High bit-depth Support with Avisynth

From Avisynth wiki
Jump to: navigation, search



Currently, Avisynth (not AvisynthPlus) only supports 8-bit video. Nevertheless, through various utilities, plugins, and scripts, Avisynth can be used to import, process, and export high bit-depth video. There has been some effort to update Avisynth itself to support high bit-depth, but there has been no progress as of 2012 (http://forum.doom9.org/showthread.php?t=162436).

What is Deep Color?

Deep Color refers to using more than 8 bits of data to represent each color channel. It is also referred to as high bit-depth color. Basically, deep color allows finer graduations of color, smoother gradients and more detail. Please refer to this short, easy to understand article: PCWorld: What is 10-bit Color?

Why Use Deep Color?

AviSynth+ Native Deep Color Support

Since r2290 (October 2016), AVS+ supports deep color – 10, 12, 14, 16 and 32-bit (floating point) RGB & YUV color spaces. All AVS+ color spaces are listed here. Support functions include ConvertBits, ConvertStacked, Extract and CombinePlanes. Deep color support has also been added to all internal filters and many external plugins.

This feature greatly simplifies use of deep color and could make much of the information below obsolete.

See the AviSynth+ main page for more information.

Importing High Bit-depth Video into AviSynth

For importing high bit depth video AviSynth 2.6.0 or greater is strongly recommended. AviSynth 2.6 adds the additional planar color spaces (Y8,YV16,YV24, YV411) which makes it that much more compatible with all of the existing formats.


Patched FFMS2 - import DNxHD, ProRes, and other 10-bit videos in their native format (4:2:2 and 4:4:4 are also supported), output greater than 8-bits will always be in the Stack16 format.


Updated binaries: March 15, 2015 | older versions

These versions work just like the official FFMS2, but includes the additional enable10bithack parameter and support for the additional planar colorspaces available is AviSynth 2.6. By default enable10bithack is set to false so it will work just like the official FFMS2; to import high bit depth video set enable10bithack=true, output will be in the Stack16 format. See FFmpeg versus Libav for information on pros and cons and differences between the FFmpeg and Libav.


Another source filter to import regular 8-bit and high bit depth video. LSMASHSource includes these 2 fuctions to import video:


Can be used to import VapourSynth scripts into AviSynth. Video can be 8-bit or greater.


You can also import video or still via 16-bit PNG format pictures with the following ImageMagick command lines.

Examples shown are for Windows. Requires the 16-bit version of ImageMagick; get it here (look for downloads with Q16 in the file name)

  • Convert 16-bit to Stack16 (high/low or stack16 format):
convert 16bit.png -depth 16 ( +clone -evaluate and 255 -evaluate multiply 256 ) 
        -append stacked.png
  • Convert Stack16 (high/low) to 16bit:
convert stacked.png -depth 16 -crop 100%x50% ( +clone -evaluate divide 256 ) 
        -delete 1 -compose Add -composite -define png:bit-depth=16 16bit1.png

For further explanation of these command lines, please see the thread Image Magick and stacked high bit-depth (doom9.org)


The following methods are obsolete! If you must, only use as a verification or as workaround:

  • Readv210mod - Can read uncompressed v210 in .mov container as color. Needs a manual setting skip the file header.
  • Sashimi - Sashimi 0.85 has different bit-depth support. Please see OtherFormats/Read_v210.avs included in the package.
  • ReadV210 - Can read uncompressed v210 in .mov container as greyscale.

Alternative builds and methods of importing (also obsolete):

  • ffms2mod - Can return most 10bit video in the Avisynth high bit-depth convention.
  • RawSource with ffmpeg - shows an example of using ffmpeg to convert to a 16bit format which can be read by RawSource in Avisynth 2.6.

Processing High Bit-depth Video with AviSynth

Some plugins support processing internally in a higher bit-depth for better quality and return an 8-bit video. Others support full high-bit processing and can retun a special format 16 bit video.

Most developers have adopted a vertically stacked format known as Stack16, where the high bits (MSB) are stored in the upper half of a video, and the lower bits (LSB) in the lower half of the video.
This special format must be processed only with high-bit aware scripts and plugins.

  • Multipurpose
    • Dither - A set of scripts, original and modified plugins to process 16-bit clips. Some of the functions include 16-bit color space conversion, debanding, denoising, resizing, and dithering 16-bit to lower bit depths.
    • CLExpr - OpenCl plugin for runtime calculation of expressions on 8 and 16-bit depths clips. Makes mt_lutxy and mt_lutxyz possible on 16-bit.
    • SmoothAdjust - High quality YUV color adjustment plugin. SmoothAdjust can input and output 16-bits; all calculations are internally done in 32-bit float to avoid rounding errors and artifacts.
  • Antialiasing
    • Xaa - anti-aliasing and resizing script.
  • Color Correction
  • Debanding
    • flash3kyuu_deband - Debanding filter with 8/16 bit input/output. In addition flash3kyuu_deband can be used to dither 16-bit to lower bit depths.
  • Degraining
    • SMDegrain - mvtools+mdegrain denoising with 16-bit input and output.
  • Denoising
    • DenoiseMD - 8/16-bit denoise.
    • Dfttest - 8/16-bit 2D/3D frequency domain denoiser.
    • KNLMeansCL - OpenCL based Non Local Means denoising with support for 16-bit input and output.
    • SMDegrainMod - 8/16 bit denoising with additional features like sharpening. Original Doom10 archived page.
    • TempLinearApproximate - 8/16 bit filter for temporal linear approximation between pixels . Meant mainly for denoising aid in motion compensated clips.
    • xNLMeans - Implementation of the Non Local Means denoising algorithm, as described by Buades et al. Includes support for 16-bit input and output.
  • Deringing
    • HQDeringMod - Deringing script with 16-bit input and output.
  • Effects
    • f3kgrain - Luma adaptive grain generator with 8/16-bit input and output.
    • HDRNoise - Random noise and film grain library, see discussion.
  • Frame Averaging
    • AvgAll_16 - Average all frames in a clip with 16-bit accuracy.
    • ClipBlend16 - Blend an specified amount of frames into a single frame with 16-bit accuracy.
    • RedAverage - 16-bit capable average with masking.
  • Resizing
    • Debicubic - This filter is designed to reverse the effects of bicubic upsampling. 8/16-bit input and output.
    • Debilinear - This filter is designed to reverse the effects of bilinear upsampling. 8/16-bit input and output.
    • nnedi3_resize16 - An advanced script for high quality image resizing and colorspace conversion. It supports 16-bit input and output.
    • ResampleHQ - Provides gamma-aware resizing and color space conversion. Uses 32-bit linear color internally but input and output is limited to 8-bit.
    • Resizers Functions Pack - Includes LinearResize(), a function to resize in linear space. 8/16-bit input/output. Original Doom10 archived page.
  • Deprecated
    • Deep Color Tools - This Script provides basic functions to import 10bit video, do color adjustments, and export to 8bit. (NOT RECOMMENDED, THERE ARE BETTER ALTERNATIVES)

You can also check the External Filters: DeepColor section, and the Deep Color Tools category for possibly more listings.

Codecs which support high bit-depth

  • H.264 - 10-bit YUV 4:2:0/4:2:2/4:4:4 available via x264 (lossy/lossless compression supported).
  • HEVC - 10-bit YUV 4:2:0/4:2:2/4:4:4 available via x265 (lossy/lossless compression supported).

Exporting High Bit-depth Video

You can encode out of AviSynth to 10bit x264 via

  • x264-tMod - A modification to the x264 encoder to enable various enhancements, especially for the use of high-bit depth input. Supports the AviSynth high bit-depth convention, quality enhancements, bit-depth conversion, filters such as denoising and deinterlacing.
10bit x264 command-line example:
avs2yuv -raw "script.avs" -o - | x264-10bit --demuxer raw --input-depth 10 
        --input-res 1280x720 --fps 24 --output "out.mp4" -
  • avs4x264mod - This command-line tool will directly convert from a high bit-depth convention Avisynth script to H.264 with x264, including the 10bit profile. Please check the blog for updated versions.
avs4x264mod.exe --x264-binary “C:\x264_64-abc.exe” -o out.264 in.avs

Some tutorials on exporting high bit depth image sequences:

Playback of High Bit-depth Videos

  • Most of the time you will only get to see dithered 8-bit video, as equipment to truly display high bit-depths is not as common at the consumer level in 2014 (list of 10-bit monitors).
  • The Blu-ray standard does not support high bit-depth video nor xvYCC color space (full-range 8 bit video). On September 2014 it was announced that the up-and-coming 4k Blu-ray standard will support 10-bit video and a greater color gamut by using the Rec. 2020 color space.
Playback Software
Other Software and Information

Sample High Bit-Depth Videos

See this thread for links to examples. There are also deepcolor versions of standard test clips (used in image processing research). http://forum.doom9.org/showthread.php?t=158836&highlight=v210

todo add: piping RGB48 data from avs2yuv and export 16bit image sequences in either .tif or .exr preferably using ImageMagick: http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=18943 or .jp2 image sequences http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=24718

Personal tools
in other languages