PDA

View Full Version : Joining multiple AVI-files -> get audio off-sync


GenoSV
4th September 2005, 21:32
Ok, I got a bit of a problem.
I got an episode of a tv series and it's captured in 8 parts (I would guess there was 6 commercial breaks and that's why it became like this).
I now want to join those 8 files together into one AVI file without re-encoding it, so I turned to VirtualDubs Direct Stream Copy function.
The problem is that the audio track is a little shorter or alittle longer than the video track (around 100ms or so on each file), and it seems like VirtualDub uses something similiar to AviSynth's UnalignedSplice filter and just add the audio onto the previous audio track etc. So thanks to that I get audio/video sync problems (at some parts almost none, at some parts like almost half a second).
Is there any way to fix this without having to re-encode the video stream?

I tried the AlignedSplice function in AviSynth, although then the video becomes YUV12 and get's like reeeally big if I use Direct Stream Copy on it.

Anyone have a solution?
I am very thankfull for any help I can get.

//geno

mic
4th September 2005, 22:05
Posting in the Avisynth section should get you a script (or ideas for 1) that eliminates the prob. of file size.

If the audio per clip is in sync, could add silence to the audio so the length matches. Ideally you could do this by creating a new audio track while copying the vid -- a new audio track should match the length of the video it's matched to. Then join clips.

If the sync is off per clip, use goldwave or similar to time-stretch to match video & re-check sync.

mic
5th September 2005, 22:05
When audio is shorter, to add silence & make audio & video lengths match in V/Dub without recompression... Works with wav & mp3 at least.

1) Create 5 sec (or as long as needed) avi file using same codec and settings as original. Video can be black or anything you'll notice, audio should be silence. If you want to play with shorter video, longer audio, think it will work also.

2) Import original avi file, go to video menu, click on Select Range. Note the end frame count. Append blank avi file created in step 1. Go back to select range and replace end frame count with original number, make sure cut off audio box is checked. Set audio to source and direct stream copy, set vid to direct stream copy, save avi. Check the last frame of new video to make sure you didn't include a frame or two of blank or patch avi.

GenoSV
6th September 2005, 07:23
thanks for the help mic.
I will try what you said in the last post later today (at work now so not very good time).
Thanks alot.

bond
6th September 2005, 09:54
for audio streams which are longer than the video virtualdub(mod) can cut the too long part away, i think it even does this by default when directstreamcopying

another reason for desync can be if there is a delay at the beginning of one of the following avi files

virtualdub(mod) either cuts too long streams at the beginning or fills the beginning with garbage (i think lots of zeros) for setting the delay
of course if you now try to append such an audio stream with garbadge at the beginning to another audio stream, things will not work and you might get desync as result
its not nice, but thats how avi works in reallife

GenoSV
6th September 2005, 19:44
Thank you so much for your help mic.
Tried what you told me to do and it worked out just fine. No desync now after joining all the files.

And thank you too bond for the info and taking time to read this topic.
Thanks alot.

mic
6th September 2005, 23:50
its not nice, but thats how avi works in reallife
If it interests anyone...:) My *guess* FWIW is audio handling in V/Dub & Mod is a result of using same pipeline for speed, if I remember from the articles at VirtualDub.org. Much slower NLEs usually add silence at either end as needed I think, or pad with blank video. Careful with the blank vid though -- I've seen other apps sometimes have a terribly reaction to it. :(