Successfully concatenating multiple videos
- by wiseguydigital
My mission is to create videos out of old web slideshows. To start with I have jpegs and audio files that worked as Flash slideshows in an old system, structured such as this:
Audio structure
my_audio_1.mp3 (this file is a 3 second mp3 of silence)
my_audio_2.mp3
my_audio_3.mp3
my_audio_4 etc... roughly 30 mp3s per slideshow
Image structure
my_image_1.jpg (this acts as the opening slide)
my_image_2.jpg
my_image_3.jpg
my_image_4. etc... roughly 30 images per slideshow.
As there are almost 100 slideshows that must be converted to video, I have created a web-based interface using PHP to automate the process, that sits on a local system and attempts to combine the files using shell_exec(). The process uses the following workflow:
Loop through each slide and make an avi or mpeg. So for instance my_mini_video_2.avi would be a video that consists of my_image_2.jpg and has a soundtrack of my_audio_2.mp3. This slide would last the length of my_audio_2.mp3.
Join / stitch / concat all of the mini videos to create the final video (Using a combination of cat and either mencoder or ffmpeg (I have also tried avimerge but to no avail).
Transcode the new 'master' video to various formats such as flv etc.
I thought this would be simple and have been close on many occasions but it still won't work. I can't get past stage 2 as I can't get a perfect 'master' video. I have now experimented with Mencoder, FFMpeg and seem to have been through every combination I can think of. The problem is that the audio and visuals never sync, no matter what I try.
Also, I have even tried created audio-less mini videos, joining the MP3s into one long MP3 using both cat and mp3wrap and then assigning the new long MP3 as the audio track, but this always produces either a very short file or a badly slowed down file and makes the female voiceover sound like a male boxer!!!
There appears to be no problems at all with the original files.
Does anybody have any experience in producing a video successfully from the same kind of starting point? Or any ideas on what I may be doing wrong?
As an example:
If I create silent mini-videos, and stitch them together into 'temp-master.mpg' and then join the MP3s together into single MP3 called 'temp-master-audio.mp3', the audio file's duration is 09:10 and the video file's duration is 08:35. They should be the same and the audio will seem sloooow.
I haven't posted code as I have written lots and lots of combinations.