Log in

View Full Version : Avidemux - Audio Sync Woes


ViciousXUSMC
15th November 2008, 17:30
Im in the process of ripping my DVD collection onto my HTPC.

I have what feels like every ripping & encoding software under the sun. I settled with DVDFab5 as my ripper and Avidemux as the encoder.

I love the x264 codec and think its the best for what I am doing, but its hard to find good support for it.

Im ripping just the main movie with DVDFab (.Vob) and then encoding to a .MP4 container with x264 for video and AAC for audio.

Every movie was out of sync until I finally found that I needed to change the frame rate from 29 to 24. That fixed 90% of them. (also over time found I need to manually set the aspect ratio too...)

Now the ones that are left I am stuck. AutoGK gets it right every single time. So there has got to be a way to fix this.

I think for most of them I have discovered that if I open the properties tab in Avidemux that the video track is longer or shorter than the audio track.

I do not think a set offset will fix it, the sound will slowly desync worse over time. Also I really suck at finding a offset, there seems to be no way to do it on the fly with Avidemux that I know of so you have to save a small test file and its a major pain. Even if I got it right I would "think" its still off and keep messing with it till the end of time.

So does anybody know how to fix these audio issues I have exclusively in Avidemux? If not I would still like to do the video part and have the easiest method possible to do the audio part with a separate program. Preferably AAC (FAAC) if possible.

Thanks ahead of time for the assistance.

LoRd_MuldeR
15th November 2008, 18:44
Check the "shift" box and enter the correct delay. You may use DGIndex to find the correct delay value or just adjust the delay until the sync is good...

ViciousXUSMC
15th November 2008, 19:34
Like I said this is one of those issues with the audio needing to be stretched or something. I want to say the term is VBR but that to me just means varible quality not varible speed.

In one of the movies I can think of the Scorpion King for instance, I spent 20min getting the sync right at the start, then by the end it was off again badly. Also the delay reads "0" I think when I tried to use a program to find the delay.

however I will heed your advice and use DGIndex for the next movie I have issues with to see if it works.

Edit: No luck I show 0ms delay with DGIndex when I am ripping new police story and it has nearly a 1 minute difference between the audio track and the video track.

LoRd_MuldeR
15th November 2008, 22:39
Unless you change the framerate (duration) of the video, it should not be necessary to "stretch" the audio stream!

Keeping the audio in sync with VFR (variable framerate, not VBR = variable bitrate) content is another problem, but there's no such thing as VFR on Video-DVD's.

I converted many of my DVD's with Avidemux and there was no problem with audio sync, as long as I set the delay properly...

(BTW: What Avidemux build do you use? I think there was a bug with older builds and MP4 output)

ViciousXUSMC
16th November 2008, 08:59
The newest one from there site directly. Actually I think I am using the newest beta.

I do change the frame rate, from 29.xxx to 24.xxx because its film. Most movies DVD's have the audio track and video track within a fraction of a second of the same length. Some movies however have many seconds difference and I just cant get it to sync.

The only other thing I can think of is they do not use a standard frame rate, or they have VFR

Also the trick with DGindex always shows 0ms delay.

Im not the only person with the issue I found others on google, but I have yet to find an answer.

LoRd_MuldeR
16th November 2008, 15:52
I do change the frame rate, from 29.xxx to 24.xxx because its film. Most movies DVD's have the audio track and video track within a fraction of a second of the same length. Some movies however have many seconds difference and I just cant get it to sync.

If you change the framerate, you actually change the duration of the video track. Then it won't play in sync to the audio stream (which still has the original duration) for obvious reasons...

The only other thing I can think of is they do not use a standard frame rate, or they have VFR

DVDs are either NTSC (29,97 fps) or PAL (25 fps). There is no VFR on Video-DVDs.

Keep the original framerate of the movie (+ set up the initial delay properly) and there should be no problem.

ViciousXUSMC
16th November 2008, 22:44
Ok first of all, not a single movie yet has been PAL for me, they have all been "FILM" NTSC witch is 23.976.

All of them open and default at the 29.976 frames per second, if I check the audio & video at that point its WAY out of sync and the time difference is off by over a minute. Changing it to PAL its still off quite a bit. Film is always the right choice.

I do believe the term is tecline, that is the reason you have to change the frame rate to 24 instead of 29.

I can quite confidently tell you the audio is not a static desync that its gets worse over time and that the audio/video track times do not match up on the files that I have issues with. (I spent over an hour testing with a movie getting it perfect and by the end it was like 10 seconds off)

Also for what ever reason if I do the offset in Avidemux the effect does not seem to apply on my preview, only my saved file. Any way around this?

LoRd_MuldeR
16th November 2008, 23:03
Can you offer sample to re-produce the problem please?

ViciousXUSMC
17th November 2008, 13:59
Sure how big should it be and where is a good place to host it?

LoRd_MuldeR
17th November 2008, 14:27
Sure how big should it be and where is a good place to host it?

As big as required to reproduce your problem -and- as small as possible.

Hosting is possible at http://mediafire.com for example.

ViciousXUSMC
17th November 2008, 16:12
For now I have this for you it could potentially help a lot.

A screen shot of the properties tab in Avidemux after opening the original .Vob files

http://xs233.xs.to/xs233/08471/originalvob261.jpg (http://xs.to)

Notice the Audio time of 02:02:55 and the Video time of 02:03:07 so its like a good 12 seconds difference. While the frame rate is indeed 23.976

Now here is a the properties tab in Avidemux of the file after I processed it with AutoGK and the sync of this file is PERFECT

http://xs233.xs.to/xs233/08471/afterautogk329.jpg (http://xs.to)

The Audio time is still 02:02:55 so to me that means this is not an audio issue on the audio side, but a video issue causing the audio problems. The .AVI file AutoGK made has the Video time also 02:02:55 so they match and thus are in sync!

However, its still 23.976 frames per second, the same setting I used in Avidemux so I have no clue what the hell is causing it. You can also see the original .vob shows many more frames in than the .AVI that AutoGK produced and that would be the reason for the longer duration despite the same frame rate. 90% or so of my movies work and the other 10% do not so its not a problem with Avidemux's frame change it has to be some part of the process Avidemux is missing or cant do. It has got to be adding frames, or not taking some out.

I also just spent about 20 minutes testing again to confirm. I made a small clip of the movie and played it in MPC and next to it had the good file from AutoGK and I kept adjusting the scenes audio offset until they matched. It was about 1/3 into the movie and the audio matched the video with an offset of +2200ms. I then plugged that in and went forward in the movie. By half way through the sync was way off by over 2 seconds easy, but I was able to go back and play the scene I adjusted the offset at and it was perfect. Thus confirming 100% that this is not an issue that just a offset will fix, I have to some how fix the video duration and frames.

Thanks for sticking with me through this I have a feeling the solution is close at hand, and I really appreciate the help.

LoRd_MuldeR
17th November 2008, 16:21
My assumption is that the Video track is a few seconds longer than the audio track, which is no problem.

Furthermore I think that AutoGK simply truncated the Video stream to make the duration match the Audio steam's length.
The AutoGK processed files obviously contains less frames, which agrees with that theory.

Since the Video framerate and the Audio samplerate are unchanged, AutoGK didn't "stretch" anything...

ViciousXUSMC
17th November 2008, 16:39
http://avidemux.org/admForum/viewtopic.php?id=5196&p=1

I think this explains it, Avidemux is adding frames looks like some new beta fixes are out I just updated to the new version and I am testing now.

AutoGK did not cut the video its same from start & end points. If it just cropped the video a offset would have fixed the audio.

LoRd_MuldeR
17th November 2008, 16:49
http://avidemux.org/admForum/viewtopic.php?id=5196&p=1

I think this explains it, Avidemux is adding frames looks like some new beta fixes are out I just updated to the new version and I am testing now.

No, this thread talks about H.264 video from TS container. But your source is a Video-DVD, which contains MPEG-2 video in VOB/PS container.

And AutoGK obviously did truncate the video stream. Just compare the framecount: 177121 vs. 176844 ;)

Also I highly recommend you get the latest SVN build (currently r4494) from here:
http://avidemux.razorbyte.com.au/#avidemux2.4

ViciousXUSMC
17th November 2008, 16:57
Yeah have the new build, but did not fix the problem.

So back to square one again.

LoRd_MuldeR
17th November 2008, 17:14
Yeah have the new build, but did not fix the problem.

So back to square one again.

If you could provide a sample (unprocessed segment of your source), we didn't have to guess all the time :)

And if nothing else helps you may want to file a bug report (http://bugs.avidemux.org/) and/or use another tool for the time being...

fbgd
17th November 2008, 20:26
Could this not be caused by the movie having a small amount of hard telecine in a few places in the film?

LoRd_MuldeR
17th November 2008, 23:44
Could this not be caused by the movie having a small amount of hard telecine in a few places in the film?

That is possible indeed. And there's no easy way to handle it...

ViciousXUSMC
18th November 2008, 10:42
Have a way for me to check for this condition?

LoRd_MuldeR
18th November 2008, 18:57
DGIndex

ViciousXUSMC
18th November 2008, 21:35
Well I have DGindex but what do I need to do with it?

LoRd_MuldeR
18th November 2008, 21:47
Goto "File -> Play" and look at the "Information" dialog box. Especially look at the "Frame Rate", "Video Type", "Frame Type" and "Frame Struct" fields.

If your file contains "mixed" content, you will see that these values are not constant for the entire video, but will change over time...

ViciousXUSMC
19th November 2008, 06:00
Ok thanks, I will have a look when I get home today.

ViciousXUSMC
20th November 2008, 14:13
progressive flashes pretty often near the mid part of the movie like its changing but @ 240fps its happening so fast I cant see it I can tell its not constant though because it flashes. Same for frame struct "Frame" is strobing lightly as if it is changing to another value very quickly and then back again.

Frame rate is 23.976 and has not flashed at all, and video type is film, started at like 93% and now its up to 98%

LoRd_MuldeR
20th November 2008, 16:06
I don't think Avidemux is able to handle such "mixed" content. Which may explain your audio sync problems.
You'd have to cut out all "film" parts, encode them separately and merge everything at the end. Doesn't sound like a feasible method to me.

But I'd still be interested in a sample...

poisondeathray
20th November 2008, 19:23
If the mixed content theory is true, how would autogk handle that? It seemed to process it fine according to the post on page 1? I don't use autogk, so I am just wondering what algorithm or process it uses to process the different segments automatically?

fbgd
22nd November 2008, 19:26
I would imagine for a case were the file comes out to be around 98% like ViciousXUSMC's autogk would use DGIndex's force film option when creating the d2v file.

ViciousXUSMC
19th January 2009, 00:26
I never did find a fix for this, but I wanted to come back and say thanks for all the hard work in trying to help me with it.

I just got the new beta version of AviDemux today and it fixed a problem I had with some files being the wrong color from Vegas. I found a way to use my FRAPS files in AviDemux so I can encode them to x264/aac because AviDemux did not (and maybe does not still) support the strange proprietary codec that FRAPS uses I just spliced together my clips in Sony Vegas and then sent it out as an uncompressed .AVI file and it works this way. Just sucks having a huge like 60GB file and having to encode it twice.

I found a work around just yesterday that seems to work great. A program called Debugmode FrameServer. It has a Vegas plugin and it will serve the file as needed. I did a test run with AutoGK and the file I got with the frame server and the one I got from converter the huge uncompressed file were exactly the same. So I have high hopes that it works just as well with AviDemux.

My Vegas broke on me, It wont let me go straight out with XVID anymore, it gives me an error that I forget currently, so thats what lead me to find that other stuff so a problem became a good thing as now I can use x264 again. I still do not know whats up with Vegas's built in HD codec I think its similar to the one Nero uses but everything comes out very dark and contrasty with it so I do not use it.

LoRd_MuldeR
19th January 2009, 03:37
I just got the new beta version of AviDemux today and it fixed a problem I had with some files being the wrong color from Vegas. I found a way to use my FRAPS files in AviDemux so I can encode them to x264/aac because AviDemux did not (and maybe does not still) support the strange proprietary codec that FRAPS uses I just spliced together my clips in Sony Vegas and then sent it out as an uncompressed .AVI file and it works this way. Just sucks having a huge like 60GB file and having to encode it twice.

1. You don't need to save to "uncompressed" AVI. You can use a lossless compression, such as HuffYUV or FFv1. This will be MUCH smaller than uncompressed.

2. You don't need to go through Vegas. Avidemux does support Avisynth input, so you can use AVISoource() or DirectShowSource() to load your FRAPS files.

My Vegas broke on me, It wont let me go straight out with XVID anymore, it gives me an error that I forget currently, so thats what lead me to find that other stuff so a problem became a good thing as now I can use x264 again. I still do not know whats up with Vegas's built in HD codec I think its similar to the one Nero uses but everything comes out very dark and contrasty with it so I do not use it.

Using x264 from Avidemux or from one of the various x264 front-ends definitely is one of the best H.264 encoders you can get right now :)

Nero Digital uses a very old H.264 encoder from Ateme. I read that Ateme's current encoder is pretty good, but the version used in Nero is just outdated and can't keep up with x264.

Also Xvid uses MPEG-4 ASP, so it can't keep up with any recent H.264 encoder. Unless you have a specific reason, don't use Xvid nowadays...

ViciousXUSMC
20th January 2009, 09:49
1. You don't need to save to "uncompressed" AVI. You can use a lossless compression, such as HuffYUV or FFv1. This will be MUCH smaller than uncompressed.

2. You don't need to go through Vegas. Avidemux does support Avisynth input, so you can use AVISoource() or DirectShowSource() to load your FRAPS files.



Using x264 from Avidemux or from one of the various x264 front-ends definitely is one of the best H.264 encoders you can get right now :)

Nero Digital uses a very old H.264 encoder from Ateme. I read that Ateme's current encoder is pretty good, but the version used in Nero is just outdated and can't keep up with x264.

Also Xvid uses MPEG-4 ASP, so it can't keep up with any recent H.264 encoder. Unless you have a specific reason, don't use Xvid nowadays...

Guess i was not in the clear yet.. I had the sound off so I did not notice my files were out of sync, and for some reason what is putting it out of sync is the first 3 or so seconds of my clps have ultra fast video speed then it seems to go back to normal.

I tried several things from Vegas I rendered it as Huff, FFV1, Uncompressed, and a few others and got the same result after using AviDemux to encode it to H264. I tried various codec settings to see if it would fix it , and even changed the audio codec to no avial.

I ran a test on a movie file not produced by me that I had downloaded and it went though without a hitch, so the problem is just really confusing.

1.) I did find out about the losless codecs. I happen to have access to both of them via FFD Show's codec package inside Vegas. HufYuv seems to work perfectly. FFV1 for what ever reason produced videos in slow motion where the video was slow but the sound was fine so sound out of sync and slow video.

2.) I'll have to learn more on how to do this. I used Vegas only really to edit my clips together it just happened to also work great as the middle way to let me load the files into AviDemux directly.

Also I love this new program I found called debugmode frameserver, it lets me go from Vegas into another program without any middle file (im assuming it servers the file as a lossless or uncompressed file) it worked with AutoGK but I get the green screen & sound with AviDemux so I am guessing what ever codec/protocol it uses wont work in AviDemux.

So if you happen to know what my problem is now and have a fix I am all for it.

Also I can try to upload some samples for you to look at as I know that will help, I just need a good place to do so again.

LoRd_MuldeR
21st January 2009, 02:30
I did find out about the losless codecs. I happen to have access to both of them via FFD Show's codec package inside Vegas. HufYuv seems to work perfectly. FFV1 for what ever reason produced videos in slow motion where the video was slow but the sound was fine so sound out of sync and slow video.

Probably your system is simply to slow to decode FFV1 in real-time (or the framerate was set wrongly).

Also I love this new program I found called debugmode frameserver, it lets me go from Vegas into another program without any middle file (im assuming it servers the file as a lossless or uncompressed file) it worked with AutoGK but I get the green screen & sound with AviDemux so I am guessing what ever codec/protocol it uses wont work in AviDemux.

Probably it uses either VfW or DirectShow. Avidemux does not use VfW/DirectShow.

Again Avisynth would be they way to feed that into Avidemux. But most likely you'd be able to feed the source FRAPS video into Avidemux directly with Avisyth...

ViciousXUSMC
21st January 2009, 08:04
Probably your system is simply to slow to decode FFV1 in real-time (or the framerate was set wrongly).



Probably it uses either VfW or DirectShow. Avidemux does not use VfW/DirectShow.

Again Avisynth would be they way to feed that into Avidemux. But most likely you'd be able to feed the source FRAPS video into Avidemux directly with Avisyth...

System is on 4gb of ram @ 1000mhz and a q6600 @ 3.65gz so its plenty fast. Its no i7 thought :P

I do not see how the frame rate would have been off since it was picked up correctly on its own with all other formats but that is a possibility.

As for Avisynth I just need to figure out how to use it, and the main reason I used Vegas was not so much to be the middle guy but for editing. It just so happens to have doubled very well as a middle way for me as an amateur.

I did get my files working correctly with another program/frontend while not nearly as advanced or with as many options it got the job done, I also like how it generates the code used so I can start to learn the code manually and edit it manually to add a setting that the gui may not be able to auto populate.

LoRd_MuldeR
21st January 2009, 21:24
Download & install Avisynth here:
http://sourceforge.net/project/showfiles.php?group_id=57023&package_id=72557&release_id=650255

Then load up "avsproxy_gui.exe" from Avidemux folder and goto the "Custom script" tab. Then type in the following:

AVISource("C:\Path to my FRAPS file\My Fraps file.avi", Audio=False)
ConvertToYV12()

In case that doesn't work (and only then) you can also try:

DirectShowSource("C:\Path to my FRAPS file\My Fraps file.avi", Audio=False)
ConvertToYV12()

Finally hit "Create Proxy!" button ;)

ViciousXUSMC
22nd January 2009, 07:37
Will try this later for sure thanks LoRd_MuldeR.

Im guessing if I use Audio=True then I keep my sound? I have yet to split my sound and video up for any kind of editing, as I do not know how to put them together again lol.

Based on this little tutorial: http://www.heaven.evolink.ro/rip.htm YAMB may be a good program to use for .MP4 Muxing.

ViciousXUSMC
22nd January 2009, 21:12
Download & install Avisynth here:
http://sourceforge.net/project/showfiles.php?group_id=57023&package_id=72557&release_id=650255

Then load up "avsproxy_gui.exe" from Avidemux folder and goto the "Custom script" tab. Then type in the following:

AVISource("C:\Path to my FRAPS file\My Fraps file.avi", Audio=False)
ConvertToYV12()

In case that doesn't work (and only then) you can also try:

DirectShowSource("C:\Path to my FRAPS file\My Fraps file.avi", Audio=False)
ConvertToYV12()

Finally hit "Create Proxy!" button ;)

I dont know whats up. I tried and no go, I get a error that says missing plugin, possible file type it cant read, ect ect.

I have 2.5.8 for Avisynth and I tried a few different files and even tried different super short directories (D:\Movies)

I have had absolutely no issues with any other program currently, the last couple of days I have been doing H264 encoding with HandBrake, it has opened every file type nativity on its own and encoded flawlessly with no sync or frame issues.

Its lacking the great interface your program has and all the filters. Its like my Avidemux is just broken it does not like to work with most of my files no matter what I do.

I need to install it on my laptop and see if its a system specific problem due to codec's or something crazy like that.

At some point I think I am going to start breaking it down and doing the whole thing manually for more control. I have a good handle on most of the x264 strings now, so I need to start learning avisynth, and form there find a good muxing program and I should be well on my way.

You try so hard to help out and I really appreciate it, but I just dont know where I am going wrong to make things work right with Avidemux.

LoRd_MuldeR
23rd January 2009, 15:16
I dont know whats up. I tried and no go, I get a error that says missing plugin, possible file type it cant read, ect ect.

I have 2.5.8 for Avisynth and I tried a few different files and even tried different super short directories (D:\Movies)

In "AVS Proxy GUI" goto "Show Details". Then copy the log (Rightclick -> Copy to Clipboard) and paste it here...

ViciousXUSMC
24th January 2009, 17:43
I figured it out.

Its working fine.

Here is what the problem was, the text that occupied the custom script tab. I though it was all #comments and I could just leave it there, however upon looking at it closer I found that a few lines of it were not comments but examples of script. After I deleted all of that out and used only what you said to use the video opened instantly in Avidemux.

However the test file I rendered did the same thing as when I imported a file that I let vegas render into a format it could read first. The first few seconds of the clip are in hyper speed for some reason and also now of course I have no sound due to the method I used to import the clip.

Thinking back to the problem that existed earlier in this thread when I was doing DVD rips that had audio sync issues that I could never fix. It could have been the same problem. The first few seconds of the clip being too fast. I just would have not known as all the movies start with black space or something similar that I would not have been able to see the speed change. So maybe after I figure out this one problem I will be back in business.

If I let the test files loop that first few seconds wont even play it just stays at one frame until that "hyper fast" section is over then the video starts to play like normal again.