Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > VirtualDub, VDubMod & AviDemux

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 24th September 2008, 22:14   #1  |  Link
vemon
Registered User
 
Join Date: Jul 2008
Posts: 2
Fixing progressive out of sync audio with VirtualDub script

I've managed to record a bunch of video clips using CamStudio + ffdshow (uncompressed video & pcm audio) which all have different length audio and video tracks (audio track is always shorter than video track). I'm not sure what's the source of the problem since uncompressed video shouldn't introduce any compressing overhead.

Anyways... I created a VirtualDub script to fix the problem but it still has some issues. I'm only able to calculate the desired time stretch ratio for the audio track by manually entering the video frame rate and the audio sampling rate. If these could be determined programmatically I would have a completely automatic script for fixing my video clips.

My question is: Does anyone know if it's possible to get the video frame rate and the audio sampling rate in a VirtualDub script?

At the moment my script looks like this:

Code:
declare infil;
declare stretchfil;
declare outfil;
declare ratio;
declare fps;
declare audiosrate;

fps = 25;
audiosrate = 44100;

VirtualDub.Open(VirtualDub.params[0],0,0);
VirtualDub.video.SetMode(0);

VirtualDub.audio.SetSource(1);
VirtualDub.audio.SetMode(1);

VirtualDub.audio.EnableFilterGraph(1);
VirtualDub.audio.filters.Clear();

infil = VirtualDub.audio.filters.Add("input");

stretchfil = VirtualDub.audio.filters.Add("time stretch");
ratio = (((double)VirtualDub.video.length / fps) - 1) / ((double)VirtualDub.audio.length / audiosrate);
VirtualDub.Log("calculated stretch ratio:");
VirtualDub.Log(Sylia.ToString(ratio));
VirtualDub.audio.filters.instance[stretchfil].SetDouble(0, ratio);
VirtualDub.audio.filters.Connect(infil, 0, stretchfil, 0);

outfil = VirtualDub.audio.filters.Add("output");
VirtualDub.audio.filters.Connect(stretchfil, 0, outfil, 0);

VirtualDub.SaveAVI(VirtualDub.params[1]);
vemon is offline   Reply With Quote
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 00:58.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.