nebs nebs - 1 year ago 99
iOS Question

iOS: Resizing/Cropping recorded video

What would be the best way to resize a user recorded video on the iphone?

I currently have the ability to get video data in two ways:

1) Get the file URL from

after the video has been recorded

2) Get the frames of the video as its being sent by a

For 1) I would need something which can read .mov h.264 files and spit out individual frames. Is there such a thing?

For 2) I thought about getting a UIImage for each frame, resizing the image and then recompiling a video with something like
. But this seems like a very intensive operation and I'm wondering if there's a better way to approach this problem.

Is the general idea of resizing videos to resize each individual frame and then recompile a video? Or is there a way to directly resize an entire video?

I just basically need the user to record a video, and then to resize that video to 320x320, no fancy editing.

Thanks for any help you can provide.

Edit: Maybe 'resize' is the wrong word. I really just need to crop the video so that it goes from 480x360 to 320x320. Also this cropping doesn't need to happen in real time, I can do it once the video has been recorded.

Answer Source

Alternative 2 is not going to work in real-time.

For alternative 1, use AVAssetExportSession initialized with one of the desired presets - for example AVAssetExportPreset640x480.

Experiment with AVAssetExportPresetLowQuality, AVAssetExportPresetMediumQuality, AVAssetExportPresetHighestQuality for additional resolutions.

Note that video files usually have 16:9 (or 4:3) aspect ratios, so 320x320 is not a valid option. There are no good reasons for resizing to other than the supported resolutions, unless you plan on distribute to other phones, in which case server-side transcoding is available.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download