使用具有自定义尺寸的 AVFoundation 录制视频? [复制]

Posted

技术标签:

【中文标题】使用具有自定义尺寸的 AVFoundation 录制视频? [复制]【英文标题】:record video with AVFoundation with custom dimensions? [duplicate] 【发布时间】:2012-02-18 02:37:58 【问题描述】:

我正在使用 AVFoundation 录制 MOV 文件,但我无法找出如何更改视频的尺寸。我将captureVideoPreviewLayervideoGravity 属性设置为AVLayerVideoGravityResizeAspectFill,并且显示预览层的UIView 具有自定义尺寸(屏幕的纵横比不同)。

录制工作正常,但录制视频的尺寸与屏幕的纵横比相同。如何使用 UIView 或预览层的纵横比进行录制?

【问题讨论】:

您想将视频裁剪成新的尺寸、缩放或变形吗? 我遇到了一个类似的问题。您是从屏幕上录制视频还是从摄像头录制视频? @MobileOverlord 我猜想裁剪和放大,因为 GravityResizeAspectFill 就是这样做的 @URLArenzo 我正在从相机录制 我还在寻找最佳答案 【参考方案1】:

这是使用 AVFoundation 录制视频的最佳示例代码

https://developer.apple.com/library/ios/#samplecode/RosyWriter/Introduction/Intro.html#//apple_ref/doc/uid/DTS40011110

在文件中:RosyWriterVideoProcessor.m

方法名称

- (BOOL) setupAssetWriterVideoInput:(CMFormatDescriptionRef)currentFormatDescription

在videoCompressionSettings中你可以改变尺寸,希望对你有帮助。

【讨论】:

看不懂

以上是关于使用具有自定义尺寸的 AVFoundation 录制视频? [复制]的主要内容,如果未能解决你的问题,请参考以下文章

swift使用AVFoundation实现自定义相机

swift使用AVFoundation实现自定义相机

php ACF - 具有自定义尺寸的图像

质量:自定义 AVFoundation 相机应用程序 VS。 iOS 标准相机应用

AVFoundation的自定义相机

使用AVFoundation 自定义相机和录制视频