6

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)
{
    GScript("""
        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 + "+" 
            }
        }
        GEval(cmd)
    """)
}

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

1 Answers1

1

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.