High bit-depth Support with Avisynth

From Avisynth wiki
Revision as of 03:34, 10 November 2015 by Jmac698 (Talk | contribs)

Jump to: navigation, search

Contents

Introduction

Currently, Avisynth 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?

Deepcolor 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, deepcolor/high bit-depth allows finer graduations of color, allowing smoother gradients and more detail. Please refer to this short, easy to understand article: PCWorld: What is 10-bit Color?

Why Use Deep Color?


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.

FFMS2

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.

Download

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.

LSMASHSource

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


VapourSource

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

Image Magick

You can also import video or still via 16-bit PNG format pictures with the following Image Magick command lines (examples shown for Windows, requires the 16-bit version of Image Magick found at http://www.imagemagick.org/script/bi...es.php#windows, the file ImageMagick-x.y.z-a-Q16-x64)

Convert 16-bit to stacked (high/low or stack16 format):

convert 16bit.png -depth 16 ( +clone -evaluate and 255 -evaluate multiply 256 ) -append stacked.png

convert stacked (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 http://forum.doom9.org/showthread.php?t=172846

Obsolete

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. More information here.
    • 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.
  • 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
  • Deringing
    • HQDeringMod - Deringing script with 16-bit input and output.
  • Effects
    • f3kgrain - Luma adaptive grain generator with 8/16-bit input and output.
  • 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.
  • 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.
    Example:
    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