如何在iOS中裁剪视频 [英] How to crop a video in iOS

查看:392
本文介绍了如何在iOS中裁剪视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直以Apple提供的RosyWriter示例代码为起点,我想找到一种方法来裁剪视频.

I was having a look at the RosyWriter Sample Code provided by Apple as a starting point and I'd like to find a way how to crop a video.

所以我有来自iPhone相机的全分辨率视频,但我只想使用其中的裁剪部分(并旋转此子部分).

So i have the full resolution video from the iPhones Camera, but I just want to use a cropped part of it (and also rotate this subpart).

我认为在captureOutput:didOutputSampleBuffer: fromConnection:中,我可以通过修改传入的CMSampleBufferRef来修改每个帧.

I figured that in captureOutput:didOutputSampleBuffer: fromConnection: i can modify each frame by modifying the CMSampleBufferRef that i get passed in.

所以我现在的问题是:

  1. 这是裁剪视频的合适地方吗?

  1. Is this the right place to crop my video?

在哪里指定最终视频(保存到光盘上)的分辨率比AVCaptureSession捕获的完整视频的分辨率小?设置AVVideoWidthKeyAVVideoHeightKey无效.

Where do I specify that the final video (that get's saved to disc) has a smaller resolution than the full video captured by AVCaptureSession? Setting the AVVideoWidthKey and AVVideoHeightKey has no effect.

如何裁剪视频并仍然具有良好的性能?

How can I crop the video and still have good performance?

感谢您的帮助!

非常感谢!

也许我只想知道如何通过将视频图像旋转90度,然后再次放大以适应宽度来制作以横向拍摄的肖像视频.?!?

Maybe I just need to know how I can make a video that was shot in portrait a landscape one by turning the images of the video by 90 degrees and then zoom in to fit the width again...?!?

推荐答案

在AVVideoSetttings.h中,有AVVideoScalingModeKey.将此键与定义的值组合在一起,可以控制在将图像编码到视频容器时如何缩放/裁剪视频.例如,如果您指定了AVVideoScalingModeFit的值,则使用裁剪.查看标题,了解其他值如何影响视频图像.

In AVVideoSetttings.h there is the AVVideoScalingModeKey. This key combined with the defined values control how the video is scaled/cropped when encoding the images to the video container. For example if you specified a value of AVVideoScalingModeFit then cropping is used. Check out the header for how other values effect the video images.

这篇关于如何在iOS中裁剪视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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