अंतिम अपडेट: 30 Jun, 2026

Title - Decoding AVI: Inside Microsoft’s Legacy Container Architecture

TL;DR – AVI (Audio Video Interleave) माइक्रोसॉफ्ट का पहला “डिजिटल वीडियो” कंटेनर है, जो Windows 95 के साथ आया था। यह एक सरल RIFF‑आधारित फ़ाइल है जो संकुचित वीडियो और ऑडियो चंक्स को इंटरलीव करती है ताकि प्लेयर उन्हें क्रमबद्ध पढ़ सके। यह फ़ॉर्मेट अभी भी Windows Media Player और कई ओपन‑सोर्स टूल्स द्वारा समझा जाता है, लेकिन इसमें HDR, 10‑बिट रंग, और मजबूत स्ट्रीमिंग मेटाडेटा जैसी आधुनिक सुविधाएँ नहीं हैं। यदि आपको कभी लेगेसी फुटेज में गहराई से जाना पड़े, तो चंक लेआउट, FourCC कोड, और OpenDML एक्सटेंशन जो 2 GB की सीमा को हटाते हैं, को समझना आवश्यक है – यही AVI का मुख्य भाग है।


1. AVI फ़ाइल वास्तव में क्या है?

  • पूरा नाम: Audio Video Interleave
  • पहला प्रकट होना: Windows 95 (1995) – उपभोक्ता पीसी पर “डिजिटल वीडियो” के लिए माइक्रोसॉफ्ट का उत्तर।
  • विशिष्टता: 1991 के RIFF (Resource Interchange File Format) स्पेसिफिकेशन पर निर्मित। RIFF एक सामान्य “चंक‑आधारित” कंटेनर है; AVI केवल उन चंक्स का सेट परिभाषित करता है जो ऑडियो, वीडियो, और इंडेक्सिंग डेटा रखता है।
  • फ़ाइल एक्सटेंशन / MIME: .avivideo/x-msvideo.
  • मुख्य लक्ष्य: ऑडियो और वीडियो स्ट्रीम को डिस्क पर कसकर इंटरलीव्ड रखें ताकि एक साधारण प्लेबैक लूप वीडियो फ्रेम पढ़ सके, फिर मिलते-जुलते ऑडियो सैंपल को, बिना महंगे सीक के।
  • पुरानी स्थिति: विंडोज़ मीडिया प्लेयर, डायरेक्टशो, VLC, और अनगिनत अन्य प्लेयर्स में अभी भी चलाया जा सकता है, लेकिन यह एक “आधुनिक” कंटेनर नहीं है। कोई मूल HDR, 10‑बिट, वैरिएबल‑बिट‑रेट, या समृद्ध मेटाडेटा समर्थन नहीं है।

2. बॉक्स के भीतर – AVI कैसे काम करता है

RIFF चंक कंकाल

एक AVI फ़ाइल केवल chunks की श्रृंखला है:

RIFF <size> "AVI "          ; file header
  LIST "hdrl"               ; header list
    avih ...                ; main AVI header (global info)
    LIST "strl"             ; stream list (one per stream)
      strh ...              ; stream header (type, codec, timing)
      strf ...              ; stream format (codec‑specific data)
  LIST "movi"               ; interleaved media data
    00dc <size> <video frame>
    01wb <size> <audio block>
    …
  idx1 ...                  ; optional index for fast seeking
  • Chunk ID (4 बाइट्स) – उदाहरण के लिए, avih, strh, movi.
  • Chunk size (4 बाइट्स) – उस डेटा की लंबाई जो उसके बाद आती है (ID और आकार फ़ील्ड को छोड़कर)।
  • डेटा – वास्तविक पेलोड (हेडर, कच्चे फ्रेम, आदि)।

क्योंकि RIFF विस्तारणीय है, आप नए chunk प्रकार जोड़ सकते हैं बिना पुराने पार्सरों को तोड़े – एक डिज़ाइन जिसने दशकों तक AVI को जीवित रखा।

FourCC – कोडेक का फुसफुसाने वाला

चार‑अक्षर कोड (FourCC) वह गोंद हैं जो प्लेयर को बताता है कि कौन सा डिकोडर लोड करना है। कुछ सामान्य कोड जिन्हें आप AVI फ़ाइलों में देखेंगे:

FourCCकोडेक (ffmpeg)सामान्य उपयोग
DIVXmpeg4 (DivX)प्रारंभिक MPEG‑4 भाग 2
XVIDmpeg4 (Xvid)ओपन‑सोर्स MPEG‑4
MJPGmjpegMotion‑JPEG (डिजिटल कैमकोर्डर)
H264h264H.264/AVC (दुर्लभ लेकिन संभव)
MP3mp3MP3 ऑडियो स्ट्रीम
PCMpcm_s16leअसंपीड़ित PCM ऑडियो

FourCC strh चंक (कोडेक पहचानकर्ता) में रहता है और कभी‑कभी strf ब्लॉक (पिक्सेल फ़ॉर्मेट, ऑडियो सैंपल फ़ॉर्मेट) में भी।

समय निर्धारण एवं समकालिकरण

AVI एक सरल time‑base प्रणाली का उपयोग करता है:

  • ग्लोबल हेडर (avih): dwRate / dwScale → फ्रेम्स प्रति सेकंड।
  • पर‑स्ट्रीम हेडर (strh): ऑडियो या द्वितीयक वीडियो स्ट्रीम्स के लिए इसका अपना dwRate / dwScale

प्लेयर फ्रेम नंबर को scale/rate से गुणा करके प्रस्तुति टाइमस्टैम्प (PTS) गणना करता है। यदि स्केल मेल नहीं खाते, तो आप क्लासिक “ऑडियो सिंक्रोनाइज़ेशन से बाहर drift करता है” बग देखेंगे जो लेगेसी टूल्स को परेशान करता रहता है।

movi चंक – जहाँ मीडिया रहता है

सभी संकुचित फ्रेम्स movi LIST में स्थित होते हैं। प्रत्येक फ्रेम से पहले एक चंक ID आती है जो बताती है कि वह वीडियो (00dc) है या ऑडियो (01wb)। यह ID स्ट्रीम नंबर भी एन्कोड करती है, इसलिए दो ऑडियो ट्रैक्स वाली फ़ाइल में 01wb और 02wb होंगे।

क्योंकि डेटा पहले से ही इंटरलीव्ड है, प्लेयर एक वीडियो फ्रेम पढ़ सकता है, फिर अगला ऑडियो ब्लॉक, और उन्हें साथ में प्रस्तुत कर सकता है बिना बहुत आगे सीक करने के। यह निर्धारक लिखने का पैटर्न AVI को शुरुआती कैप्चर डिवाइसों में लोकप्रिय बनाता था जिन्हें कम‑लेटेंसी डिस्क राइट्स की आवश्यकता थी।

इंडेक्सिंग (idx1) – तेज़ फ़ॉरवर्ड, तेज़ रीवाइंड

वैकल्पिक idx1 चंक movi में प्रत्येक फ्रेम के ऑफसेट और आकार की तालिका है। जब मौजूद हो, तो सीकिंग एक सरल तालिका लुकअप बन जाता है। यदि यह अनुपलब्ध है, तो प्लेयर को फ़ाइल को रीयल‑टाइम में स्कैन करना पड़ता है – जिससे बड़े फ़ाइलों पर एक स्पष्ट “बफ़रिंग” विराम हो सकता है।

OpenDML (AVI 2.0) – 2 GB बाधा को तोड़ना

मूल RIFF स्पेसिफिकेशन एक चंक के आकार फ़ील्ड को 32‑बिट अनसाइन्ड इंटीजर तक सीमित करता है → 2 GB अधिकतम फ़ाइल आकार। OpenDML (जिसे कभी‑कभी AVI 2.0 कहा जाता है) ने पेश किया:

  • AVIX LISTs – अतिरिक्त “विस्तारित” RIFF सेक्शन जो पहले 2 GB के बाद आ सकते हैं।
  • indx चंक – 64‑बिट सक्षम इंडेक्स।
  • लंबी अवधि के लिए अतिरिक्त हेडर फ़ील्ड।

अधिकांश आधुनिक टूल (ffmpeg, VLC) आउटपुट 2 GB से अधिक होने पर स्वचालित रूप से OpenDML पर स्विच कर देते हैं, लेकिन कई पुराने प्लेयर्स अभी भी AVIX चंक्स पर अटकते हैं, इसलिए आप कभी‑कभी संगतता हैक्स देख सकते हैं जो लंबी कैप्चर को कई 2 GB AVI फ़ाइलों में विभाजित करते हैं।


3. AVI 2024 में कहाँ रहता है?

रुझानAVI के लिए इसका क्या मतलब है
MP4/MKV/ProRes की ओर बदलावनई उत्पादनें उन कंटेनरों को प्राथमिकता देती हैं जो मूल रूप से HDR, 10‑बिट, VBR, और समृद्ध मेटाडेटा का समर्थन करते हैं। AVI को नई सामग्री के लिए शायद ही चुना जाता है।
पुरानी हार्डवेयरपुराने CCTV कैमरे, शुरुआती‑2000 के कैमकोर्डर, और कुछ गेम इंजन अभी भी AVI आउटपुट करते हैं। आपको अभी भी उन फ़ाइलों को आधुनिक कार्यप्रवाह में इन्गेस्ट करने की आवश्यकता होगी।
ओपन‑सोर्स समर्थनffmpeg, libav, VLC, HandBrake, और GStreamer AVI पार्सरों को जीवित रखते हैं, लेकिन वे अक्सर वितरण के लिए MP4/MKV में री‑एन्कोड करते हैं।
OpenDML पुनरुत्थान4K निगरानी रिकॉर्डिंग जो कई दिनों तक चलती हैं, जल्दी ही 2 GB से अधिक हो जाती हैं। OpenDML (AVIX) अभी भी प्रमुख समाधान है, हालांकि कई उपकरण इसे सही ढंग से संभाल नहीं पाते।
सुरक्षा सुदृढ़ीकरणऐतिहासिक AVI पार्सर खराब चंक आकारों को स्वीकार करते थे, जिससे CVE (जैसे, CVE‑2020‑13144) उत्पन्न होते थे। अब Windows मीडिया फ़ाउंडेशन को प्राथमिकता देता है, जो कई पुरानी अजीबियों को अस्वीकार करता है, और डेवलपर्स को अधिक सुरक्षित पाइपलाइन की ओर धकेलता है।
कंटेनर‑अज्ञेय पाइपलाइनआधुनिक मीडिया फ्रेमवर्क AVI को केवल एक और स्रोत तत्व के रूप में देखते हैं। एक बार डेटा को कच्चे बफ़र्स में डिमक्स कर दिया जाता है, तो कंटेनर डाउनस्ट्रीम प्रोसेसिंग के लिए अप्रासंगिक हो जाता है।

संक्षेप में, AVI जीवित है लेकिन उम्रदराज़ – यह उन स्थितियों में टिकता है जहाँ पुराना हार्डवेयर या सरल इंटरलीव्ड स्टोरेज आवश्यक होता है, लेकिन यह नए प्रोजेक्ट्स के लिए प्रथम विकल्प नहीं है।


4. हैंड्स‑ऑन: आज AVI के साथ काम करना

A. न्यूनतम हेडर (hex) पर नज़र

52 49 46 46  00 00 00 00  41 56 49 20   ; "RIFF" + size + "AVI "
4C 49 53 54  20 00 00 00  68 64 72 6C   ; LIST "hdrl"
...

RIFF मैजिक (52 49 46 46) किसी भी पार्सर को बताता है “यह एक RIFF फ़ाइल है”। अगले चार बाइट्स कुल फ़ाइल आकार (8 घटाकर) होते हैं। "AVI " पहचानकर्ता फ़ाइल को AVI परिवार में लॉक कर देता है।

B. आधुनिक MP4 → लेगेसी AVI रूपांतरण

ffmpeg -i input.mp4 \
       -c:v mpeg4 -q

```bash
ffmpeg -i input.mp4 \\ \n -c:v mpeg4 -qscale:v 5 \\   \n   # MPEG‑4 पार्ट 2 (DivX/Xvid संगत) -c:a mp3 -b:a 192k \\      \n   # MP3 ऑडियो (अधिकांश AVI प्लेयर्स इसे समझते हैं) -f avi output.avi

The command above forces MPEG‑4 Part 2 video (the codec most legacy AVI players recognize) and MP3 audio, then writes an AVI container. If you need OpenDML support for files larger than 2 GB, add the -movflags +faststart‑style flag that tells FFmpeg to use the extended AVIX chunks:

ffmpeg -i input.mp4 \\ -c:v mpeg4 -qscale:v 5 \\ -c:a mp3 -b:a 192k \\ -f avi -flags +global_header -movflags +faststart output.avi

Tip: Some older Windows Media Player versions still choke on the AVIX extension. If you must stay under 2 GB, split the source into multiple AVIs using the -segment_time and -f segment muxer.


5. Common Pitfalls & How to Fix Them

SymptomLikely CauseFix
Audio drifts out of sync after a few minutesMismatched dwRate/dwScale between avih and strh (or a VBR audio stream)Re‑encode audio to a constant‑bitrate format (e.g., MP3 128 kbps) or use -vsync 2 in FFmpeg to force frame‑accurate timestamps.
“Cannot play this video” on Windows Media PlayerMissing or corrupt idx1 index, or OpenDML (AVIX) chunks not recognizedRun ffmpeg -i broken.avi -c copy -map 0 -f avi repaired.avi to rebuild the index; or use aviindex (part of mplayer) to generate a fresh idx1.
File size capped at 2 GB despite long footageEncoder used classic AVI (no OpenDML)Add -use\_open\_dml 1 (FFmpeg) or -format avi2 (VirtualDub) to enable OpenDML extensions.
Green or corrupted framesIncompatible FourCC (e.g., H.264 in an AVI without proper headers)Stick to codecs known to work in AVI (mpeg4, msmpeg4v2, MJPG, XVID). If you must store H.264, use the h264 FourCC and ensure the strf chunk contains the SPS/PPS extradata.
Playback stalls on network streamsAVI’s lack of robust streaming metadata (no moov atom)Wrap the AVI in a streaming protocol (e.g., RTSP) that handles byte‑range requests, or convert to MP4/MKV for smoother streaming.

6. Debugging Tools You Should Keep Handy

ToolPlatformWhat It Does
ffprobe / ffmpegCross‑platformDumps every chunk, FourCC, timestamps, and can rebuild indexes (-c copy).
MediaInfoWindows/macOS/LinuxHuman‑readable summary of streams, codecs, and container flags.
VirtualDubWindowsClassic AVI editor; can rebuild headers, add OpenDML, and preview frame‑by‑frame.
GSpot (legacy)WindowsIdentifies obscure FourCCs and suggests appropriate codecs.
aviindex (part of MPlayer)Linux/macOSGenerates a fresh idx1 chunk for broken files.
Hex editors (HxD, Bless)AnyDirectly inspect RIFF headers when you suspect malformed chunk sizes.

A typical workflow when an AVI refuses to play:

  1. Inspect with ffprobe -show_format -show_streams file.avi.
  2. Check the index: ffmpeg -i file.avi -c copy -f avi -y temp.avi (FFmpeg will rebuild it automatically).
  3. Validate FourCCs: mediainfo file.avi. If you see an unknown codec, consider re‑encoding that stream.
  4. Repair with VirtualDub → “File → Re‑open as AVI (OpenDML)”. Save a fresh copy.

7. When (and When Not) to Use AVI

Good Use‑Cases

ScenarioWhy AVI Works
Legacy camcorder ingestThe device outputs native AVI; transcoding adds unnecessary quality loss.
Simple interleaved captureLow‑latency write to disk without needing complex container features.
Compatibility with old Windows‑only softwareSome industrial automation tools only understand AVI.
Archiving raw, uncompressed videoAVI can hold PCM audio and uncompressed RGB24 video without extra overhead.

Bad Use‑Cases

ScenarioWhy AVI Fails
HDR or 10‑bit colorNo standard way to store those pixel formats; you’d need a custom FourCC that most players ignore.
Variable‑bit‑rate streamingLack of a proper moov‑like atom makes adaptive bitrate impossible.
Rich metadata (chapters, subtitles, tags)AVI’s chunk model doesn’t define standard containers for subtitles or extensive tags.
Cross‑platform mobile distributionModern mobile players expect MP4/MKV; AVI may not be hardware‑accelerated.

If you’re starting a new project, treat AVI as a fallback for legacy pipelines, not a primary delivery format.


8. Future Outlook – Will AVI Ever Make a Comeback?

The short answer: unlikely. The industry has coalesced around ISO‑BMFF‑based containers (MP4, MOV, HEVC‑MP4, etc.) because they support:

  • Extensible metadata (ISO‑UserData, UUID boxes).
  • Fragmented streaming (moof/mdat) for adaptive bitrate.
  • Native HDR/10‑bit/12‑bit video definitions.

AVI’s design, while elegant for its time, is fundamentally limited by its 32‑bit size fields and its reliance on external FourCC‑driven codecs. Even though OpenDML extended the size limit, it never gained widespread adoption beyond niche surveillance and archival tools.

That said, software preservation will keep AVI parsers alive for decades. Projects like FFmpeg, GStreamer, and VLC will continue to support the format, ensuring that the massive archive of 1990s‑2000s footage remains accessible. In a world where “digital archaeology” is becoming a real discipline, knowing how to read and repair AVI files is still a valuable skill.


9. Quick Reference Cheat‑Sheet

ItemCommand / SettingExplanation
Create classic AVIffmpeg -i src -c:v mpeg4 -qscale:v 5 -c:a mp3 -b:a 192k -f avi out.aviSimple, widely compatible.
Enable OpenDMLffmpeg -i src -c:v mpeg4 -qscale:v 5 -c:a mp3 -b:a 192k -f avi -use_open_dml 1 out.aviAllows >2 GB files.
Re‑index broken AVIffmpeg -i broken.avi -c copy -f avi repaired.aviRewrites idx1.
Split >2 GB into chunksffmpeg -i long.avi -c copy -map 0 -segment_time 1800 -f segment part_%03d.avi30‑minute segments stay under the limit.
Inspect headerffprobe -show_format -show_streams file.aviDumps all RIFF chunks and stream info.
Add a subtitle track (non‑standard)ffmpeg -i video.avi -i subs.srt -c copy -metadata:s:s:0 language=eng out.aviWorks only with players that read the txt stream; not universally supported.

Keep this table bookmarked; it covers 80 % of everyday AVI tasks.


10. Best Practices for Archiving AVI Files

Even though AVI is a legacy container, many institutions still have petabytes of it sitting on tape or in cold‑storage. Treating those assets with a disciplined workflow will save you headaches down the line.

PracticeWhy It MattersHow to Implement
Validate on ingestCorrupt headers or missing indexes can go unnoticed until playback.Run ffprobe -v error -show_format -show_streams file.avi immediately after copying. Log any non‑zero exit codes.
Generate a checksumGuarantees bit‑exact preservation across media migrations.Use SHA‑256 (sha256sum file.avi > file.avi.sha256). Store the checksum alongside the file in your catalog.
Create a modern proxyMost downstream workflows (editing, streaming) expect MP4/MKV.Encode a low‑bitrate MP4 proxy (ffmpeg -i file.avi -c:v libx264 -crf 23 -c:a aac -b:a 128k proxy.mp4). Keep the proxy in the same directory with a clear naming convention (*_proxy.mp4).
Document FourCCs and codec versionsSome FourCCs map to multiple codec implementations (e.g., DIVX could be DivX 5, 6, or 7).Extract the codec private data (ffprobe -show_private_data) and store it in a side‑car JSON file (file.avi.codec.json).
Migrate to OpenDML for large filesFiles >2 GB will become unreadable on older players.When transcoding, always pass -use_open_dml 1. If you’re only copying, use aviindex to rebuild an OpenDML‑compatible index.
Store metadata in a side‑carAVI has no standard for extensive tags (e.g., creator, location).Use XMP side‑car files (file.avi.xmp) or embed a small INFO LIST chunk manually if you need minimal in‑container metadata.
Regularly test playbackBit‑rot can affect codecs as well as containers.Schedule a quarterly job that runs a headless player (e.g., ffplay -autoexit -frames 10 file.avi) and reports any failures.

By applying these steps at the moment of acquisition, you avoid costly “repair‑the‑archive” projects later.


11. Frequently Asked Questions (FAQ)

Q1: Can I store H.265/HEVC video inside an AVI file?
Short answer: Technically yes, if you supply the correct FourCC (HEVC or HVC1) and include the SPS/PPS NAL units in the strf chunk. In practice, very few players support it, and many will treat the stream as unknown. For reliable playback, stick to MPEG‑4 Part 2 or Motion‑JPEG.

Q2: Why does Windows Media Player sometimes show a black screen but still plays audio?
Explanation: The player has successfully opened the audio stream but failed to locate a usable video decoder for the FourCC. This can happen when the FourCC is custom or when the required codec isn’t installed. Installing a codec pack (e.g., K-Lite) or re‑encoding the video to a known FourCC resolves the issue.

Q3: Is there any way to embed subtitles directly into an AVI file?
Answer: AVI does not define a standard subtitle stream. Some tools cheat by adding a “txt” stream (FourCC txt ) that contains plain‑text subtitles, but only a handful of players (e.g., VirtualDub with a plugin) will render them. The recommended approach is to keep subtitles in a separate .srt or .ass file, or to re‑mux into a container that officially supports subtitles (MP4, MKV).

Q4: My video shows a “frame rate mismatch” warning in MediaInfo. What should I do?
Solution: Verify that the dwRate/dwScale values in both the global avih and per‑stream strh headers are consistent. If they differ, re‑mux with FFmpeg using -video_track_timescale to force a uniform time base:

ffmpeg -i broken.avi -c copy -video_track_timescale 1000 fixed.avi

Q5: Does AVI support multiple audio languages?
Yes, but with caveats. You can add several audio streams, each with its own strh/strf pair and a distinct stream number (01wb, 02wb, …). However, there is no standardized way to label the language; you must rely on external metadata (e.g., an accompanying .xml file) or embed a custom INFO chunk.

Q6: How can I extract raw frames from an AVI without re‑encoding?
Command:

ffmpeg -i source.avi -c:v copy -f image2 frame_%05d.bmp

Replace bmp with png or tiff if you prefer lossless image formats. The -c:v copy flag tells FFmpeg to dump the compressed frames as‑is; if the codec is MJPEG, the output will already be JPEG images.

Q7: Are there any security concerns when opening AVI files from untrusted sources?
Yes. Malformed chunk sizes can trigger buffer overflows in legacy parsers (e.g., older DirectShow filters). Always open unknown AVIs in a sandboxed environment or use a modern library like FFmpeg that performs strict bounds checking. Updating Windows Media Foundation and disabling legacy DirectShow filters further mitigates risk.


12. TL;DR सारांश (अधीर लोगों के लिए)

  • AVI = RIFF‑based, interleaved container introduced with Windows 95.
  • FourCC tells the player which codec to use; common ones are DIVX, XVID, MJPG, H264, MP3 .
  • Timing is driven by dwRate/dwScale in the global and stream headers.
  • movi holds the actual media; idx1 (optional) speeds up seeking.
  • OpenDML (AVIX) lifts the 2 GB limit but isn’t universally supported.
  • Use cases today: legacy camcorder ingest, simple interleaved capture, archival of raw PCM video.
  • Avoid for new projects: no HDR, 10‑bit, VBR, subtitles, or rich metadata.
  • Toolbox: ffprobe, ffmpeg, MediaInfo, VirtualDub, aviindex, hex editors.
  • Best practice: validate, checksum, generate modern proxies, and migrate large files to OpenDML.

13. समापन विचार

AVI’s simplicity is both its strength and its Achilles’ heel. It gave early PC users a straightforward way to store synchronized audio‑video pairs, and that design philosophy—interleaved chunks, a clear header layout, and extensible FourCC identifiers—still influences modern containers. While the industry has moved on to more feature‑rich formats, the sheer volume of legacy footage means AVI will remain a “must‑know” for anyone working in video preservation, forensic analysis, or any field that must bridge the past with today’s workflows.

If you ever find yourself staring at a dusty .avi on a hard drive from the late‑90s, you now have the conceptual map, the command‑line recipes, and the troubleshooting checklist to bring that footage back to life—whether you choose to keep it in its original container or transcode it into a modern, HDR‑ready format.

Happy demuxing!