§ ¶120 fps video???
If you're a frequent watcher of Internet-sourced video files you may have noticed an interesting characteristic of the video stream of some AVI files, namely an unusually high frame rate of 120 fps. Such a frame rate might seem useless and utterly wasteful, given that film sources run at 24 fps, video sources run at up to 30 frames/60 fields per sec, and computer refresh rates not generally higher than 85Hz.
Ah, but there is reason to this madness.
The reason for the 120 fps frame rate becomes clear if you look at the data in the stream itself, namely that at least 75% of the frames are empty. Basically, someone came up with the innovative idea of using null frames in AVI to achieve variable frame rate in order to accommodate both 24 fps and 30 fps within the same file. A 24 fps portion uses a frame density of 1/5, whereas a 30 fps portion uses 1/4. The need for mixed 24/30 comes from recording video which has both telecined and non-telecined video, and applying inverse telecine to the appropriate portions.
VirtualDub can process these videos to some extent, but there are some shortcomings. Attempting to recompress or filter the video will result in a 120 full frames per second. Also, attempting to play the video will result in a mind-numbingly slow frame rate because VirtualDub will still attempt to blit/flip at 120 fps. You can, however, direct stream the video, and you can use frame rate conversion in this mode to remove some of the null frames and drop the video stream to a more ordinary frame rate. I'm working on improving support for sparse video streams in a future version.
Tritical made some neat utilities to deal with these files.
Look for the avi_tc_package. My standard mode of operation is run cfr2tc to strip the null frames and create a timecode file, recompress/filter the video, then run tc2cfr to add back the null frames.
squid - 26 05 06 - 03:43
I think it would be better if such mixed-rate streams were in a container that supported variable frame rates, such as MKV and MP4. Granted, those containers are (slightly) harder to work with than AVI, but AVI is also a rather outdated format that requires all kinds of disgusting hacks to work around the shortcomings. (Packed bitstream or b-frame decoder lag with Xvid/DivX, using 120fps and a bunch of null frames to achieve VFR, problems with VBR audio, etc.)
Coderjoe - 26 05 06 - 13:29
Yes, but AVI persists for similar reasons as x86: support for it is ubiquitous, well understood, and well supported at this point. Many of the limitations that you point out are also why AVI is fairly friendly to editing -- I've seen too many proposed video file formats that were so complex and attempted to support so many different features that the chances for read support in a commercial program were essentially zero.
Phaeron - 26 05 06 - 23:38
Why can't the framerate be 30FPS, and still have null frames for 24FPS film sources? Wouldn't 1 null frame every 6 real frames result in 30FPS? Why the need to go all the way up to 120?
Brian Young - 27 05 06 - 18:14
The playback would repeat 1 frame in 5 to make up the pattern. The first 3 frames show for 1/30 second the 4th would show for 1/15 second. This is within the range the human eye can detect.
IanB - 27 05 06 - 19:24
Brian- you can't just add a null frame to bring 24fps video to 30 fps because the video would pause every twelfth of a second. your video would look distractingly jerky. probably very subtly, but still distracting.
longneck - 27 05 06 - 19:26
Very obviously, actually, if you're used to smooth pans. Occasionally fansub groups do it and I have to yell at them. ;) Try use vdub to convert the fps of a 23.976 panning scene to 29.97, and watch the result.
foxyshadis - 28 05 06 - 05:03
Commercial software supports the Quicktime container fine for editing, and that is essentially what the MP4 container is based on. MP4 supports the features I mentioned. Although, arguably, you shouldn't really be editing with a lossy source, anyway.
Coderjoe - 28 05 06 - 14:17
While mp4 has nearly the same editing characteristic (index is there, frames are random accessable) it has one little disadvantage over avi, you can't extend it with any kind of stream. There is no fourcc and regular header structures to map to a codec automatically, an mp4 parser needs to mess with codec specific atoms and extract bits of informations here and there to setup the decoder, only a few encodings are supported (good for hw players) but it's already becoming a mess like quicktime's mov format.
Gabest (link) - 28 05 06 - 17:10
And AVI isn't a mess? Again, look at all the hacks for things like VBR audio, B frames, and VFR. I would be quite willing to say that AVI is a huge mess.
Now, granted, I haven't yet had the chance to read ISO/IEC 14496-1, so I don't know how complex it is. But at least it was designed to handle all of these things I've mentioned cleanly.
Coderjoe - 31 05 06 - 01:17
In other words, the MPEG-4 container format handles the features you specified by ditching a major feature of AVI, which is forward compatibility. It is quite possible to edit an AVI file using a program written years prior to the video codec used to encode the video in the file, due to the genericity of the format; with what Gabest is saying, the same could not be said for MP4.
You can complain all you want about AVI, but writing a basic, generic AVI parser and output routine is still MUCH easier than ANY of the other formats you have described, even with the hacks for the additional features that you describe. And backward compatibility is a BIG deal.
Anyway, I think you've made your opinion about AVI clear enough.
Phaeron - 31 05 06 - 01:37
May I ask what prompted this entry now, when we've been dealing with these encodes on a regular basis for several years now? It's rather unthinkable that you would only now be looking at the concept for the first time.
StarCreator (link) - 02 06 06 - 04:08
Although, IMHO, MKV and AVI are made for quite different purposes. MKV is meant to be a "final" container, to distribute a complete movie with subtitles, menus, different audio tracks etc. etc. in, while AVI's strength is the aforementioned ease of editing. In other words, use AVI for encoding and editing, and use MKV for the final product.
I don't know enough about MP4 to really comment on that, but from what I've seen it looks like a failed attempt to combine the virtues of AVI and MKV...
TheFluff - 02 06 06 - 16:12
StarCreator: Not saying this is new by any means, but not everyone who works on a video application or works with video may have seen this. Was just something that came up again recently.
Phaeron - 02 06 06 - 23:44
I dont think that 'VirtualDub can process these videos to some extent', in fact i converted some 15fps video to 25(with Vdub), and Vdub refuse to play it back.
Would be useful to permit decimation and adding null frames at same time,
Actually you need 2 steps, and you are not guaranteed that a null frame will be added exactly where one has been removed.
movmasty (link) - 22 04 07 - 21:32