High bit-depth Support with Avisynth

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
m (1 revision)
m
Line 82: Line 82:
 
-H.264, High 10 Profile (Hi10P) and above  https://en.wikipedia.org/wiki/H.264
 
-H.264, High 10 Profile (Hi10P) and above  https://en.wikipedia.org/wiki/H.264
  
-ProRes 422  https://en.wikipedia.org/wiki/Prores
+
-ProRes 422  https://en.wikipedia.org/wiki/ProRes
  
 
-DNxHD  https://en.wikipedia.org/wiki/DNxHD also supported by ffmbc  https://code.google.com/p/ffmbc/
 
-DNxHD  https://en.wikipedia.org/wiki/DNxHD also supported by ffmbc  https://code.google.com/p/ffmbc/

Revision as of 17:32, 15 November 2013

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 deepcolor?

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


Why Use Deepcolor?

-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/

-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

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

-Professional video is stored in 10bit formats (like ProRes 422) and people want to use Avisynth for processing.


Importing High Bit-depth Video into Avisynth

Patched ffms2/ffms2-ffmbc - http://forum.doom9.org/showthread.php?p=1580141#post1580141 (See SAPikachu's signature for downloading) Can import DNxHD, ProRes, or other 10 bit videos in their native chroma format (4:2:2 and 4:4:4 are also supported), outputting in the Avisynth high bit-depth convention. Uses Avisynth 2.6's new colorspace. You can process with the full quality of the format.

Note:

  1. There may be a long delay on opening, as FFMS2 performs an automatic indexing operation.
  2. At the time of writing (1-8-2012), the official libav library has a bug with decoding of DNxHD video, so you should use the ffmbc build to decode that. Other than that, both builds should be OK, but ffmbc may have better support for professional video formats (ProRes etc.), and libav is better for H264 and other common formats.


The following methods are obsoleted now, except as a verification or workaround:

Readv210mod - http://forum.doom9.org/showthread.php?p=1526131#post1526131 Can read uncompressed v210 in .mov container as color. Needs a manual setting skip the file header.

Sashimi - http://sites.google.com/site/ourenthusiasmsasham/soft - Sashimi 0.85 has different bit-depth support. Please see OtherFormats/Read_v210.avs included in the package.

ReadV210 - http://forum.doom9.org/archive/index.php/t-158985.html Can read uncompressed v210 in .mov container as greyscale.

Alternative builds and methods of importing:

ffms2mod - http://forum.doom9.org/showthread.php?p=1528494 Can return most 10bit video in the Avisynth high bit-depth convention.

rawsource with ffmpeg - http://forum.doom9.org/showthread.php?t=162598&page=2 - 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, where the high bits are stored in the upper half of a video, and the lower bits in the lower half of the video. This special format must be processed only with high-bit aware scripts and plugins.

RedAverage - http://forum.doom9.org/showthread.php?t=163018 - 16bit capable average with masking.

Dither - http://forum.doom9.org/showthread.php?p=1386559 - A set of scripts, original and modified plugins to process 16-bit clips in the native 8-bit Avisynth environment.

ResampleHQ - http://svn.int64.org/viewvc/int64/resamplehq/doc/index.html - Provides gamma-aware resizing and colorspace conversion. Uses 32-bit linear color internally.

Tweak3 - ? - same as Tweak but with dithering.

Smoothlevels - http://forum.doom9.org/showthread.php?t=137479 - Advanced levels adjustment function, with limiting & smoothing parameters.

Deep Color Tools - http://forum.doom9.org/showthread.php?p=1467907#post1467907 - This Script provides basic functions to import 10bit video, do color adjustments, and export to 8bit

flash3kyuu_deband - another deband filter for avisynth - https://github.com/SAPikachu/flash3kyuu_deband#readme http://forum.doom9.org/showthread.php?t=161411 Dither 10bit to 8bit:

ReadV210(...)
f3kdb(precision_mode=3,input_mode=1,input_depth=16)

8/16 bit denoise - deepcolor denoise - http://forum.doom9.org/showthread.php?t=162342

You can also check http://avisynth.org/mediawiki/External_filters#Deepcolor_Filters for possibly more listings.

8bit Video to 16bit Scene Referred Linear guide http://blendervse.wordpress.com/2011/09/16/8bit-video-to-16bit-scene-referred-linear-exrs/


Codecs which support high bit-depth

-H.264, High 10 Profile (Hi10P) and above https://en.wikipedia.org/wiki/H.264

-ProRes 422 https://en.wikipedia.org/wiki/ProRes

-DNxHD https://en.wikipedia.org/wiki/DNxHD also supported by ffmbc https://code.google.com/p/ffmbc/

-Apple Animation https://en.wikipedia.org/wiki/Animation_codec

https://en.wikipedia.org/wiki/Digital_cinematography#Digital_acquisition_codecs_compared


Exporting High Bit-depth Video

You can encode out of AVIsynth to 10bit x264 via

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

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" -

AVS2yuv (http://akuvian.org/src/avisynth/avs2yuv/)

AVS2pipemod (https://github.com/chikuzen/avs2pipemod#readme). The Dither html doc with the plugin gives examples of using AVS2yuv including lossless 10bit.

AVS2x264mod http://forum.doom9.org/showthread.php?p=1529305#post1529305 Example:

avs4x264mod.exe --x264-binary “C:\x264_64-abc.exe” -o out.264 in.avs


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 rare at the consumer level in 2011. Digital theatres project up to 12-bit video. Guide: http://coalgirls.wakku.to/?page_id=4635

-The Bluray standard does not support xvColor (using full-range 8 bit video) or high bit-depth video.

Playback Software

MPlayer with high-bit codecs installed, such as http://samples.mplayerhq.hu/drivers32/new/AppleProResDecoder.qtx ProRES 422

MadVR http://forum.doom9.org/showthread.php?t=146228

VLC http://www.videolan.org

Other sofware and information

Further information on high-bit playback http://forum.doom9.org/showthread.php?t=161548

FFdshow builds with 10-bit support http://forum.doom9.org/showthread.php?t=161915

An excellent guide on 10-bit playback: http://haruhichan.com/wpblog/?p=205

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

Personal tools