YV12 FAQ
From MediaCoderWiki
What is YV12?
These are several different ways to represent colors. For example: YUV and RGB colorspace. In YUV colorspace there is one component that represent lightness (luma) and two other components that represent color (chroma). As long as the luma is conveyed with full detail, detail in the chroma components can be reduced by subsampling (filtering, or averaging) which can be done in several ways (thus there are multiple formats for storing a picture in YUV colorspace). YV12 is such a format (where chroma is shared in every 2x2 pixel block) that is supported by AviSynth. Many important codecs stored the video in YV12: MPEG-4 (x264, XviD, DivX and many others), MPEG-2 on DVDs, MPEG-1 and MJPEG.
Where can I download the latest stable AviSynth version which supports YV12?
"AviSynth v2.56" (and more recent versions) can be downloaded here.
Where can I download the DGIndex/DGDecode plugin, which supports YV12, to import MPEG-1/MPEG-2/TS/PVA in AviSynth ?
The latest DGIndex/DGDecode combo can be downloaded here.
Which encoding programs support YV12?
...
The regular builds of Virtualdub (till v1.5.4) have no internal YV12 support. There are two options for encoding to DivX/XviD:
- There is a modified version (called VirtualdubMod) which has YV12 support: This modification (by pulco-citron, Suiryc and Belgabor) has OGM and AVS-preview support. It can be downloaded from here. In order to use the YV12 support (without doing any color conversions) you have to load your AVI in VirtualdubMod and select "fast recompress".
- For easy (and fast) YV12 support, you can also try out the new commandline compressor: AVS2AVI, see also (...).
- The MPEG-1/MPEG-2 encoders HC and QuEnc also support (and even require) YV12.
How do I use v2.5x if the encoding programs can't handle YV12 (like TMPGEnc or CCE SP)?
Using Virtualdub you have to add "ConvertToYUY2" to your script or you have to install a YV12 decompressor like DivX5 or one of the recent XviD builds of Koepi (XviD-04112002-1 or newer). Enabling "fast recompress" implies that there will be a YV12 -> YUY2 -> YV12 conversion. (DivX3/4 also supports YV12, except that PIV users could experience crashes when encoding to DivX4 in YV12.)
Using TMPGEnc you have to add the line ConvertToRGB24 to your script, and for CCE SP you need to add the line ConvertToYUY2 to your script, since Windows has no internal YV12 compressor. You can also install DivX5 or one of the recent XviD builds of Koepi XviD-04112002-1 or newer which will decompress the YV12-AVI for you when loading the avi in TMPGEnc or CCE SP.
What are the main advantages and processing/encoding in YV12?
There are two advantages:
- speed increase: It depends entirely on the external plugins whether they will have YV12 support or not. If they have then speed increases like 25-35 percent are expected. Of course there will only be a large speed increase if both your source and target are in YV12, for example in DVD to DivX / XviD conversions.
- no color conversions: The color information doesn't get interpolated (so often) and thus stays more realistic. Even if you have to do color conversions (because your are encoding with CCE SP or TMPGEnc) you have the advantage that putting off the YV12->YUY2 (or RGB24 for TMPGEnc) conversion until the end of the script allows you to first IVTC or Deinterlace to create progressive frames. But the YV12 to YUY2 conversion for progressive frames maintains more chroma detail than it does for interlaced or field based frames.
How do I use VirtualDub/VirtualDubMod such that there are no unnecessary color conversions?
Just load your avs file in VirtualDub/VirtualdubMod and set the video on "Fast recompress". In this mode the process will stay in YV12 (all the necessary filtering has to be done in AviSynth itself). Under compression select a codec which support YV12, like Xvid, DivX5, RealVideo (provided you download the lastest binaries) or 3ivx D4 (provided you download the lastest binaries). Note that DivX3/4 also supports YV12, except that PIV users could experience crashes when encoding to DivX4 in YV12.
If you want to preview the video you also need a decompressor. DivX5 is capable of doing this, but DivX4 and the regular builds of Xvid are not. Instead download the binaries of Koepi (XviD-04112002-1 or newer) which can be found here.
Which internal filters support YV12?
In principal all internal filters support YV12 natively. Which color formats the filters support is specified in the documentation.
Which external plugins support YV12?
The plugins which are compiled for AviSynth v2.5 are given in External plugins. New plugins are listed in this sticky.
What will be the main advantages of processing in YV12?
- speed increase:
- That depends entirely on the external plugins whether they will have YV12 support or not. Speed increases like 25-35 percent are expected. Of course there will only be a large speed increase if both your source and target are in YV12, for example in DVD to DivX/Xvid conversions.
- no color conversions:
- The colour information doesn't get interpolated (so often) and thus stays more realistic.
MPEG-2 encoders such as CCE, Procoder and TMPGEnc can't handle YV12 input directly. CCE and Procoder needs YUY2, and TMPGEnc RGB24. This only means that the last line of AviSynth must be a ConvertToYUY2 (for CCE/Procoder, or ConvertToRGB24 for TMPGEnc) call, and that you will not be able to take full advantage of YV12 colorspace. Still there are two advantages:
1) All internal filtering in AviSynth will be faster though (less data to filter, better structure to filter, and a very fast conversion from YV12 to YUY2), and you will definitely be able to tell the difference between v2.06 and v2.5.
2) If you are making a progressive clip there is another advantage. Putting off the YV12->YUY2 conversion until the end of the script allows you to first IVTC or Deinterlace to create progressive frames. But the YV12 to YUY2 conversion for progressive frames maintains more chroma detail than it does for interlaced or field-based frames.
The color conversions:
CCE: YV12 -> YUY2 -> YV12
TMPGEnc: YV12 -> RGB24 -> YV12
How do I know which colorspace I'm using at a given place in my script?
To see which colorspace you are using at a given place in your script, add:
Info()
... and AviSynth will give you much information about colorspace amongst other things!
Colors are swapped when my I load a DivX file in AviSynth v2.5?
This happens due to a bug in DivX. Download the latest binaries (11/22 or more recent) and use "SwapUV(clip)".
I installed AviSynth v2.5 and get the following error message: "Couldn't locate decompressor for format 'YV12' (unknown)."?
Install a codec (like XviD or DivX5) which supports YV12. If that still doesn't work, modify your registry as explained in the next question.
I installed AviSynth v2.5 and DivX5 (or one of the latest Xvid builds of Koepi), all I got is a black screen when opening my avs in VirtualDub/VirtualDubMod/MPEG-2 encoder?
Ok, apperently your video is not decompressed by DivX 5.02 (or Xvid). Go to your windows-dir and rename a file called MSYUV.DLL, or add the following to your registry file:
REGEDIT4 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Drivers32] "VIDC.YV12"="divx.dll"
Replace "divx.dll" by "xvid.dll" for xvid v0.9 or "xvidvfw.dll" for xvid v1.0.
Are there any lossless YV12 codecs, which I can use for capturing for example?
There are several of them:
VBLE and LocoCodec can be found here.
- VBLE Codec (by MarcFD): A huffyuv based encoder discussion.
- LocoCodec (by TheRealMoh):
- MJPEG Codec: Leaves a small logo in the right upper side of the clip. It can be downloaded here.
Some important links:
- Technical explanation of YV12 (and similar formats)
- Good Microsoft page on YUV
- Some other Microsoft stuff
