Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:

  1. 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.
  2. 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).
  3. 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.

UPDATED 21 March 2010

Thanks to Michael Steele's recommendation about AviSynth and VirtualDub (and I have added the GScript plugin), I have managed to make some progress, and this script is almost working. The only issue now is that although in this example 4 mini-videos are being added next to each other as I want, the mini-video is always the same one (e.g. video-4, video-4, video-4, video-4 rather than video-1, video-2, video-3, video-4):

# A nearly functional AVS file    

# Set out some basic variables
base_audio = "C:\..."
base_image = "C:\..."
total_slides = 4

LoopThroughFiles(total_slides, base_audio, base_image)

#This is the function for outputting each combination
function AudioNImage(string mp3, string image, float fps)
    audio = DirectShowSource(mp3)
    length = audiolengthF(audio)
    rate = Audiorate(audio)
    frames = Int((length/rate)*fps)
    video = ImageSource(image, end=Int(frames), fps=fps)
    return audiodub(video, audio)

#Loop through the files to create the full command string
# My audio and image files are in the format of VID0002.jpg and VID0002.mp3
function LoopThroughFiles(int total, string audiopath, string imagepath)
        cmd = ""
        for (i=1, total) {
            audio = audiopath + "000" + String(i) + ".mp3"
            picture = imagepath + "000" + String(i) + ".jpg"
            cmd = cmd + "AudioNImage(audio, picture, 25)"
            if (i < total) {
                cmd = cmd + "+" 

So this is nearly there, but I just need to find out why the mini-videos do not increment?

share|improve this question
Is this a coding issue? If so it will get a better response at - but you will need to post some code. Also, if it is the post can be migrated (after 5 votes) so you don't need to actually post again. – ChrisF Mar 19 '10 at 13:28
It may be a stupid shot, but does the length of a single-slide video and the mp3 used with it match exactly? – Neo Mar 19 '10 at 15:38
chrisF, I didn't post this on StackOverflow as it's not exactly code, more just command line variations. There are no issues with the programming. This I believe is to do with the software commands. Neo, the weird thing is that each individual mini video is perfect. The combined video length works out correctly, but the sound duration of the combined files is longer. – user31640 Mar 19 '10 at 20:11
you might ask at which has a similar Q-n-A format and focuses on audio/video & home theater stuff. this question is welcome here but they'd appreciate it too. (and it's not part of the Stack Overflow trilogy so crossposting here and there shouldn't be a problem.) – quack quixote Mar 21 '10 at 20:23
up vote 1 down vote accepted

Your problem may be caused because of differing frame rates in the source content. Use an application such as MediaInfo to determine whether this is the issue.

Suggestion #1

I've had success using AviSynth and VirtualDub for tasks like this. Avisynth creates a video stream based off of a script written by you. It's perfect for combining multiple small files because you're able to set precise timings. You may have to use one of the many 3rd party plugins to display successive .jpg images for set periods of time.

Once you are happy with what AviSynth is producing, use VirtualDub to encode it into whatever format you want.

Suggestion #2

Do your audio and video splicing seperately, and then merge the two streams as a final step.

  1. Use an audio editor such as Audacity to create one master .mp3 or uncompressed .wav.
  2. Create your slideshow video as you've been doing.
  3. Combine the two streams. VirtualDub can do this, but it's a little cumbersome for something this simple. I've used ripbot264. The popular Handbrake tool could also probably do this.
share|improve this answer
Hi Michael, thanks for your recommendations. I have installed AviSynth and VirtualDubMod on a PC here and I'm getting closer. I have written a script in AviSynth which nearly works, but is not changing the images/audio. I have updated my question accordingly... – user31640 Mar 21 '10 at 20:10
Michael, I'm now gonna use a combination of AviSynth and VirtualDub for creating my master files. I'm using custom code to generate an AVS Script for AviSynth and then I will use other software for encoding. Thanks for your advice. – user31640 Mar 23 '10 at 15:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.