High bit-depth Support with Avisynth

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
m (format)
(Processing High Bit-depth Video with AviSynth: cleanup: direct some filters to wiki pages)
(53 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 
== Introduction ==
 
== 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).
+
<div style="max-width:62em" >
<br>
+
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).
<br>
+
</div>
 +
 
 
== What is Deep Color? ==
 
== What is Deep Color? ==
 +
<div style="max-width:62em" >
 +
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:  [http://www.pcworld.com/article/171223/what_is_10bit_color.html PCWorld: What is 10-bit Color?]
 +
</div>
 +
  
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:  http://www.pcworld.com/article/171223/what_is_10bit_color.html
 
<br>
 
<br>
 
 
== Why Use Deep Color? ==
 
== Why Use Deep Color? ==
 +
<div style="max-width:62em" >
 +
*Higher internal precision, using high-bit depth color, when processing an image in a filter, gives a higher quality (8-bit) output.
 +
*If a video filter uses linear gamma internally, there can be noticeable differences in the image.  A linear gamma representation is best supported with a high bit-depth. See the illustration for [http://int64.org/projects/resamplehq/ ResampleHQ].
 +
*If you encode high-bit depth video, you can get better compression (reportedly up to 30%) and less banding. 
 +
*Banding is one of the most serious liabilities of 8-bit depth.  Refer to the following references for an explanation of why 10-bit encodes compress better:
 +
**[http://x264.nl/x264/10bit_02-ateme-why_does_10bit_save_bandwidth.pdf Why does 10-bit save bandwidth (even when content is 8-bit)?.pdf]
 +
**[http://x264.nl/x264/10bit_01-ateme_pierre_larbier_422_10-bit.pdf Using 10-bit AVC/H.264 Encoding with 4:2:2 for Broadcast Contribution.pdf]
 +
**[http://x264.nl/x264/10bit_03-422_10_bit_pristine_video_quality.pdf Keeping Video Quality Pristine throughout the Production Process: 4:2:2 10-bit AVC/H.264 encoding.pdf]
 +
</div>
  
-Higher internal precision, using high-bit depth color, when processing an image in a filter, gives a higher quality (8-bit) output
 
  
-If a video filter uses linear gamma internally, there can be noticeable differences in the image.  A linear gamma representation is best supported with a high bit-depth. See the illustration for ResampleHQ, http://int64.org/projects/resamplehq/
+
== AviSynth+ Native Deep Color Support ==
 +
<div style="max-width:62em" >
 +
Since [https://github.com/pinterf/AviSynthPlus/releases/tag/r2290-MT r2290] (October 2016), {{AvsPluscon}} supports deep color &ndash; 10, 12, 14, 16 and 32-bit (floating point) RGB &amp; YUV color spaces. All AVS+ color spaces are listed [[Avisynthplus_color_formats|here]]. Support functions include [[ConvertBits]], [[ConvertStacked]], [[Extract]] and [[CombinePlanes]]. Deep color support has also been added to all [[Internal_filters|internal filters]] and many [[AviSynth%2B_x64_plugins|external plugins]].
  
-If you encode high-bit depth video, you can get better compression (reportedly up to 30%) and less banding. 
+
'''''This feature greatly simplifies use of deep color and could make much of the information below obsolete.'''''
Banding is one of the most serious liabilities of 8-bit depth. Refer to the following references for an explanation of why 10-bit encodes compress better:
+
  
http://x264.nl/x264/10bit_02-ateme-why_does_10bit_save_bandwidth.pdf
+
See the [[AviSynth%2B|AviSynth+ main page]] for more information.  
 +
</div>
  
http://x264.nl/x264/10bit_01-ateme_pierre_larbier_422_10-bit.pdf
 
  
http://x264.nl/x264/10bit_03-422_10_bit_pristine_video_quality.pdf
+
== Importing High Bit-depth Video into AviSynth ==
 +
<div style="max-width:62em" >
 +
For importing high bit depth video [http://sourceforge.net/projects/avisynth2/ 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.  
  
-Professional video is stored in 10bit formats (like ProRes 422) and people want to use Avisynth for processing.
+
=== [[FFmpegSource|FFMS2]] ===
<br>
+
'''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.
<br>
+
 
== Importing High Bit-depth Video into Avisynth ==
+
*Source code: [http://github.com/SAPikachu/ffms2_hacks GitHub repository]
For importing high bit depth video [http://forum.doom9.org/showthread.php?t=168764 AviSynth 2.6.0 Alpha5] or later is strongly recommended. AviSynth 2.6 adds additional color spaces ([[Y8]],[[YV16]],[[YV24]]) that make that much more compatible with all of the existing formats.  
+
*Discussion: [http://forum.doom9.org/showthread.php?t=164841 Doom9 thread] - Importing DNxHD to Avisynth (some of the links may be outdated; see downloads below or [http://forum.doom9.org/member.php?u=135430 SAPikachu's signature] for latest versions)
<br>
+
 
<br>
+
==== Download ====
==== FFMS2 ====
+
Updated binaries: March 15, 2015 | [http://www.mediafire.com/folder/2izh9abzep52o/Video_works older versions]
:'''[http://forum.doom9.org/showthread.php?p=1580141#post1580141 Patched ffms2]''' - (See SAPikachu's signature for downloading the latest versions) [[http://github.com/SAPikachu/ffms2_hacks patched ffms2 source code repository]]
+
* [http://www.nmm-hd.org/upload/get~t6gq8DWihBs/ffms2-6e0d654+a9fe004-ffmbc-FFmbc-0.7.1.7z ffms2-6e0d654+a9fe004-ffmbc-FFmbc-0.7.1.7z] | [http://web.archive.org/web/20150321005059/https://www.nmm-hd.org/upload/get~t6gq8DWihBs/ffms2-6e0d654+a9fe004-ffmbc-FFmbc-0.7.1.7z mirror] - This version uses [http://code.google.com/p/ffmbc/ FFmbc] as a decoder; may have better support for professional video formats like ProRes, DNxHD, etc.
:Import DNxHD, ProRes, and other 10-bit videos in their native format (4:2:2 and 4:4:4 are also supported), output will always be in the [[Stack16]] format.
+
* [http://www.nmm-hd.org/upload/get~BLsLZwgj5ps/ffms2-6e0d654+a9fe004-ffmpeg-1e4d049.7z ffms2-6e0d654+a9fe004-ffmpeg-1e4d049.7z] | [http://web.archive.org/web/20150321005255/https://www.nmm-hd.org/upload/get~BLsLZwgj5ps/ffms2-6e0d654+a9fe004-ffmpeg-1e4d049.7z mirror] - This version uses [http://en.wikipedia.org/wiki/FFmpeg FFmpeg] as a decoder; may be better for general (more common) formats.
 +
* [http://www.nmm-hd.org/upload/get~Q4mZfV9y0Og/ffms2-6e0d654+a9fe004-libav-9a60b1f.7z ffms2-6e0d654+a9fe004-libav-9a60b1f.7z] | [http://web.archive.org/web/20150321005339/https://www.nmm-hd.org/upload/get~Q4mZfV9y0Og/ffms2-6e0d654+a9fe004-libav-9a60b1f.7z mirror] - This version uses [http://en.wikipedia.org/wiki/Libav Libav] as a decoder; may be better for general (more common) formats.
 +
 
 +
These versions work just like the official [[FFmpegSource|FFMS2]], but includes the additional {{FuncDef3|enable10bithack}} parameter and support for the additional [[planar]] colorspaces available is AviSynth 2.6.  
 +
By default {{FuncDef3|enable10bithack}} is set to false so it will work just like the official FFMS2; to import high bit depth video set {{FuncDef3|enable10bithack}}<code>=true</code>, output will be in the [[Stack16]] format.
 +
See [http://github.com/mpv-player/mpv/wiki/FFmpeg-versus-Libav FFmpeg versus Libav] for information on pros and cons and differences between the FFmpeg and Libav.<br/>
 +
<!--===== Archived Downloads =====
 +
* <code>[http://www.nmm-hd.org/upload/get~PbKYgPe2oKY/ffms2-9417b9c-ffmbc-FFmbc-0.7-rc8.7z ffms2-9417b9c-ffmbc-FFmbc-0.7-rc8.7z]</code>
 +
<code>[http://www.nmm-hd.org/upload/get~fmbjO7t9dEg/ffms2-9417b9c-ffmpeg-8728360.7z ffms2-9417b9c-ffmpeg-8728360.7z]</code>
 +
<code>[http://www.nmm-hd.org/upload/get~3O9tHZ9TJIM/ffms2-9417b9c-libav-aca2510.7z ffms2-9417b9c-libav-aca2510.7z]</code>
 +
-->
 +
 
 +
=== [[LSMASHSource]] ===
 +
Another source filter to import regular 8-bit and high bit depth video. LSMASHSource includes these 2 fuctions to import video:
 +
*[[LSMASHSource/LSMASHVideoSource|LSMASHVideoSource]] - This function uses [http://en.wikipedia.org/wiki/Libavcodec#Implemented_video_codecs libavcodec] as a video decoder and [http://github.com/l-smash/l-smash L-SMASH] as a demuxer. Recommended for MP4, MOV, [http://en.wikipedia.org/wiki/ISO_base_media_file_format ISO Base Media] and its derived file formats.<br/>
 +
*[[LSMASHSource/LWLibavVideoSource|LWLibavVideoSource]] - This function uses [http://en.wikipedia.org/wiki/Libavcodec#Implemented_video_codecs libavcodec] as a video decoder and [http://www.ffmpeg.org/libavformat.html libavformat] as a demuxer.<br/>
 +
 
 +
=== [[VapourSource]] ===
 +
Can be used to import [http://www.vapoursynth.com/ VapourSynth] scripts into AviSynth. Video can be 8-bit or greater.
 +
 
 +
=== ImageMagick ===
 +
You can also import video or still via 16-bit PNG format pictures with the following [http://www.imagemagick.org/ ImageMagick] command lines. 
 +
 
 +
Examples shown are for Windows. Requires the 16-bit version of ImageMagick; get it [http://www.imagemagick.org/script/binary-releases.php#windows here] (look for downloads with ''Q16'' in the file name)
 +
 
 +
*Convert 16-bit to [[Stack16]] (high/low or stack16 format):<div {{BoxWidthIndent|60|1}} >
 +
convert 16bit.png -depth 16 ( +clone -evaluate and 255 -evaluate multiply 256 )
 +
        -append stacked.png
 +
</div><div style="max-width:62em" >
 +
 
 +
*Convert Stack16 (high/low) to 16bit:<div {{BoxWidthIndent|60|1}} >
 +
convert stacked.png -depth 16 -crop 100%x50% ( +clone -evaluate divide 256 )
 +
        -delete 1 -compose Add -composite -define png:bit-depth=16 16bit1.png
 +
</div>
 +
 
 +
For further explanation of these command lines, please see the thread [http://forum.doom9.org/showthread.php?t=172846 ''Image Magick and stacked high bit-depth''] (doom9.org)
  
<br>
+
=== Obsolete ===  
:There are 3 variants of the patched ffms2:
+
::*- ffms2/ffmbc - This version uses [http://code.google.com/p/ffmbc/ ffmbc] as a decoder; may have better support for professional video formats like ProRes, DNxHD, etc.
+
::*- ffms2/ffmpeg - This version uses [http://en.wikipedia.org/wiki/FFmpeg ffmpeg] as a decoder; may be better for general (more common) formats.
+
::*- ffms2/libav - This version uses [http://en.wikipedia.org/wiki/Libav libav] as a decoder; may be better for general (more common) formats. (read note #2)
+
:These versions worked just like the official [[FFmpegSource|FFMS2]], the only difference is the additional 'enable10bithack' parameter.
+
:By default 'enable10bithack' is set to false, to import high bit depth video set enable10bithack=true.
+
<br>
+
::Note:
+
::# There may be a long delay on opening, as FFMS2 performs an automatic indexing operation.
+
::# At the time of writing (1-8-2012), the official libav library had a bug with decoding of DNxHD video, so you should use the ffmbc build to decode that.
+
<br>
+
==== [[LSMASHSource]] ====
+
:Another source filter to import regular 8-bit and high bit depth video.
+
:LSMASHSource includes these 2 fuctions to import video:
+
::[[LSMASHSource/LSMASHVideoSource|LSMASHVideoSource]] - This function uses [http://en.wikipedia.org/wiki/Libavcodec#Implemented_video_codecs libavcodec] as a video decoder and [http://github.com/l-smash/l-smash L-SMASH] as a demuxer. Recommended for MP4, MOV, [http://en.wikipedia.org/wiki/ISO_base_media_file_format ISO Base Media] and its derived file formats.
+
::[[LSMASHSource/LWLibavVideoSource|LWLibavVideoSource]] - This function uses [http://en.wikipedia.org/wiki/Libavcodec#Implemented_video_codecs libavcodec] as a video decoder and [http://www.ffmpeg.org/libavformat.html libavformat] as a demuxer.
+
<br>
+
==== [[VapourSource]] ====
+
:Can be used to import [http://www.vapoursynth.com/ VapourSynth] scripts into Avisynth. Video can be 8-bit or greater. 
+
<br>
+
==== Obsolete ====  
+
 
'''The following methods are obsolete! If you must, only use as a verification or as workaround:'''<br>
 
'''The following methods are obsolete! If you must, only use as a verification or as workaround:'''<br>
  
:[http://forum.doom9.org/showthread.php?p=1526131#post1526131 Readv210mod] - Can read uncompressed v210 in .mov container as color.  Needs a manual setting skip the file header.   
+
*[http://forum.doom9.org/showthread.php?p=1526131#post1526131 Readv210mod] - Can read uncompressed v210 in .mov container as color.  Needs a manual setting skip the file header.   
  
:[http://sites.google.com/site/ourenthusiasmsasham/soft Sashimi] - Sashimi 0.85 has different bit-depth support.  Please see OtherFormats/Read_v210.avs included in the package.
+
*[http://sites.google.com/site/ourenthusiasmsasham/soft Sashimi] - Sashimi 0.85 has different bit-depth support.  Please see OtherFormats/Read_v210.avs included in the package.
  
:[http://forum.doom9.org/showthread.php?t=158985 ReadV210] - Can read uncompressed v210 in .mov container as greyscale.   
+
*[http://forum.doom9.org/showthread.php?t=158985 ReadV210] - Can read uncompressed v210 in .mov container as greyscale.   
 
<br>
 
<br>
:Alternative builds and methods of importing '''(also obsolete)''':
+
Alternative builds and methods of importing '''(also obsolete)''':
  
::[http://forum.doom9.org/showthread.php?p=1528494 ffms2mod] - Can return most 10bit video in the Avisynth high bit-depth convention.
+
*[http://forum.doom9.org/showthread.php?p=1528494 ffms2mod] - Can return most 10bit video in the Avisynth high bit-depth convention.
  
::[http://forum.doom9.org/showthread.php?t=162598&page=2 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.
+
*[http://forum.doom9.org/showthread.php?t=162598&page=2 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.
<br>
+
</div>
  
== Processing High Bit-depth Video with Avisynth ==
 
  
 +
== Processing High Bit-depth Video with AviSynth ==
 +
<div style="max-width:62em" >
 
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.
 
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.<br>
 
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.<br>
 
This special format must be processed only with high-bit aware scripts and plugins.<br>
 
This special format must be processed only with high-bit aware scripts and plugins.<br>
<br>
+
* Multipurpose
*'''[http://forum.doom9.org/showthread.php?t=167573 AutoAdjust]''' - A high quality automatic color adjustment filter. AutoAdjust can input and output 16-bits; all calculations are internally done in 32-bit float to avoid rounding errors and artifacts.
+
**'''[[Dither_tools|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.
  
*'''[http://forum.doom9.org/showpost.php?p=1579509 AvgAll_16]''' - Average all frames in a clip with 16-bit accuracy.
+
* Antialiasing
 +
**'''[[Xaa]]''' - anti-aliasing and resizing script.
  
*'''[http://forum.doom9.org/showpost.php?p=1672638 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.
+
* Color Correction
 +
** '''[[AutoAdjust]]''' - Automatic color adjustment plugin.
 +
** '''[http://www.snovidenie.com/plugins/hdr/ HDRMatrix]''' - Bt.601-Bt.709 conversion and RGB color correction filter, see [http://forum.doom9.org/showthread.php?t=172189&page=2#post1756038 discussion].
  
*'''[http://forum.doom9.org/showthread.php?t=168048 ClipBlend16]''' - Blend an specified amount of frames into a single frame with 16-bit accuracy.  
+
* Debanding
 +
**'''[http://forum.doom9.org/showthread.php?t=161411 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.  
  
*'''[[Debilinear]]''' - This filter is designed to reverse the effects of bilinear upsampling. 8/16-bit input and output.
+
* Degraining
 +
**'''[[SMDegrain]]''' - mvtools+mdegrain denoising with 16-bit input and output.
  
*'''[http://forum.doom9.org/showthread.php?p=1467907#post1467907 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)
+
* Denoising
 +
**'''[http://forum.doom9.org/showthread.php?t=162342 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.
 +
**'''[http://forum.videohelp.com/threads/369142-Simple-MDegrain-Mod-v2-2d-A-Quality-Denoising-Solution SMDegrainMod]''' - 8/16 bit denoising with additional features like sharpening. [http://web.archive.org/web/20131210170708/http://doom10.org/index.php?topic=2178.0 Original Doom10 archived page.]
 +
**'''[http://forum.doom9.org/showthread.php?t=167032 TempLinearApproximate]''' - 8/16 bit filter for temporal linear approximation between pixels . Meant mainly for denoising aid in motion compensated clips.
 +
**'''[http://forum.doom9.org/showthread.php?t=172966 xNLMeans]''' - Implementation of the Non Local Means denoising algorithm, as described by Buades et al. Includes support for 16-bit input and output.
  
*'''[http://forum.doom9.org/showthread.php?t=162342 DenoiseMD]''' - 8/16-bit denoise.
+
* Deringing
 +
**[[HQDering_mod|'''HQDeringMod''']] - Deringing script with 16-bit input and output.
  
*'''[http://forum.doom9.org/showpost.php?p=1386559 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.  
+
* Effects
 +
**'''[[f3kgrain]]''' - Luma adaptive grain generator with 8/16-bit input and output.
 +
**[http://www.snovidenie.com/plugins/hdr/ HDRNoise] - Random noise and film grain library, see [http://forum.doom9.org/showthread.php?t=172189&page=2#post1756038 discussion.]
  
*'''[http://forum.doom9.org/showthread.php?t=161411 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.  
+
* Frame Averaging
 +
**'''[http://forum.doom9.org/showpost.php?p=1579509 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.
 +
**'''[http://forum.videohelp.com/threads/369143-ResizersPack-MasksPack-PlaygroundPack-SmoothContrast-Logo-mod-functions?p=2364056 Resizers Functions Pack]''' - Includes LinearResize(), a function to resize in linear space. 8/16-bit input/output. [http://web.archive.org/web/20141105135234/http://doom10.org/index.php?topic=2182.0 Original Doom10 archived page.]
  
*[[HQDering_mod|'''HQDeringMod''']] - Deringing script with 16-bit input and output.
+
* Support
 +
**'''[http://www.snovidenie.com/plugins/hdr/ HDRCore]''' - Basic YUV bitdepth and range conversion filters, see [http://forum.doom9.org/showthread.php?t=172189 discussion].
  
*'''[http://forum.doom9.org/showthread.php?t=163018 RedAverage]''' - 16-bit capable average with masking.
+
* Deprecated
 +
**'''[http://forum.doom9.org/showthread.php?p=1467907#post1467907 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)
  
*'''[http://svn.int64.org/viewvc/int64/resamplehq/doc/index.html ResampleHQ]''' - Provides gamma-aware resizing and color space conversion.  Uses 32-bit linear color internally but input and output is limited to 8-bit.
+
You can also check the [[External_filters#Deepcolor_Filters|External Filters: DeepColor]] section, and the [[:Category:Deep_color_tools|Deep Color Tools]] category for possibly more listings.
 +
</div>
  
*'''[http://doom10.org/index.php?topic=2182.0 Resizers Functions Pack]''' - Includes LinearResize(), a function to resize in linear space. 8/16-bit input/output.
 
 
*'''[http://doom10.org/index.php?topic=2178.0 SMDegrainMod]''' - 8/16 bit denoising with additional features like sharpening.
 
 
*'''[http://forum.doom9.org/showthread.php?t=154971 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.
 
 
*'''[http://forum.doom9.org/showthread.php?t=167032 TempLinearApproximate]''' - 8/16 bit filter for temporal linear approximation between pixels . Meant mainly for denoising aid in motion compensated clips.
 
<br>
 
You can also check [[External_filters#Deepcolor_Filters| DeepColor Filters]] section for possibly more listings.
 
 
[http://blendervse.wordpress.com/2011/09/16/8bit-video-to-16bit-scene-referred-linear-exrs/ 8-bit video to 16-bit Scene Referred Linear .EXR’s]
 
<br>
 
<br>
 
 
== Codecs which support high bit-depth ==
 
== Codecs which support high bit-depth ==
 
+
<div style="max-width:62em" >
 
*[http://en.wikipedia.org/wiki/Animation_codec Apple Animation]
 
*[http://en.wikipedia.org/wiki/Animation_codec Apple Animation]
  
 
*[http://en.wikipedia.org/wiki/DNxHD DNxHD] also supported by [http://code.google.com/p/ffmbc/ ffmbc]
 
*[http://en.wikipedia.org/wiki/DNxHD DNxHD] also supported by [http://code.google.com/p/ffmbc/ ffmbc]
  
*[http://en.wikipedia.org/wiki/H.264 H.264, High 10 Profile (Hi10P) and above] - 10-bit YUV 4:2:0/4:2:2/4:4:4 available via x264.
+
*[http://en.wikipedia.org/wiki/H.264 H.264] - 10-bit YUV 4:2:0/4:2:2/4:4:4 available via x264 (lossy/lossless compression supported).
 +
 
 +
*[http://en.wikipedia.org/wiki/High_Efficiency_Video_Coding HEVC] - 10-bit YUV 4:2:0/4:2:2/4:4:4 available via x265 (lossy/lossless compression supported).
  
 
*[http://en.wikipedia.org/wiki/ProRes ProRes 422]
 
*[http://en.wikipedia.org/wiki/ProRes ProRes 422]
Line 127: Line 173:
 
*[http://www.videohelp.com/tools/Ut-Video-Codec-Suite Ut Video Codec Suite] - YUV 4:2:2 10bit (lossless compression).
 
*[http://www.videohelp.com/tools/Ut-Video-Codec-Suite Ut Video Codec Suite] - YUV 4:2:2 10bit (lossless compression).
  
https://en.wikipedia.org/wiki/Digital_cinematography#Digital_acquisition_codecs_compared
+
*[http://en.wikipedia.org/wiki/VP9 VP9] - support for YUV 4:2:0/4:2:2/4:4:4 10-12bit encoding via [http://en.wikipedia.org/wiki/VP9#Profiles profiles 2 and 3.]
<br>
+
<br>
+
== Exporting High Bit-depth Video ==
+
  
You can encode out of AVIsynth to 10bit x264 via
+
*[http://azfcpug.org/wp-content/uploads/2011/02/Digital%20Video%20Acquisition%20Codecs.pdf Digital Video Acquisition Codecs.pdf] [http://web.archive.org/web/20141021023458/http://azfcpug.org/wp-content/uploads/2011/02/Digital%20Video%20Acquisition%20Codecs.pdf mirror]
 +
</div>
  
AVS4x264 https://astrataro.wordpress.com/2012/06/04/avs4x264mod-v0-8-0-supports-d2v-dgi-dga-avi-mkv-mp4-m2ts-wmv-input-and-auto-fps-correction/  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.
 
  
x264+tmod https://astrataro.wordpress.com/2012/07/21/x264-rev2208677-tmod/  tmod is 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
+
== Exporting High Bit-depth Video ==
 +
<div style="max-width:62em" >
 +
You can encode out of AviSynth to 10bit x264 via
  
10bit x264 command-line example:
+
*[http://tmod.nmm-hd.org/x264/ 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.
  
  avs2yuv -raw "script.avs" -o - | x264-10bit --demuxer raw --input-depth 10 --input-res 1280x720 --fps 24 --output "out.mp4" -
+
10bit x264 command-line example:<div {{BoxWidthIndent|60|1}} >
 +
  avs2yuv -raw "script.avs" -o - | x264-10bit --demuxer raw --input-depth 10  
 +
        --input-res 1280x720 --fps 24 --output "out.mp4" -
 +
</div>
  
AVS2yuv (http://akuvian.org/src/avisynth/avs2yuv/)
+
*[[Avs2YUV]]
  
AVS2pipemod (https://github.com/chikuzen/avs2pipemod#readme).  The Dither html doc with the plugin gives examples of using AVS2yuv including lossless 10bit.
+
*[[avs2pipemod]]
  
AVS2x264mod http://forum.doom9.org/showthread.php?p=1529305#post1529305  Example:
+
*[[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 [http://astrataro.wordpress.com/category/encode/x264/avs4x26x/ blog] for updated versions.
  
 +
Example:<div {{BoxWidthIndent|60|1}} >
 
  avs4x264mod.exe --x264-binary “C:\x264_64-abc.exe” -o out.264 in.avs
 
  avs4x264mod.exe --x264-binary “C:\x264_64-abc.exe” -o out.264 in.avs
<br>
+
</div>
 +
 
 +
Some tutorials on exporting high bit depth image sequences:
 +
*[http://web.archive.org/web/20130914191039/http://blendervse.wordpress.com/2011/09/16/8bit-video-to-16bit-scene-referred-linear-exrs/ 8-bit video to 16-bit Scene Referred Linear .EXR’s]
 +
*[http://web.archive.org/web/20131112191047/http://blendervse.wordpress.com/2013/03/23/pipe-to-rgb-quick-how-to/ Pipe To RGB – Quick How To]
 +
*[http://web.archive.org/web/20131009105710/http://blendervse.wordpress.com/2013/03/12/pipe-to-rgb-avspmod-to-imagemagick/ Pipe To RGB – AvsPmod To ImageMagick]
 +
</div>
 +
 
  
 
== Playback of High Bit-depth Videos ==
 
== Playback of High Bit-depth Videos ==
 +
<div style="max-width:62em" >
 +
*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 ([http://4ktvblog.com/10-bit-monitor list of 10-bit monitors]).
  
-Most of the time you will only get to see dithered 8-bit video, as equipment to truly display high bit-depths is rare at the consumer level in 2011. Digital theaters project up to 12-bit video. Guide: http://coalgirls.wakku.to/?page_id=4635
+
*The Blu-ray standard does not support high bit-depth video nor [http://en.wikipedia.org/wiki/XvYCC xvYCC] color space (full-range 8 bit video). On September 2014 it was announced that the up-and-coming [http://en.wikipedia.org/wiki/Blu-ray_Disc#4K_Blu-ray_Disc 4k Blu-ray] standard will support 10-bit video and a greater color gamut by using the [http://en.wikipedia.org/wiki/Rec._2020 Rec. 2020] color space.
  
-The Bluray standard does not support xvColor (using full-range 8 bit video) or high bit-depth video.
+
*Digital theaters project up to 12-bit video; for more information read the wiki article: [http://en.wikipedia.org/wiki/Digital_Cinema_Initiatives#Image_and_audio_capability_overview Digital Cinema Initiatives]
  
Playback Software
+
=====Playback Software=====
  
MPlayer with high-bit codecs installed, such as http://samples.mplayerhq.hu/drivers32/new/AppleProResDecoder.qtx ProRES 422
+
*[http://forum.doom9.org/showthread.php?t=146228 MadVR]
  
MadVR http://forum.doom9.org/showthread.php?t=146228
+
*[http://mpc-hc.org/ MPC-HC]
  
VLC http://www.videolan.org
+
*[http://forum.doom9.org/showthread.php?t=171120 MPDN]
  
Other sofware and information
+
*[http://www.videolan.org VLC]
  
Further information on high-bit playback http://forum.doom9.org/showthread.php?t=161548
+
=====Other Software and Information=====
  
FFdshow builds with 10-bit support http://forum.doom9.org/showthread.php?t=161915
+
*[http://forum.doom9.org/showthread.php?t=161548 Further information on high-bit playback]
  
An excellent guide on 10-bit playback:  http://haruhichan.com/wpblog/?p=205
+
*[http://haruhichan.com/wpblog/?p=205 An excellent guide on 10-bit playback]
<br>
+
<br>
+
== Sample High Bit-Depth Videos ==
+
  
 +
*[http://forum.doom9.org/showthread.php?t=161915 FFdshow builds with 10-bit support] (deprecated)
 +
</div>
 +
 +
 +
== Sample High Bit-Depth Videos ==
 +
<div style="max-width:62em" >
 
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
 
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
 +
</div>
  
 
[[Category:Advanced topics]]
 
[[Category:Advanced topics]]
 +
[[Category:Deep_color_tools]]

Revision as of 09:34, 6 July 2020

Contents

Introduction

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.

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.

ImageMagick

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)

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.
    • 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.
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

Views
Personal tools
Navigation
community
in other languages
Tools