Interleave?

This forum is for questions and discussion of all the aspects of handling and cleaning up your footage with Avisynth.
Locked
User avatar
Wolfy2hk
Joined: Fri Dec 22, 2006 11:36 am
Location: Tejas
Org Profile

Interleave?

Post by Wolfy2hk » Sat Jan 06, 2007 9:21 pm

So im wondering what it is exactly and whether or not it makes the vid have a better quality, because i always see interleave asking me if i should do it always or never when im compressing with
LEAD MCMP/MJPEG Codec [VFW].

User avatar
Zero1
Joined: Fri Jan 02, 2004 12:51 pm
Location: Sheffield, United Kingdom
Contact:
Org Profile

Post by Zero1 » Sun Jan 07, 2007 10:51 am

It depends on the context somewhat, because interleave can refer to a few things. The most common "use" for it though is Audio/Video Interleaving (which as you may now see, is where .avi gets it's name from (Audio Video Interleaved)).

Interleaving affects the way the data is arranged in a video file. A non interleaved video (referred to as flat storage) stores the components of a video in complete blocks. For example you may have the video data at the beginning of the file, the audio after that, and subtitles last.

A flat file might look like this.

Code: Select all

--------------------------------------------------------------
|                                                    |       |
|                     Video                          | Audio |
|                                                    |       |
--------------------------------------------------------------
Because the audio and video are seperate, it increases disk seek. This was a problem years ago on CD ROM drives because of the slow access times and throughput; flat files had the biggest chance of stuttering.

Interleaving sort of "weaves" the data, that is you get a bit of video data, then a bit of audio, video, audio and so on. This greatly reduces the disk seek because the audio and video it has to decode is closer together, however with old containers like AVI it can increase overhead. It generally isn't much (perhaps 1-5MB but it's largely dependant on the video length and filesize), but it's a point worth making. MP4 has much lower overhead.

An interleaved file would look something like this.

Code: Select all

-------------------------------------------------------------
|  V  | A |  V  | A |  V  | A |  V  | A |  V  | A |  V  | A |
|  i  | u |  i  | u |  i  | u |  i  | u |  i  | u |  i  | u |
|  d  | d |  d  | d |  d  | d |  d  | d |  d  | d |  d  | d |
-------------------------------------------------------------
Another good thing with interleaving is that with modern containers like MP4, it allows for streaming and progressive download. Flat files tend not to work very well (or at all) when streaming because where you have a sequential download (unlike bittorrent which seems to get some parts of a file randomly), you in theory need all the video data before you actually get to the audio part of the file. Think of the flat diagram and vision a progress bar, if the download was 50% done, you wouldn't have any audio yet (since the video is more than 50% of the file), and it may be unplayable, or playable without audio. Now in an interleaved file, you will have complete video up to 50% (since it's also getting chunks of audio). Whether you can play a 50% complete video is dependant on the codecs and/or container though.

It doesn't directly affect the quality, but it can essentially waste a few MB.

You should leave interleaving enabled

Locked

Return to “AviSynth Help”