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) Use
AVAssetReader
to open your video and extractCMSampleBuffers
Link
2) Modify
CMSampleBuffer
:Link
3) Create
AVAssetWriter
and add modifiedCMSampleBuffers
to it's inputLink
In this article
CVPixelBuffer
is used as an input toAVAssetWriter
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.