High bit-depth Support with Avisynth

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
m (Importing High Bit-depth Video into AviSynth)
m (Importing High Bit-depth Video into AviSynth)
Line 29: Line 29:
 
<br>
 
<br>
 
<br>
 
<br>
==== FFMS2 ====
+
=== 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.
+
'''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.
  
 
*Source code: [http://github.com/SAPikachu/ffms2_hacks GitHub repository]
 
*Source code: [http://github.com/SAPikachu/ffms2_hacks GitHub repository]
 
*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 SAPikachu's signature for latest versions)
 
*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 SAPikachu's signature for latest versions)
 
 
<br>
 
<br>
===== Download =====
+
==== Download ====
 
* <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> - 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.
 
* <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> - 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.
 
* <code>[http://www.nmm-hd.org/upload/get~fmbjO7t9dEg/ffms2-9417b9c-ffmpeg-8728360.7z ffms2-9417b9c-ffmpeg-8728360.7z]</code>  - This version uses [http://en.wikipedia.org/wiki/FFmpeg FFmpeg] as a decoder; may be better for general (more common) formats.
 
* <code>[http://www.nmm-hd.org/upload/get~fmbjO7t9dEg/ffms2-9417b9c-ffmpeg-8728360.7z ffms2-9417b9c-ffmpeg-8728360.7z]</code>  - This version uses [http://en.wikipedia.org/wiki/FFmpeg FFmpeg] as a decoder; may be better for general (more common) formats.
Line 48: Line 47:
 
<br>
 
<br>
  
==== [[LSMASHSource]] ====
+
=== [[LSMASHSource]] ===
 
Another source filter to import regular 8-bit and high bit depth video. LSMASHSource includes these 2 fuctions to import video:
 
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/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/>
 
*[[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/>
 
<br>
 
<br>
==== [[VapourSource]] ====
+
=== [[VapourSource]] ===
 
Can be used to import [http://www.vapoursynth.com/ VapourSynth] scripts into AviSynth. Video can be 8-bit or greater.<br/>
 
Can be used to import [http://www.vapoursynth.com/ VapourSynth] scripts into AviSynth. Video can be 8-bit or greater.<br/>
 
<br>
 
<br>
==== Obsolete ====  
+
=== 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>
  

Revision as of 05:26, 22 October 2014

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?

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



Importing High Bit-depth Video into AviSynth

For importing high bit depth video AviSynth 2.6.0 Alpha5 or later is strongly recommended. AviSynth 2.6 adds additional color spaces (Y8,YV16,YV24) that make 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.

  • Source code: GitHub repository
  • Discussion: Doom9 thread - Importing DNxHD to Avisynth (some of the links may be outdated; see downloads below or SAPikachu's signature for latest versions)


Download

These versions worked just like the official FFMS2, but include 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.

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 had a bug with decoding of DNxHD video, so you should use the FFmbc build to decode that.


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.

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.

  • 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.
  • AvgAll_16 - Average all frames in a clip with 16-bit accuracy.
  • 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.
  • ClipBlend16 - Blend an specified amount of frames into a single frame with 16-bit accuracy.
  • Debilinear - This filter is designed to reverse the effects of bilinear upsampling. 8/16-bit input and output.
  • 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)
  • 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.
  • 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.
  • HQDeringMod - Deringing script with 16-bit input and output.
  • RedAverage - 16-bit capable average with masking. Download latest version here
  • ResampleHQ - Provides gamma-aware resizing and color space conversion. Uses 32-bit linear color internally but input and output is limited to 8-bit.
  • SMDegrainMod - 8/16 bit denoising with additional features like sharpening.
  • 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.
  • TempLinearApproximate - 8/16 bit filter for temporal linear approximation between pixels . Meant mainly for denoising aid in motion compensated clips.

You can also check DeepColor Filters section for possibly more listings.

Codecs which support high bit-depth



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 rare at the consumer level in 2011. Digital theaters 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

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

Personal tools