View Full Version : Determine Audio Skew
moon1234
21st May 2004, 01:47
I have been reading for ages and have NEVER run across a tool that can tell me what the audio skew is in a an AVI file.
I find numerous threads on how to add or change the skew using a miraid of tools (VdubMod, NanDub, Avimux, etc), but never a tool to tell me what the delay is that is currently applied to the file.
My dilema is that I convert XVID files to SVCD and they audio sync is perfect in the AVI file and ever so slighly off in the SVCD. But reading the file in NanDub shows a preload skew, but all AVI files with AC3 sound show a preload skew. The audio could be offset by 8 seconds or more and this value is nowhere to be found. I even tried Gspot and it does not display this information.
I know that their has to be some way of calculating or finding this information for a given AVI file. Will someone plonk me on the head and tell me how to find this value. I would like to be able to find it in Miliseconds if possible.
Thanks,
Moon1234
Matthew
21st May 2004, 02:25
I made a tool for this - for mp3 audio only - no one was interested though :p
http://forum.doom9.org/showthread.php?s=&threadid=74445
It's been updated and is now better, I just use it for personal use. I'll PM you a copy.
Some mp3s (before muxing) have a tag at the beginning, in this case the tool fails (this tag must be deleted first using a hex editor). Also, the avi may need to ahve been muxed in nandub/virtualdubmod.
Instructions:
-Extract program files to directory.
-Open avi in nandub
-Chop off all but first 20 secs or so.
-Use "save wav" and save as audio.mp3
-Save video only (set audio to no audio and video to direct stream copy) as video.avi
-Optional step to ensure success: open audio.mp3 in a hex editor and ensure that structure is as follows. First 58 bytes wave header. Thereafter lots of zeros (no zeros=no delay). After zeros first hex byte should be FF (denotes start of mp3 stream), if there is a tag delete it so that this condition is true and save file.
-Run the bat, wait a couple of mins, and check out the delay.txt
The hex editor bit might seem confusing but if you have one installed it's easy as.
I know it works because I use it, e.g. it told me an avi had a delay range of 2029-2050 (I think), I used a delay of 2040 in the DVD project and it synced perfectly.
AC3 is easy, just demux the audio using VirtualDubMod then run through beplit/besliced. If there is a delay the log will say "sync found after XYZ bytes". Divide this number by bitrate x 4 (usually. 448x4=1792) and you have your audio delay.
moon1234
21st May 2004, 02:40
The MP3 audio thing is good, but seems rather intensive. I like the AC3 audio one. That will be the biggest help. My bud sends me backups of some of the overseas MPEG2 DVB shows and he just leaves the AC3 muxed in. Unfortunatly when I convert to SVCD the Audio is ALWAYS off by just a smidge. My wife can't tell, but I sure can.
Thanks,
Moon1234
Matthew
21st May 2004, 03:12
Ahhh ok, so it's still just me who finds this tool useful :p
Obviously you don't need it, but believe me, it's practically zero effort to use and beats the hell out of manual syncing. I know from experience =)
moon1234
21st May 2004, 08:55
Don't get me wrong. I will use it. It just dumbfounds me that you are the only person that has ever developed a tool to read this information. Does everyone else just guess?
Thanks for putting forth the effort. I for one will be VERY happy to have perfectly synced audio.
Matthew
21st May 2004, 10:36
It dumbfounds me too a bit...but I suppose technically minded people who are into divx/xvid aren't interested in converting them.
The tool doesn't really read the information per se, it just remuxes until the delay in the remuxed file matches that in the original. Still trial and error, but it's automated :)
And yes, AFAIK everyone else just guesses - well, experiments with different delays and watches the video, anyway. I did that once and most certainly did not want to do it again.
Evaldas
23rd May 2004, 16:56
Originally posted by Matthew
Instructions:
-Extract program files to directory.
-Open avi in nandub
-Chop off all but first 20 secs or so.
-Use "save wav" and save as audio.mp3
-Save video only (set audio to no audio and video to direct stream copy) as video.avi
-Optional step to ensure success: open audio.mp3 in a hex editor and ensure that structure is as follows. First 58 bytes wave header. Thereafter lots of zeros (no zeros=no delay). After zeros first hex byte should be FF (denotes start of mp3 stream), if there is a tag delete it so that this condition is true and save file.
-Run the bat, wait a couple of mins, and check out the delay.txt
hi,
thanks Matthew for the tool. i asked in the forum if there's such a tool, maybe, 2 years ago or so :) thanx again :)
but i need some help, cause i don't understand one thing in your instructions.
i bolded the part which i do not understand. what tag should i delete, if there it is? and how to delete: replace with 00 or delete some byte(s), so the file will be shorter by some byte(s)?
and one more qustion. if the 59th byte is FF, so there is no delay at all?
Matthew
26th May 2004, 03:19
I'll send you a PM with the later version.
Here is an example (screenshot) of a file with a delay+tag. The tag is selected. Just delete the selection (don't replace with 0s).
http://www.yousendit.com/d.aspx?id=91A21E18AC1E4E171C1CA762B3284EB0
Note that the result won't be useless if you process a file like this without deleting the tag, it will just be something like "delay range starts at 508 and ends at 507". If I recall correctly, the second number (507 in this example) will be the end of the real delay range so if you just minus 10 (=497) and use that as the delay the result should be fine.
Anyway, the first 58 bytes is always wave header inserted by nandub, so if the 59th byte is FF then it's most likely the original source (e.g. DVD from which avi came) had a delay of 0.
I say most likely because the original source could still have a delay - if the inputted delay in nandib/virtualdubmod is anywhere between 0 and ~30 then no delay is added (i.e. the avi will be unnoticeably out of sync if the delay is 20 ms). This is why if you use the tool on your avi, the delay.txt will say the delay is between 0 and 30 something ms.
abysas
8th July 2004, 02:23
Mattew, I'd like to have your program too. Could you please give me a link because that link in your post doesn't work anymore. Also I have a question on your instruction about ac3 delay, what the resulted number mean, is it a time in ms or a number of frames? Thanks alot for your efforts and help in solving this problem :)
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.