PDA

View Full Version : How to syncronize audio to the video ?


Blase Marzo
14th January 2005, 11:34
I have az avi vith 24,1 FPS. Audio and video are in sync.

1. I demux audio and video.

2. Change the video fps to 23.976 with virtualdub direct stream copy.

3. Change the audio fps to 23.976 with besweet.

The audio and video are out of sync. Some part of the movie are in synch and the most of it aren't.

How can I syncronize the audio to the video to be correct ?
Which program and how ?

Thanks for your help.

ursamtl
14th January 2005, 16:18
If the part that's in sync is at the beginning and then the sync gets progressively worse towards the end of the movie, then it's obviously a small speed difference that's even throughout the length of the movie. However, if the in sync section appears after a section that was badly out of sync, then it's a problem with the overall movie and would require a lot more work.

To fix the sync in the first scenario I just described, you could try a program called avisynth (www.avisynth.org). You have to write a simple script in Notepad and save it as an .avs file. If you open this file in a player program such as Media Player Classic (an excellent free media player program), the program sees the script as if it were the actual video file but with the commands in the script. It sounds complicated, but it's really simple. As a matter of fact, I did this last night with an mpeg file I downloaded containing a poor transfer of 70's Super 8 concert footage. It was sped up quite a bit. I slowed it down to about 89% of its speed using an avisynth script, which I then opened in Media Player Classic, but then the audio seemed to go out of sync progressively. I simply tried slight increases and decreases in the numbers I used in the script, resaved the file, replayed it and within 15 minutes, I had the whole clip in sync. Then I used a program called TMPGEnc to read the avs file and encode it as an mpeg file. The process is called "frameserving" and there's an excellent Doom9 forum (http://forum.doom9.org/forumdisplay.php?s=&forumid=33) you can check out for info on it. Last night was my first try at frameserving and it worked without a problem. Give it a try.

On the other hand, as I said above, if the sync problem is not linear (synced sections occuring after out of sync sections), the problem would require loading the file into a full-fledged video editing program and trying to go through it scene by scene or section by section and fix the sync in each one. That could be a big job!

Regards,
Steve.

Blase Marzo
14th January 2005, 19:03
I write an avs file about what ?

what should I do with the audio ?

Can you explain it more detailed ?

ursamtl
14th January 2005, 22:35
Ok well it's quite simple. I had a file called 032475.mpeg with an audio sample rate of 44100 and a frame rate of 29.97. I knew the key of the opening song to be A. In the video clip it was sped up to roughly B. The freqency of A440 is about 89% of D, so I started with values that were about 89%: 39250 sampling rate and 26.67 frames/sec. My .avs script looked like this:

DirectShowSource("v:\032475.mpeg")
AssumeSampleRate(39250 )
AssumeFPS(26.67)

The sync wasn't quite right, so I tried increasing/decreasing values until I arrived at a combination that worked:

DirectShowSource("v:\032475.mpeg")
AssumeSampleRate(39730)
AssumeFPS(27)

This script plays an mpeg file "v:\032475.mpeg" but instead of using the file's internal settings, it assumes (or forces) a sample rate of 39730Hz at a video speed of 27 frames per second. Note that it doesn't actually change the file itself. It just causes the playback software to think the file's settings are the assumed ones from the script, so the software then plays each stream at the indicated speeds. By using this .avs file as my source in TMPGEnc, I was able to create a new file with internal settings of 48000 and 29.97 to create a DVD compatible mpeg file.

It's not that complicated once you try it. Just do a bit of reading first on the www.avisynth.org web site or in the avisynth forum.

Good luck,
Steve.