Convert
AviSynth+
Up-to-date documentation: https://avisynthplus.readthedocs.io
Convert between any of the color formats that AviSynth supports:
Color format Image format Bit depth Sample ratio Description RGB24 interleaved 8 4:4:4 (full chroma) RGB32 interleaved 8 4:4:4:4 (full chroma + alpha) YV24 ♦ planar 8 4:4:4 (full chroma) YV16 ♦ planar 8 4:2:2 (chroma shared between 2 pixels) YUY2 interleaved 8 4:2:2 (chroma shared between 2 pixels) YV12 planar 8 4:2:0 (chroma shared between 2x2 pixels) YV411 ♦ planar 8 4:1:1 (chroma shared between 4 pixels) Y8 ♦ (both) 8 4:0:0 (no chroma) (♦ = not supported in AviSynth version 2.58 or below)
AVS+ supports all of the above, plus:
Color format Image format Bit depth Sample ratio Description RGB48 interleaved 16 4:4:4 (full chroma) RGB64 interleaved 16 4:4:4:4 (full chroma + alpha) RGBPxx planar 8-16, 32 * 4:4:4 (full chroma) RGBAPxx planar 8-16, 32 * 4:4:4:4 (full chroma + alpha) YUV444Pxx planar 8-16, 32 * 4:4:4 (full chroma) YUVA444Pxx planar 8-16, 32 * 4:4:4:4 (full chroma + alpha) YUV422Pxx planar 8-16, 32 * 4:2:2 (chroma shared between 2 pixels) YUVA422Pxx planar 8-16, 32 * 4:2:2:4 (chroma shared between 2 pixels + alpha) YUV420Pxx planar 8-16, 32 * 4:2:0 (chroma shared between 2x2 pixels) YUVA420Pxx planar 8-16, 32 * 4:2:0:4 (chroma shared between 2x2 pixels + alpha) Y10..Y32 (both) 10-16, 32 * 4:0:0 (no chroma) * 8-16 = 8,10,12,14,16 bit integer; 32 = 32 bit float
When the target format is the same as the source format, the original clip will be returned unchanged, except for the case of ConvertToYV12 or ConvertToYV16 (and high bit depth variants) where the ChromaInPlacement and ChromaOutPlacement parameters are different, or the target placement is different from the source chroma placement read from _ChromaLocation frame property.
There is no unique way of converting YUV to RGB or vice-versa. There are different conversion matrices in use; the two most common ones are available in AviSynth, namely Rec.601 and Rec.709, plus some others. The following should be correct in most cases (see here for more)
- Rec.601 should be used when your source is standard definition (usually defined as smaller than 720p):
ConvertToRGB(clip)
(using default "Rec601")
- Rec.709 should be used when your source is DVD or HDTV:
ConvertToRGB(clip, matrix="Rec709")
- The special-purpose matrices PC.601 and PC.709 keep the range unchanged,
- The special-purpose matrix AVERAGE is used for (rarely found) sources with unweighted luma,
- where Y = (R + G + B) / 3.
Note ConvertToRGB always converts to RGB32 – unless your source is RGB24, in which case no conversion is done. If you need 24-bit RGB for some reason, use ConvertToRGB24 explicitly.
Use ConvertBackToYUY2 to convert back to YUY2 with minimal color-blurring when you have previously applied a YUY2→RGB conversion.
AVS+ See also ConvertBits to convert between bit depths and/or between full-limited range.
Contents |
Syntax and Parameters
RGB interleaved
ConvertToRGB(clip [, string matrix, bool interlaced,
string ChromaInPlacement,
string chromaresample,
float param1, float param2, float param3 AVS+ ] )
ConvertToRGB24(clip [, string matrix, bool interlaced,
string ChromaInPlacement,
string chromaresample,
float param1, float param2, float param3 AVS+ ] )
ConvertToRGB32(clip [, string matrix, bool interlaced,
string ChromaInPlacement,
string chromaresample,
float param1, float param2, float param3 AVS+ ] )
ConvertToRGB48(clip, [ string matrix, bool interlaced,
string ChromaInPlacement,
string chromaresample,
float param1, float param2, float param3 ] ) AVS+
ConvertToRGB64(clip, [ string matrix, bool interlaced,
string ChromaInPlacement,
string chromaresample,
float param1, float param2, float param3 ] ) AVS+
RGB planar
ConvertToPlanarRGB(clip, [ string matrix, bool interlaced,
string ChromaInPlacement,
string chromaresample,
float param1, float param2, float param3 ] ) AVS+
ConvertToPlanarRGBA(clip, [ string matrix, bool interlaced,
string ChromaInPlacement,
string chromaresample,
float param1, float param2, float param3 ] ) AVS+
YUV444
ConvertToYV24(clip [, bool interlaced, string matrix,
string ChromaInPlacement,
string chromaresample,
float param1, float param2, float param3 AVS+ ] )
ConvertToYUV444(clip, [ string matrix, bool interlaced,
string ChromaInPlacement,
string chromaresample,
float param1, float param2, float param3 ] ) AVS+
ConvertToYUVA444(clip, [ string matrix, bool interlaced,
string ChromaInPlacement,
string chromaresample,
float param1, float param2, float param3 ] ) AVS+
YUV422
ConvertToYV16(clip [, bool interlaced, string matrix,
string ChromaInPlacement,
string chromaresample,
string ChromaOutPlacement, AVS+
float param1, float param2, float param3 AVS+ ] )
ConvertToYUY2(clip [, bool interlaced, string matrix,
string ChromaInPlacement,
string chromaresample,
float param1, float param2, float param3 AVS+ ] )
ConvertToYUV422(clip, [ string matrix, bool interlaced,
string ChromaInPlacement,
string chromaresample,
string ChromaOutPlacement,
float param1, float param2, float param3 ] ) AVS+
ConvertToYUVA422(clip, [ string matrix, bool interlaced,
string ChromaInPlacement,
string chromaresample,
string ChromaOutPlacement,
float param1, float param2, float param3 ] ) AVS+
ConvertBackToYUY2(clip [, string matrix ] )
YUV420
ConvertToYV12(clip [, bool interlaced, string matrix,
string ChromaInPlacement,
string chromaresample,
string ChromaOutPlacement,
float param1, float param2, float param3 AVS+ ] )
ConvertToYUV420(clip, [ string matrix, bool interlaced,
string ChromaInPlacement,
string chromaresample,
string ChromaOutPlacement,
float param1, float param2, float param3 ] ) AVS+
ConvertToYUVA420(clip, [ string matrix, bool interlaced,
string ChromaInPlacement,
string chromaresample,
string ChromaOutPlacement,
float param1, float param2, float param3 ] ) AVS+
YUV411
ConvertToYV411(clip [, bool interlaced, string matrix,
string ChromaInPlacement,
string chromaresample,
float param1, float param2, float param3 AVS+] )
|ConvertToYUV411(clip [, bool interlaced, string matrix,
string ChromaInPlacement,
string chromaresample,
float param1, float param2, float param3 ] ) AVS+
}}
Y-only
ConvertToY8(clip [, string matrix] )
ConvertToY(clip, [ string matrix ] ) AVS+