Log in

View Full Version : Avisynth to ffmpeg (16bit stacked/interleaved)


FranceBB
21st July 2018, 05:27
Hi,
I gotta encode a few DNxHR 12bit files into AppleProRes 10bit.
Here's what I'm doing:

#Indexing the 12bit source dithered up to 16bit stacked

FFMpegSource2("video1.mxf", atrack=-1, enable10bithack=true)

#Loudness Correction

ResampleAudio(48000)
Normalize(0.12)

#16bit downscale using Lanczos via nnedi

nnedi3_resize16(target_width=1920, target_height=1080, tv_range=true, kernel_d="Lanczos", lsb_in=true, lsb=true)

#16bit debanding using f3kdb

f3kdb(range=15, Y=45, Cb=30, Cr=30, grainY=0, grainC=0, sample_mode=2, blur_first=true, dynamic_grain=false, opt=3, mt=true, keep_tv_range=true, input_mode=1, input_depth=16, output_mode=1, output_depth=16)

Now I'd like to output 16bit stacked (output_mode=1, output_depth=16) or 16bit interleaved (output_mode=2, output_depth=16) to ffmpeg and let it dither it down to 10bit and encode in AppleProRes. Does ffmpeg actually support 16bit stacked/interleaved? I generally encode in either H.264/HEVC with x264/x265 and their pipe applications actually support 16bit stacked/interleaved, but this time I gotta encode in AppleProRes, therefore I'm using ffmpeg and I'm not sure whether it supports these high bit dept formats or not.

Gser
21st July 2018, 09:55
Using nnedi3_resize16 for downscaling is the funniest thing I've seen in a while. Might I suggest http://avisynth.nl/index.php/Dither_tools it has some nice debanding stuff too. I don't know if ffmpeg supports stacked formats but it does suppport real 10 bit formats so you might want to consider updating to AVS+.

On a side note how much banding can there really be on a 12-bit source?

FranceBB
21st July 2018, 12:09
On a side note how much banding can there really be on a 12-bit source?

Almost none if it was real 12bit. I believe it has been edited and exported at 12bit from AVID Media Composer, but the original shoots recorded by the camera were plain 8bit.

sneaker_ger
22nd July 2018, 16:18
Yes, ffmpeg can handle such interleaved input.
Example:
avspipemod -rawvideo "script.avs" | ffmpeg -y -f rawvideo -pixel_format yuv420p16le -video_size 1920x1080 -framerate 25 -i - "output.mkv"

FranceBB
23rd July 2018, 07:04
Got it.
I used avs2yuv to pipe to ffmpeg and encode.
Unfortunately, avs2yuv only supports 16bit interleaved (HDRTools) and doesn't support 16bit stacked (Dither_Tools), so I had to convert it internally in Avisynth (not a big deal).

#Indexing the 12bit source dithered up to 16bit stacked

FFMpegSource2("video1.mxf", atrack=-1, enable10bithack=true)

#Loudness Correction

ResampleAudio(48000)
Normalize(0.12)

#16bit stacked downscale using Lanczos via nnedi

nnedi3_resize16(target_width=1920, target_height=1080, tv_range=true, kernel_d="Lanczos", lsb_in=true, lsb=true)

#debanding using f3kdb (16bit stacked in, 16bit interleaved out)

f3kdb(range=15, Y=45, Cb=30, Cr=30, grainY=0, grainC=0, sample_mode=2, blur_first=true, dynamic_grain=false, opt=3, mt=true, keep_tv_range=true, input_mode=1, input_depth=16, output_mode=2, output_depth=16)

avs2yuv.exe "test.avs" -depth 16 -csp auto - | ffmpeg.exe -hwaccel dxva2 -i - -pix_fmt yuv422p10le -c:v prores -an test_output.mov


It worked.