TheBashar
6th March 2007, 22:12
I'm having trouble with the audio getting out of sync in merged vfr mkv files. I put together a simple test case to illustrate this. Can someone more informed than I please clear up what I missing?
All the files to reproduce my test case can be downloaded from:
http://www.gigasize.com/get.php/481342/VFRSyncTest.7z
Basically it goes something like this:
Have AVS file which generates blank video and constant tone
Call to DeDup's DupeMC records the duplicate frame statistics
Another AVS (almost same) adds Info() and uses DeDup to remove what would have been duplicate frames.
DeDup outputs timecode file
Another set of AVS files are almost identical but with different color and tone.
I use MeGUI to encode the video to MKV
I use MeGUI to encode the audio with Nero AAC
I use MKVMergeGUI to merge each video MKV, audio MP4, and corresponding timecode file
I use MKVMergeGUI to repeatedly merge the two clips together in an A-B-A-B-A-B pattern
Problem: When you watch the ABABAB.mkv, you see that the audio tone switches in time with the color changes. But as the video progresses (actually as the merge points are passed) the color changes lag farther and farther behind the audio.
Observations that I don't understand:
If I do the alternating in one video clip, the video dooesn't get out of sync; only with the merges.
When I watch the A (or B) clip, in MPC I see only 2 distinct frames, though there should be 4.
When I watch the merged ABABAB clip, I see 4 distinct frames per color, except the last one which shows only 2 distinct frames.
I could use the audio delay parameter in MKVMergeGUI to fix this if I could figure out some pattern to how much the audio is getting advanced (or chopped I think). While the pattern seems predictable with this simple test, I've had trouble with real video sometime getting a little out of sync and sometimes a lot.
In case you don't want to download the 84kB archive, here are the AVS files so you can see how simple this test should be:
a1.avs:
vid = BlankClip(length=75, width=320, height=240, pixel_type="YV12", fps=15.0, audio_rate=22050, stereo=false, color=color_firebrick)
aud = Tone(length=6, frequency=440, samplerate=22050, channels=1, type="sine")
CLIP = AudioDubEx(vid, aud)
Trim(CLIP, 0, -CLIP.framecount, true)
DupMC(log="a.dup")
a2.avs:
vid = BlankClip(length=75, width=320, height=240, pixel_type="YV12", fps=15.0, audio_rate=22050, stereo=false, color=color_firebrick)
aud = Tone(length=6, frequency=440, samplerate=22050, channels=1, type="sine")
CLIP = AudioDubEx(vid, aud)
Trim(CLIP, 0, -CLIP.framecount, true)
Info()
DeDup(log="a.dup", times="a.tmc", maxcopies=20, maxdrops=20, decwhich=0)
b1.avs:
vid = BlankClip(length=75, width=320, height=240, pixel_type="YV12", fps=15.0, audio_rate=22050, stereo=false, color=color_turquoise)
aud = Tone(length=6, frequency=660, samplerate=22050, channels=1, type="sine")
CLIP = AudioDubEx(vid, aud)
Trim(CLIP, 0, -CLIP.framecount, true)
DupMC(log="b.dup")
b2.avs:
vid = BlankClip(length=75, width=320, height=240, pixel_type="YV12", fps=15.0, audio_rate=22050, stereo=false, color=color_turquoise)
aud = Tone(length=6, frequency=660, samplerate=22050, channels=1, type="sine")
CLIP = AudioDubEx(vid, aud)
Trim(CLIP, 0, -CLIP.framecount, true)
Info()
DeDup(log="b.dup", times="b.tmc", maxcopies=20, maxdrops=20, decwhich=0)
And this is one of the timecode files (the other is identical):
# timecode format v2
0.000000
1333.333333
2666.666667
4000.000000
Finally a note about the archive. It contains all the files to recreate the test videos as well as the videos themselves. I just want to note that it contains a "ababab.tmc" file which is a timecode file _extracted_ from the ababab.mkv file, NOT used to create the video file.
All the files to reproduce my test case can be downloaded from:
http://www.gigasize.com/get.php/481342/VFRSyncTest.7z
Basically it goes something like this:
Have AVS file which generates blank video and constant tone
Call to DeDup's DupeMC records the duplicate frame statistics
Another AVS (almost same) adds Info() and uses DeDup to remove what would have been duplicate frames.
DeDup outputs timecode file
Another set of AVS files are almost identical but with different color and tone.
I use MeGUI to encode the video to MKV
I use MeGUI to encode the audio with Nero AAC
I use MKVMergeGUI to merge each video MKV, audio MP4, and corresponding timecode file
I use MKVMergeGUI to repeatedly merge the two clips together in an A-B-A-B-A-B pattern
Problem: When you watch the ABABAB.mkv, you see that the audio tone switches in time with the color changes. But as the video progresses (actually as the merge points are passed) the color changes lag farther and farther behind the audio.
Observations that I don't understand:
If I do the alternating in one video clip, the video dooesn't get out of sync; only with the merges.
When I watch the A (or B) clip, in MPC I see only 2 distinct frames, though there should be 4.
When I watch the merged ABABAB clip, I see 4 distinct frames per color, except the last one which shows only 2 distinct frames.
I could use the audio delay parameter in MKVMergeGUI to fix this if I could figure out some pattern to how much the audio is getting advanced (or chopped I think). While the pattern seems predictable with this simple test, I've had trouble with real video sometime getting a little out of sync and sometimes a lot.
In case you don't want to download the 84kB archive, here are the AVS files so you can see how simple this test should be:
a1.avs:
vid = BlankClip(length=75, width=320, height=240, pixel_type="YV12", fps=15.0, audio_rate=22050, stereo=false, color=color_firebrick)
aud = Tone(length=6, frequency=440, samplerate=22050, channels=1, type="sine")
CLIP = AudioDubEx(vid, aud)
Trim(CLIP, 0, -CLIP.framecount, true)
DupMC(log="a.dup")
a2.avs:
vid = BlankClip(length=75, width=320, height=240, pixel_type="YV12", fps=15.0, audio_rate=22050, stereo=false, color=color_firebrick)
aud = Tone(length=6, frequency=440, samplerate=22050, channels=1, type="sine")
CLIP = AudioDubEx(vid, aud)
Trim(CLIP, 0, -CLIP.framecount, true)
Info()
DeDup(log="a.dup", times="a.tmc", maxcopies=20, maxdrops=20, decwhich=0)
b1.avs:
vid = BlankClip(length=75, width=320, height=240, pixel_type="YV12", fps=15.0, audio_rate=22050, stereo=false, color=color_turquoise)
aud = Tone(length=6, frequency=660, samplerate=22050, channels=1, type="sine")
CLIP = AudioDubEx(vid, aud)
Trim(CLIP, 0, -CLIP.framecount, true)
DupMC(log="b.dup")
b2.avs:
vid = BlankClip(length=75, width=320, height=240, pixel_type="YV12", fps=15.0, audio_rate=22050, stereo=false, color=color_turquoise)
aud = Tone(length=6, frequency=660, samplerate=22050, channels=1, type="sine")
CLIP = AudioDubEx(vid, aud)
Trim(CLIP, 0, -CLIP.framecount, true)
Info()
DeDup(log="b.dup", times="b.tmc", maxcopies=20, maxdrops=20, decwhich=0)
And this is one of the timecode files (the other is identical):
# timecode format v2
0.000000
1333.333333
2666.666667
4000.000000
Finally a note about the archive. It contains all the files to recreate the test videos as well as the videos themselves. I just want to note that it contains a "ababab.tmc" file which is a timecode file _extracted_ from the ababab.mkv file, NOT used to create the video file.