View Single Post
Old 7th March 2007, 10:34   #3  |  Link
TheBashar
Registered User
 
TheBashar's Avatar
 
Join Date: Jan 2002
Posts: 112
Some More Clues and Confusion

Quote:
Originally Posted by foxyshadis View Post
a is exactly 5000 ms long, and the last frame is 4966. But in the timecodes, note that the first frame b starts at 5333 ms, not 5000.
Thanks for looking into the problem foxyshadis. Where did you get the 4966 number from? I don't know how you were able to dig that out.

I've done some investigating of my own, and continue to be perplexed by what I find. I re-mkvmerged the individual a.mkv and b.mkv with artificial timecode files. I constructed these so each successive frame's duration is 100ms more than the previous.

[Note: I added a DeDup override to keep the first frame so you'll see an extra frame from my previous post's tests - now 5 frames per clip]

inca.tmc: (pseudo syntax to save space here)
Code:
0.000000, 100, 300, 600, 1000
incb.tmc: (pseduo syntax to save space here)
Code:
0.000000, 500, 1100, 1800, 2600
I then mkvmerge these two timecoded videos together (ababab) and extract the merged video's timecode file:

mergeinc.tmc: (pseduo syntax etc etc)
Code:
0.000000, 100.000000, 300.000000, 600.000000, 1000.000000,
1100.000000, 1600.000000, 2200.000000, 2900.000000, 3700.000000, 
4200.000000, 4300.000000, 4500.000000, 4800.000000, 5200.000000,
5300.000000, 5800.000000, 6400.000000, 7100.000000, 7900.000000,
8400.000000, 8500.000000, 8700.000000, 9000.000000, 9400.000000,
9500.000000, 10000.000000, 10600.000000, 11300.000000, 12100.000000
Notice here, at each merge point the duration of the previous clips last frame is set to the duration of said clips first frame. This would be an understandable rule IF it held true!

Here's the kicker, I got the "real" a.tmc file and I manually changed the duration of the first frame so if I add that duration to the last frame it would be exactly 5000ms - what the clip length is. So here's my timecode file:

a.tmc:
Code:
0.000000, 933.333333, 1400.000000, 2733.333333, 4066.666667
933.333333 + 4066.666667 = 5000 right?

b.tmc:
Code:
0.000000, 66.666667, 1400.000000, 2733.333333, 
4066.666667
Now, after mkmerging these into the individual video files, mkvmerging the two videos together, and extracting the merged video's timecode file I, unfathomably find:

merged.tmc:
Code:
0.000000, 933.000000, 1400.000000, 2733.000000, 4067.000000,
5400.000000, 5467.000000, 6800.000000, 8133.000000, 9467.000000,
10801.000000, 11734.000000, 12201.000000, 13534.000000,  14868.000000,
16201.000000, 16268.000000, 17601.000000, 18934.000000, 20268.000000,
21601.000000, 22534.000000, 23001.000000, 24334.000000, 25668.000000,
27002.000000, 27069.000000, 28402.000000, 29735.000000, 31069.000000
Now mysteriously the merge points all have durations of 1333ms - which is a totally different pattern than the previous test. Is it now looking at the duration of the 2nd to last frame?

IF I could figure out how it was determining the inter-merge duration, I could write a utility to patch the timecode file(s) to make it fit the actual video length. But, even if I could figure that out, my trouble doesn't end there.

I made an artificial timecode file which I knew would match the actual merged ababab and used mkvmerge to replace the timecodes on the merged video:

replace.tmc:
Code:
0.000000, 1000.000000, 2000.000000, 3000.000000, 4000.000000
5000.000000, 6000.000000, 7000.000000, 8000.000000, 9000.000000
10000.000000, 11000.000000, 12000.000000, 13000.000000
14000.000000, etc, etc, etc
Now, when I view this new video, the audio slowly falls behind the video at each successive merge point! Now I now the timecodes for the video match the exact clip lengths. What is causing the audio to be elongated or delayed?

Current Conclusions:
  1. Audio sync problems are caused (in part) by mkvmerge assigning final frame durations based on some algorithm other than looking at audio length.
  2. Audio sync problems are also caused by a yet unknown secondary source related to the merge points.

Though you still need some of the files from the link in the first post, you can get the updated scripts and files to reproduce these tests at:
http://www.gigasize.com/get.php/4839...dated_Files.7z
Attached Files
File Type: 7z Sync Test Updated Files.7z (84.5 KB, 48 views)

Last edited by TheBashar; 7th March 2007 at 19:26. Reason: Added Updated Files To Reproduce
TheBashar is offline   Reply With Quote