如何在肖像应用程序中录制风景视频? (Swift 2,iPhone) [英] How to record landscape video in a portrait application? (Swift 2, iPhone)

查看:92
本文介绍了如何在肖像应用程序中录制风景视频? (Swift 2,iPhone)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我的人像iPhone应用程序中录制风景视频。

I need to record a landscape video inside my portrait iPhone application.

是否有可能或被任何硬件限制阻止?

Is it possible or is it blocked by any hardware limitation?

使用AVCaptureVideoPreviewLayer我能够更改预览方向,但视频仍以纵向方式录制。

Using AVCaptureVideoPreviewLayer I was able to change the preview orientation, but the video is still recorded in Portrait.

欢迎任何想法!

推荐答案

您应该能够为视频录制设置横向方向。并将预览图层设置为纵向,以实现以纵向预览的横向视频。如果我理解你的问题。你能展示你已尝试过的任何代码吗?

You should be able to set the orientation to landscape for the video recording. And set the preview layer to portrait to achieve a landscape video that is previewed in portrait. If I understand your question correctly. Can you show any code you tried already?

        if captureSession.canAddOutput(videoOutput) {
            captureSession.addOutput(videoOutput)
            let connection = videoOutput.connectionWithMediaType(AVMediaTypeVideo)
            if connection.supportsVideoOrientation {
                connection.videoOrientation = AVCaptureVideoOrientation.LandscapeRight
            }
            print("adding output")

        } else {
            print("Could not add front video output")
            return
        }

    ...

    func setupPreviewLayer() {

        ...etc...

        previewLayer.connection.videoOrientation = AVCaptureVideoOrientation.Portrait

        ...etc...

    }

这篇关于如何在肖像应用程序中录制风景视频? (Swift 2,iPhone)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆