BradLarson / GPUImage

An open source iOS framework for GPU-based image and video processing
http://www.sunsetlakesoftware.com/2012/02/12/introducing-gpuimage-framework
BSD 3-Clause "New" or "Revised" License
20.25k stars 4.61k forks source link

Append/merge multiple video files into one final output video? #61

Open phil-m opened 12 years ago

phil-m commented 12 years ago

Hi, I've been experimenting with this great framework (thanks Brad/All for the amazing work!), & have recording with various filters saving to output files working.

I now need to merge a number of the already recorded videos into a final single composition. Is this possible with the current api?

As a test, I've tried to edit the SimpleVideoFileFilter example to play 2 video files (pre added to the project) one after the other, but can't find a way to hook into the end of the first one so I can start the second?

Does anyone have any pointers/ideas on how I could go about doing/adding this functionality?

Thanks Phil

BradLarson commented 12 years ago

I don't know of an easy way to do this, because I try to preserve timestamps for video frames coming from movie sources, and the timestamps from two movies will overlap with one another. This wouldn't record well in the target video, so you couldn't combine videos just by feeding one in after another.

This would require some sort of mechanism for shifting one movie's timestamps to come after the other's. You're welcome to try adding this functionality, but I probably won't implement something like this for a while.

phil-m commented 12 years ago

Thanks very much for the quick response Brad.

I can see the problem now, thanks for detailing the timestamp issue.

As I'm on a bit of a tight deadline, & am still learning my way though the GPUImage code base, I've opted to do this outside of GPUImage for now. Luckily for this project all the filters are applied to the individual video files, so the final comp only needs to merge them without any additional effects.

If anyone else requires this same feature for now, here's a couple of links that helped me get started with using AVMutableComposition & AVAssetExportSession to merge/compose multiple video files into a single final video: http://stackoverflow.com/questions/3298290/avasset-and-avassettrack-track-management-in-ios-4-0 http://www.iphonedevsdk.com/forum/iphone-sdk-development/101375-ios-5-error-merging-3-videos-avassetexportsession.html http://praveencastelino.blogspot.co.uk/2010/09/create-movie-using-avfoundation.html

Thanks again for your help & for your work on this library, its making image & video handling on iOS a joy!

omerwaqaskhan commented 12 years ago

Hi, phil-m, I want to have the same functionality but with network files, like the files will be streaming from network after one another and also I need to have seeking functionality in them so that if I seek through multiple files then that should be done properly.

Is it possible?

Here is a link I have got related to this, but I am not getting through

http://www.viggiosoft.com/blog/blog/2011/10/15/video-composition-with-ios/

Thanks

foxfling commented 12 years ago

Hello all, I'm trying to do the same thing but only with a little difference. I want to put one video on top of another with some chromakey effect. You can image like this, normally when doing chromakey, we replace the color (e.g. green) with a background picture. But this time I wanna replace it with a recording video. In this way, I could make sample movies with some clips. I tried to render a movie file on top of a video camera. But it doesn't work. Do you have any clue?

alariccole commented 12 years ago

I think doing it outside of GPUImage is necessary, and I believe this is a feature outside of the scope of this project. I vote to close it.

RickCaine commented 11 years ago

You can find many mergers by Google Search:Movie Joiner| Best Video Combiner, VOB Merger, MKV Merger, MP4 Merger, AVI Merger