As I wrote in a previous entry, people have used avi for things which it was never designed. One of the more notable examples is multi-channel audio bitstreams. In addition, the people who make such files went as far as to do in the completely wrong manner. So, as a result, I looked for a way to rescue data from the avi format so it is actually usable.
Basically, use mkvmerge from mkvtoolnix to convert the avi file to an mkv file. Then, open the file with Perian, and save it as a .mov file. The result is a file which both has the proper framing for AC3 data, and also has the proper frame decode and display information. This means that one can do real AC3 passthrough on avi files. Maybe this will be the ultimate solution.
Now, if only the designers of MKV had any sense when they designed the timecode system. For those that don’t know what I mean, ask yourself this: Which system can give greater precision:
- value * timescale / 1E9
- value / timescale
The answer is the second. If you don’t believe me, try to figure out how to do the value of 1/48000 in the first system (both value and timescale are integers). It isn’t possible, yet the MKV designers decided to go with this system for defining time. The latter was designed by Apple over a decade prior, and is still the superior system.
What does this mean for MKV? It means the default timescale used for 48KHz AC3 audio isn’t exact. If one forces it to 1E6, then it works, but this timescale doesn’t work as well for video. Once could use a finer timescale, such as 100, but the real problem still remains. BTW, with AC3 data, no timescale in MKV works 44.1KHz audio. Yet another case where mov is better, because it has a timescale for the movie as a whole, and then separate timescales for each track, in addition to having a more useful timescale system. It’s a shame the MKV people didn’t realize a superior format already existed when they decided to make their own system. At the least, they could have learned from it and not make new mistakes.
Chris Dixon - May 29, 2008
I can’t tell you have much I have learned since I began reading your blog regularly. Thanks for another informative post. Is it possible to revise mkv to use the proper timescale?
Graham Booker - May 29, 2008
Chris, Glad to see someone’s enjoying it. Yes, it is possible to revise mkv, but that would require changing the spec; so it isn’t likely to happen. If the designers wish to fix this, then they just simply change the equations in the spec and then all the authors have to change the equations in their code, and then that’d do it.
NeuralSpark - Jun 17, 2008
Echoing the educational sentiment, your work is REALLY interesting.
Erik - Aug 12, 2008
hi, Graham, Can you please explain why is Avi bad for AC3 passthrough? 95% of my video files are divx avi, lots of them have ac3 tracks… I managed to do the passthrough using your method… should i still try to convert them to apple friendlier mov? Thanks Erik
Graham Booker - Aug 12, 2008
Erik, The previous post (linked above) states what’s wrong with AVI.