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

发布于 2025-01-06 09:15:46 字数 281 浏览 2 评论 0原文

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

录制效果很好,但录制视频的尺寸与屏幕的宽高比相同。如何记录 UIView 或预览层的宽高比?

I am recording an MOV file using AVFoundation but im having trouble finding out how to change the dimensions of the video. I have videoGravity property of captureVideoPreviewLayer set to AVLayerVideoGravityResizeAspectFill and the UIView showing the preview layer has custom dimensions (not the same aspect ratio of the screen).

Recording works fine but the dimensions of the recorded video are the same as the aspect ratio of the screen. How can i record with the aspect ratio of the UIView or the preview layer?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷途知返 2025-01-13 09:15:46

录制视频的最佳示例代码

这是使用 AVFoundation https://developer.apple.com/library/ios/#samplecode/RosyWriter/Introduction/Intro.html#//apple_ref/doc/uid/DTS40011110

在文件中:RosyWriterVideoProcessor.m

方法名称

- (BOOL) setupAssetWriterVideoInput:(CMFormatDescriptionRef)currentFormatDescription

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

Here is best sample code to record video using AVFoundation

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

In File: RosyWriterVideoProcessor.m

Method Name

- (BOOL) setupAssetWriterVideoInput:(CMFormatDescriptionRef)currentFormatDescription

In videoCompressionSettings you can change dimension, hope this will help you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文