PDA

View Full Version : audio sync problem with MKV/TIVTC/x264


xxxyzzzz
10th May 2008, 05:17
Hi,

I am not sure if this is the right place to post; it could be here, in the x264 forum, or in the alternative container forum. I start here.

This is what I am doing:

I am creating mkv/x264/(ogg/ac3) files from some of my favorite cartoon episode DVDs, as well as some movies.

I use the following guide:

http://avisynth.org/mediawiki/VFR

to create variable frame rate matroska. I use tritical's ingenious filter, TIVTC, to create the timecodes necessary to mux the raw x264 video with the audio using mkvmerge-gui from mkvtoolnix 2.2.0.

This is my problem:

The audio is frequently out of sync with the video for different episodes (about -20ms to 120ms), and it doesn't seem to matter what audio codec used.

I understand that it could be very slightly out of sync in different places, especially with cartoons/anime; but, this is with the entire video.

I have been adjusting it for now; but, I would like to know why.

Is this a common problem with VFR video? or is it a TIVTC/MKV/X264 problem? Or maybe it is a problem with the decoder?

Thanks,
Z


Here are my 2-pass avisynth scripts:
Pass 1:
LoadPlugin("DGDecode.dll")
LoadPlugin("TIVTC.dll")
LoadPlugin("RemoveGrainSSE2.dll")

movie = mpeg2source("movie.d2v")
out_width = 720
out_height = 480
tfm(movie,mode=0,pp=7,mi=40,output="tfm.txt").tdecimate(mode=4,output="stats.txt")
RemoveGrain(mode=2)

Pass 2:
LoadPlugin("DGDecode.dll")
LoadPlugin("TIVTC.dll")
LoadPlugin("RemoveGrainSSE2.dll")

movie = mpeg2source("movie.d2v")
out_width = 720
out_height = 480
tfm(movie,mode=0,pp=7).tdecimate(mode=5,hybrid=2,dupThresh=1.0,input="stats.txt",tfmin="tfm.txt",mkvout="timecodes.txt")
RemoveGrain(mode=2)


Here are my x264 options:
Pass 1:
wine x264.exe --pass 1 --bitrate 1000 --stats .stats --ref 1 --progress --keyint 250 --bframes 3 --qpmin 10 --qpmax 51 --no-psnr --filter -2,-1 --subme 2 --direct auto --vbv-bufsize 14000 --vbv-maxrate 25000 --me dia --no-ssim --level 4.1 --b-pyramid --partitions none --threads auto --thread-input --sar 1:1 --output NUL movie_pass_1.avs

Pass 2:
wine x264.exe --pass 2 --bitrate 1000 --stats .stats --progress --keyint 250 --bframes 3 --qpmin 10 --qpmax 51 --no-psnr --mixed-refs --trellis 1 --ref 12 --filter -2,-1 --direct auto --vbv-bufsize 14000 --vbv-maxrate 25000 --me umh --no-ssim --level 4.1 --weightb --b-pyramid --b-rdo --bime --partitions p8x8,b8x8,i4x4,i8x8,p4x4 --8x8dct --threads auto --thread-input --sar 1:1 --output movie.264 movie_pass_1.avs


Normal mkvmerge command used:
mkvmerge -o movie.mkv --priority lower --aspect-ratio 0:4/3 --default-duration 0:30000/1001fps --timecodes 0:timecodes.txt -d 0 -A -S movie.264 --sync 0:0 -a 0 -D -S audio.ac3 --track-order 0:0,1:0

P.S. I apologize for the massive amount of information - but I would like to be thorough.

Dark Shikari
10th May 2008, 05:37
Here are my x264 options:
Pass 1:
wine x264.exe --pass 1 --bitrate 1000 --stats .stats --ref 1 --progress --keyint 250 --bframes 3 --qpmin 10 --qpmax 51 --no-psnr --filter -2,-1 --subme 2 --direct auto --vbv-bufsize 14000 --vbv-maxrate 25000 --me dia --no-ssim --level 4.1 --b-pyramid --partitions none --threads auto --thread-input --sar 1:1 --output NUL movie_pass_1.avs

Pass 2:
wine x264.exe --pass 2 --bitrate 1000 --stats .stats --progress --keyint 250 --bframes 3 --qpmin 10 --qpmax 51 --no-psnr --mixed-refs --trellis 1 --ref 12 --filter -2,-1 --direct auto --vbv-bufsize 14000 --vbv-maxrate 25000 --me umh --no-ssim --level 4.1 --weightb --b-pyramid --b-rdo --bime --partitions p8x8,b8x8,i4x4,i8x8,p4x4 --8x8dct --threads auto --thread-input --sar 1:1 --output movie.264 movie_pass_1.avs
General, unrelated comment on your x264 options:

1. Keyint 250 is default. No need to specify.
2. --bframes 16 is probably best (especially for cartoons, which can benefit from more than 3 more often than not).
3. --partitions p8x8,b8x8,i4x4,i8x8,p4x4 is a really long way to write "--partitions all".
4. Unless I'm blind, you don't have --subme 6 or higher on your second pass (you completely forgot it) so --b-rdo does nothing.
5. --threads auto implies --thread-input.
6. --sar 1:1 is default.
7. Low deblocking settings are particularly not recommended for cartoon footage; I suggest you try normal deblocking settings (0:0) or higher; MeGUI's cartoon profile, for example, uses 1:1.
8. QPmax and min are 10/51 by default anyways.

xxxyzzzz
11th May 2008, 19:41
@Dark Shikari - Thank you; I am an amateur with x264, and I haven't updated my command line options in many months. (And you were not blind :) )

Concerning my post, I also forgot to ask if it could be the mkv splitter or the decoder I am using (MPlayer-1.0rc2 which, I believe, uses ffmpeg 0.4.9 svn20080426)

Also, if this has nothing to do with TIVTC or my avisynth script, then this thread can be moved - but, I have no idea.

Thanks,
Z

xxxyzzzz
17th May 2008, 07:36
May this thread be moved to the alternative container forum? I might have better luck there.

Thanks,
Z

Comatose
17th May 2008, 07:53
Can you upload the timecodes file? It's likely that the problem is with TIVTC getting it wrong or something. At the very least, everything else is less likely to be the cause :x

xxxyzzzz
17th May 2008, 18:29
Alright,

I am attaching the timecodes file for the very first episode of "Avatar: The Last Airbender" in which the audio needs to be delayed about 100ms to match the DVD.

However, I am not sure what you could gather from just the file....

Thanks,
Z