iOS - Reversing video file (.mov)

2019-06-17 10:17发布

问题:

Requirement :

It sounds like litte different but this is what I want to achieve. I want to make movie (.mov) file in reverse. Just like how we rewind the movie file. I also want maintain same frame rate as my video is containing.

NOTE: I do not just want to play video file in reverse order. I want to generate new movie file playing in reverse order.

My Exploration :

I thought of below steps to perform to do the same.

  1. Make chunks of video files with specific frame rate using AVAssetExportSession
  2. Merge all these video chunks into single movie file using AVMutableComposition and AVAssetExportSession.
  3. Also merge audio of each file into new video file during the merge process.

Using above steps , I am able to achieve resulting video file in reverse but I am having below concerns.

  1. It takes good amount of time if video is of long duration.
  2. It also consumes huge CPU cycles and memory to accomplish this process.

Does anybody is having any other optimized way to achieve this? Any suggestion will be appreciated.

回答1:

Here is my solution , maybe it can help you. https://github.com/KayWong/VideoReverse



回答2:

you need to refer AVFoundation library to achieve your task..

i have done only 30 seconds video edit with AVAssetExportSession & AVMutableComposition.

this is the link which you need to refer and its very help full.

http://www.subfurther.com/blog/category/avfoundation/

And also if you wants to refer WWDC conference PDF for Editing Media it would be better.

this link total source : https://developer.apple.com/videos/wwdc/2010/ And this link covers Editing Media With AVFoundation

About memory cycles.. it also consumes more memory while Exporting.