PDA

View Full Version : Dvd2avi and audio sync problems


ntbone
3rd October 2001, 21:24
If you have ever had audio desyncronization, either in playback or in conversion here may be answeres.

I have been recording TV episodes for about 4 weeks. I have 3 weeks worth stored on my hard disk. I have watched them all (over the course of 3 weeks). I also have 2 movies. Majority of them (all but 5 videos) were recorded at 352 by 480, 4.8 mpbs using the built in ati profile for this configurcation. None of them have audio sync problems when played in the ati player.

I decided to convert some of them to divx and have stumbled across some problems and the possible source for audio desync in ANY conversion from ANY mpeg to divx.

Here is what i have found. On a fresh install of win2k, a fresh install of the mmc 7.1 and a fresh install of the dvd 4.1 here is what is used when displaying a mpeg2 file. The graph (as shown in graph edit) uses the built in mpeg2 splitter provided with windows, the cine master video decoder and a mpeg audio decoder. These are then passed on to an audio renderer and a video render. The playback fine with no problems with audio sync. This codec only works if the overlay is not being used by another app (the tv or another movie).

I install ulead video studio 4. This installs the ligos playback codec. Specifically this includes the ligos mpeg splitter, the ligos video decoder. If these codecs get set as the default ones to use for mpeg2 then the ati software uses them. If another video is open then windows will uses these to render the mpeg file to a non overlay renderer. If a graph is made with these codecs, i get severe audio desync. Specifically, a 20 minute video was off sync (recorded with NO dropped frames). I was getting frustrated as to why after installing some software (be it the ulead product or something else) i would get audio desync. This is because the app makes this ligos coded the default. Since the ligos codec produces audio desync (and i beleive the demuxer is part of the problem) i would not use this codec for anything.

There is also another mpeg2 codec avaialbe from www.elecard.com. This codec also has its own splitter and video decoder and also suffers from severe audio problems. It also cannot be used.

The mpeg2 played back properly with the powerdvd decoder as well. It also used the same mpeg2 splitter. The ravenset (something like that) one also worked. I am willing to be the windvd one also works though i have not tried it.

I tried editing the videos in ulead video studio, audio desync in the resulitng video. I tried it in a demo of ulead media studio pro 6 and 6.5 and both gave audio desync.

I tried conversions with dvd2avi, and it got audio sync issues (this is the frame serving method). I also got issues with flask mpeg, xmpeg and other ones. Some would not even read the mpeg. Dvd2avi read it fine but would properly sync the audio.

I looked into mpeg inplace editors, ie editors which just cut mpegs without recompression. Found 3 of them that would. And they acheived proper audio sync (at least with the decoders that worked with the original file.). They include MyFlix and M2-edit (www.mediaware.com), nanopeg-editor which hung up and enver worked and one from www.vitecmm.com. These editors have in general crappy interfaces and cost much more then i am willing to pay. Plus they still don't allow me to decode them.

Now i formulated a hypothesis as to why dvd2avi method (refer to www.doom9.org for this method) gets audio desync i believe for one reason. The program demuxes the audio track or converts it to wav and then makes a sort of project for the video. The streams are devided at the begining of the file. THe wave is given a offset which i used and didn't help. The tracks usually were of different size by up to 800 ms. Thats quite a lot. I tried things like adjusting the frame rate, and manual sync but thats a pain the butt. Now here is my theory. The reason that the video and audio is off is because the mpeg2 program stream contains valuable information about how to keep they in sync. Thus to get the correct audio and video sample from the file, you cannot just demux them convert them and seek to the same spot. The time codes may be constantly adjust due the fact that during capture a frame may be dropped here or there. Throwing away this infromation is not good enough. Dvd2avi should read the program stream and provide both the audio and video sample for a given spot. I noticed that if i tried to use a range on a vob file or mpeg file that the audio would always come out wrong.

Basically there are two ways to go here. Figure out how to modify dvd2avi or (mpeg2dec.dll) to read both audio and video and pass them along, or make a directshow component for video from dvd2avi and use the already working demuxer provided by windows. I tried the IMedia method, but it requires the use of the ligos decoder and thus does not help the situation. I am currently working on a solution and would definitly appreciate input from anyone who can give insight into this.

I am almost sure that the mpeg program stream contains the vital information for keepying the audio in sync. If you want to know more about the mpeg2 splitter download the Directx SDK, or platform sdk and read up on it. Its the only one that works properly. It should not be difficult to convert the dvd2avi project ot a direct show (though i am in school so it will take time) and this may even provide a decent mpeg2 player for free for those who have a decent machine. My machine can decode at 30 some frames per second in dvd2avi. It will also offer the most freedom, no more scripts, or plugins or anything like that. (though i think those are still very nice).

Roginator
20th December 2001, 08:08
Let me know if you've figured out how to fix this problem. I just got a hardware MPEG-2 card and trying to send it to VirtualDub for editing is causing me to lose what little hair I have left.

trbarry
22nd December 2001, 20:59
What is needed is a version of Virtualdub that can just read mpeg2 files directly, including ac3 sound and the timing information.

While Avery Lee may not be able to support that directly in Virtualdub because of licensing issues I'm surprised that there doesn't seem to be source for a modified Vdub floating around the web somewhere.

- Tom

Roginator
23rd December 2001, 03:07
What I can't understand is why Graphedit can't produce synchronized AVI files using the same DirectShow filters used by DVD players, etc.

You can use the following filters, but the end result is not in sync:
I-Media Multiple MPEG2 Stream --> Ligos MPEG Splitter --both--> Ligos MPEG Video Decoder and Cyberlink Audio Decoder --merge--> I-Media AVI output.

24hourloop
27th December 2001, 21:01
Because the audio stream in an AC3/MPEG file may be offset by a certain amount from the video stream. Both are completely independent. As a matter of fact you are quite likely to see many instances where they do not start on the smae boundary.

toejam13
12th September 2009, 04:11
What is needed is a version of Virtualdub that can just read mpeg2 files directly, including ac3 sound and the timing information.

I have VirtualDub 1.9.0 with both an MPEG and AC3 plugin. It handles both elementary and interleaved MPEG1/2 files fine.

The problem, as I have read it, is that VirtualDub cannot handle variable framerate video streams. To do so would require an entire rewrite of the video stream engine. Supposedly, this is one reason why VirtualDub does not handle MKV files.

I have one movie, which according to MPC, has a sync offset that slowly climbs from 0ms to 280ms over the span of 50 seconds, then begins to drop over the next few minutes. Neither DGindex+AVIsynth nor VirtualDub w/ AC3+MPEG2 plug-ins can handle it. VLC only converts the video, discarding the audio streams. However, MPC and VLC can play back the VOB files with the audio in-sync.

So, direct import doesn't do much if the underlying system can't adapt to the weirdness of the source. Again, that would require a re-write of VirtualDub. Hopefully, that could happen some day.

thewebchat
12th September 2009, 06:51
Sweet necropost. You just bumped an 8 year old thread. There ought to be an award for that.