Possible to use AV Foundation to crop a video?

547 views Asked by At

I am trying to crop videos both taken in my app and uploaded from the user's photo library. I am looking to crop every video to be the size of the iPhone 5s screen (I know that sounds dumb, but that's what I need to do).

Can I do this using the AV Foundation framework or do I need to use Core Video? I've made multiple attempts with AV Foundation and gotten nowhere.

Also if you could link to any helpful tutorials or code samples that would be greatly appreciated.

I'm using Objective-C and working on an app designated for iOS 7+.

Thanks!

1

There are 1 answers

0
Karol Czaradzki On BEST ANSWER

1) Use AVAssetReader to open your video and extract CMSampleBuffers
Link

2) Modify CMSampleBuffer:
Link

3) Create AVAssetWriter and add modified CMSampleBuffers to it's input
Link
In this article CVPixelBuffer is used as an input to AVAssetWriter
using adapter. You actually don't need an adapter because you have CMSampleBuffers
ready you can add them straight to the input using appendSampleBuffer: method.