Log in

View Full Version : Dubbing audio over multiple slides


Starduster
9th August 2010, 00:02
If I do the following, the slide is displayed as long as the audio/video file plays:

LoadVFAPIPlugin("swf.vfp","SWFSource")

vd = DirectShowSource("MOB_1390_2_1.flv", fps = 29.97, convertfps = True)
fv = SWFSource("slide1.swf").flipVertical.AssumeFPS(vd).ConvertToRGB32()
sld1 = AudioDubEx(fv,vd)

Which is exactly what I want. However when I try to put multiple sld's end to end, they only display for a second each using this code:

LoadVFAPIPlugin("c:\program files\AVIsynth\Plugins\swf.vfp","SWFSource")

vd = DirectShowSource("MOB_1390_2_1.flv", fps = 29.97, convertfps = True)
fv = SWFSource("slide1.swf").flipVertical.AssumeFPS(vd).ConvertToRGB32()
sld1 = AudioDubEx(fv,vd)

vd = DirectShowSource("MOB_1390_2_2.flv", fps = 29.97, convertfps = True)
fv = SWFSource("slide2.swf").flipVertical.AssumeFPS(vd).ConvertToRGB32()
sld2 = AudioDubEx(fv,vd)

vd = DirectShowSource("MOB_1390_2_3.flv", fps = 29.97, convertfps = True)
fv = SWFSource("slide3.swf").flipVertical.AssumeFPS(vd).ConvertToRGB32()
sld3 = AudioDubEx(fv,vd)

sld1 ++ sld2 ++ sld3

How can I get them each to play full length?

Gavino
9th August 2010, 10:56
AlignedSplice (or ++) adjusts the audio length of each clip to match its video, so if the audio is longer, it gets cut off. Here you need something that instead extends the video to match the audio.

This function repeats the last video frame to match the audio length:
function PadVideo(clip c) {
af = ceil(AudioLengthF(c)/AudioRate(c)*Framerate(c))
lastf = Framecount(c)-1
reps = max(af-lastf, 1)
return c.Loop(reps, lastf, lastf)
}
You can then use
sld1 = PadVideo(sld1)
and so on, to get each clip the correct length before appending them.

Starduster
9th August 2010, 12:52
Thanks so much... words cannot express the level of frustration I'm feeling right now!! ;-)

The clip appears to be running for the proper amount of time, but there is no audio. Could it be because AudioDub is handed only one video frame? Here's what I have:

function PadVideo(clip c) {
af = ceil(AudioLengthF(c)/AudioRate(c)*Framerate(c))
lastf = Framecount(c)-1
reps = max(af-lastf, 1)
return c.Loop(reps, lastf, lastf)
}

LoadVFAPIPlugin("swf.vfp","SWFSource")

vd = DirectShowSource("MOB_1390_2_1.flv", fps = 29.97, convertfps = True)
fv = SWFSource("slide1.swf").flipVertical.AssumeFPS(vd).ConvertToRGB32()
sld1 = AudioDub(fv,vd)
sld1 = PadVideo(sld1)
return sld1

Thanks again!

Starduster
9th August 2010, 13:11
Like I said... so frustrated!! On one computer (XP) the following works perfectly, clip is shown and audio is heard for duration of vd:

vd = DirectShowSource("MOB_1390_2_1.flv", fps = 29.97, convertfps = True)
fv = SWFSource("slide1.swf").flipVertical.AssumeFPS(vd).ConvertToRGB32()
sld1 = AudioDub(fv,vd)

I copied the exact same .avs, .swf. and .flv to another computer (Server 2008) and it has no sound and appears to have no length (doesn't move the progress bar). I've just installed the latest AVIsynth and K-Lite codec pack on both.

If I had any hair left, I'd pull it out!!

Gavino
9th August 2010, 17:01
The clip appears to be running for the proper amount of time, but there is no audio.
Damn! My PadVideo function isn't right - I was forgetting that Loop() affects the audio as well.

The last line must be replaced by
return AudioDub(c.Loop(reps, lastf, lastf), c)

The PadVideo function should also help when you have only a single .swf file.

Starduster
12th August 2010, 22:08
Gavino, thanks for all your help. I have no idea what's going on, I still can't hear audio playing with WMP but I encoded it by accident with ffmpeg and it works fine!! Go figure.