<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multimedia.cx/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=LoveBug356</id>
	<title>MultimediaWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multimedia.cx/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=LoveBug356"/>
	<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php/Special:Contributions/LoveBug356"/>
	<updated>2026-05-14T07:08:50Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.5</generator>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Microsoft_Audio/Video_Interleaved&amp;diff=10206</id>
		<title>Microsoft Audio/Video Interleaved</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Microsoft_Audio/Video_Interleaved&amp;diff=10206"/>
		<updated>2008-05-23T13:49:58Z</updated>

		<summary type="html">&lt;p&gt;LoveBug356: update microsoft link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extensions: avi&lt;br /&gt;
* Company: [[Microsoft]]&lt;br /&gt;
* Technical Description From Microsoft: http://msdn.microsoft.com/en-us/library/ms779636(VS.85).aspx&lt;br /&gt;
* Another AVI format ducumentation: http://www.alexander-noe.com/video/documentation/avi.pdf&lt;br /&gt;
* John McGowan's AVI Overview: http://www.jmcgowan.com/avi.html&lt;br /&gt;
* MIME Types:&lt;br /&gt;
** video/msvideo&lt;br /&gt;
** video/x-msvideo&lt;br /&gt;
&lt;br /&gt;
'''Microsoft Audio/Video Interleaved''' ('''AVI''') is a multimedia format based on the [[RIFF]] container format. For a long time, AVI was the de facto standard for multimedia files on Windows (recently, [[ASF]] has supplanted AVI on the Windows platform). While there is some contention&lt;br /&gt;
regarding the originator of the format, the fact remains that there were, and still are, a wide variety of computer applications that create AVI files. This leads to a lot of fragmentation and application-specific nuances in a standard that was never particularly well-defined in the first place.&lt;br /&gt;
&lt;br /&gt;
== Structure ==&lt;br /&gt;
&lt;br /&gt;
An AVI has this [[RIFF]] structure:&lt;br /&gt;
&lt;br /&gt;
 RIFF &amp;quot;AVI &amp;quot; (space at end)&lt;br /&gt;
     LIST &amp;quot;hdrl&amp;quot;&lt;br /&gt;
     DATA &amp;quot;avih&amp;quot;, len: 56&lt;br /&gt;
         LIST &amp;quot;strl&amp;quot;&lt;br /&gt;
             DATA &amp;quot;strh&amp;quot;, len: 56&lt;br /&gt;
             DATA &amp;quot;strf&amp;quot;&lt;br /&gt;
         ''LIST &amp;quot;strl&amp;quot;''&lt;br /&gt;
             ...&lt;br /&gt;
     ''LIST: name: `INFO''' (optional)&lt;br /&gt;
         ...&lt;br /&gt;
     LIST &amp;quot;movi&amp;quot;&lt;br /&gt;
         DATA &amp;quot;00dc&amp;quot;&lt;br /&gt;
         DATA &amp;quot;01wb&amp;quot;&lt;br /&gt;
         ...&lt;br /&gt;
     DATA &amp;quot;idx1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Idiosyncracies ==&lt;br /&gt;
''This section comes from the document 'AVI Files: Tips &amp;amp; Quirks' by Arpad &amp;quot;A'rpi&amp;quot; Gereoffy found at http://multimedia.cx/avistuff.txt''&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
A'rpi is the originator of the [[MPlayer]] media application for Linux. It's an open source movie player that can decode AVI files, as well as a number of other file formats. He has encountered a lot of AVIs created by a lot of different programs and is qualified to write about some of the quirks and nuances a programmer might encounter when writing a general purpose AVI file decoder.&lt;br /&gt;
&lt;br /&gt;
=== Random Tips For Processing AVI File ===&lt;br /&gt;
In short, these are some things I discovered while writing/fixing my AVI demuxer:&lt;br /&gt;
&lt;br /&gt;
* AVI files are built from variable length chunks.&lt;br /&gt;
* Each chunk has a 4-byte fourcc and a 4-byte length (dword).&lt;br /&gt;
* If the chunk size is bad/broken, it will kill the whole demuxer process.&lt;br /&gt;
* Chunks are padded to 2*n offset.&lt;br /&gt;
&lt;br /&gt;
AVI files usually have:&lt;br /&gt;
* RIFF avi header, containing general parameters (used for file type detection)&lt;br /&gt;
* stream headers, containing common format stream descriptor, and type-specific audio/video/other header&lt;br /&gt;
* single 'movi' chunk contains the audio and video packets.&lt;br /&gt;
* index chunk contains index table (16 bytes for each chunk in 'movi')&lt;br /&gt;
&lt;br /&gt;
The AVI header has a dwFlags field. It contains useful information, like type of interleaving, &amp;quot;have index&amp;quot; chunk and so on. Ignore it. Really. It's broken in too many files. Windows players ignore it too.&lt;br /&gt;
&lt;br /&gt;
AVI docs say that 'XXdb' are uncompressed and 'XXdc' are compressed video chunk fourccs. (XX = stream id in HEX. Some specs says it's in DEC. Funny.) Ignore it. Just use the first 2 chars as a hex number, and get stream type from stream header for that stream id. I've seen even XXim FourCCs...&lt;br /&gt;
&lt;br /&gt;
Stream header has some interesting fields:&lt;br /&gt;
* dwRate, dwScale: These specify the playback samplerate of the stream.&lt;br /&gt;
* dwStart: Specifies delay of the stream; rarely used, but must be supported.&lt;br /&gt;
* dwSampleSize: This is the sample size (bytes / sample). It may be 0, which means variable sample sizes -&amp;gt; 1 chunk == 1 sample. For non-zero samplesize, chunks may contain more than one sample.&lt;br /&gt;
&lt;br /&gt;
Regarding VBR audio in AVI, see VirtualDub site mentioned in the references. The 3 AVI parsers in Windows behave differently with such streams. 1 normal (0=vbr), 1 tricky (rounds up zero to blockalign), 1 crashes.&lt;br /&gt;
&lt;br /&gt;
In AVI, audio specific header contains WAVEFORMATEX and video spec. hdr contains BITMAPINFOHEADER. Both can have optional codec-dependent extra data appended after the struct. Don't crop it, it will break decoding!&lt;br /&gt;
&lt;br /&gt;
About the movi chunk:&lt;br /&gt;
Recently I got some AVI files with bad movi chunk sizes. So, I have to say: Ignore it. Read chunks from the file while not EOF, and not while filepos &amp;lt; movi_end.&lt;br /&gt;
&lt;br /&gt;
About index:&lt;br /&gt;
* It contains chunk pos, chunk size, chunk fourcc and flags. Bit 4 of the flags field (flags &amp;amp; 0x10) means that chunk represents a keyframe.&lt;br /&gt;
* Offset is relative to `cat /dev/urandom`. Really. Or dunno.&lt;br /&gt;
* I calculate an offset_of_offset value from the movi_start and first chunk offset. It works in 99% of cases. I saw different methods in other players, handling some common cases (such as relative to avi chunk, relative to movie chunk, etc.) and fallback to absolute value.&lt;br /&gt;
* Chunk info in chunk header (first 4+4 bytes of chunks) and index table should be equal. They aren't. Sometimes the size values differ by +/-1. Strange. Sometimes fourccs 'type' part (last 2 char) differ. Even more strange. Sometimes they leave chunk header. I think Windows parsers don't use chunk headers at all, and use only the index. This may be why they are unable to play files without index.&lt;br /&gt;
&lt;br /&gt;
On the subject of interleaving, there are 3 categories of interleaving for AVI files (taken from DOCS/tech/formats.txt in the [[MPlayer]] distribution):&lt;br /&gt;
# Interleaved: Audio and video content is interleaved. It's faster and requires only 1 reading thread, so it's recommended (and most commonly used).&lt;br /&gt;
# Non-interleaved: Audio and video aren't interleaved. The file stores all of the video data followed by all the audio data. Such a file requires 2 reading processes or 1 reading with lots of seeking. This is very bad when playing the data from a network or CD-ROM.&lt;br /&gt;
# Badly-interleaved streams: Some AVI files claim to be interleaved but with bad sync. These files should be treated as non-interleaved.&lt;br /&gt;
&lt;br /&gt;
About A/V sync, you should rely on samplerate (dwRate/dwScale), samplesize and stream positions. Use an integer, not a floating-point number, for byte positions. When calculating time for each frame:&lt;br /&gt;
  time = ((dwSampleSize ? (bytepos / dwSampleSize) : chunkpos) * dwRate / dwScale&lt;br /&gt;
floats will gradually drift into error.&lt;br /&gt;
&lt;br /&gt;
== Quirks ==&lt;br /&gt;
* Some AVI files are seen in the wild with the signature 'AVI\x19'. There is a 0x19 number in the fourth byte rather than a 0x20.&lt;br /&gt;
&lt;br /&gt;
[[Category:Container Formats]]&lt;/div&gt;</summary>
		<author><name>LoveBug356</name></author>
	</entry>
</feed>