Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
15th May 2019, 00:31 | #1 | Link |
Registered User
Join Date: Jun 2002
Location: On thin ice
Posts: 6,837
|
question on Dither tools
Which format does the script below output and which command line would I use to encode it with x265?
Code:
LoadPlugin("C:\Users\frank\Daten\Projekte\VB\staxrip\bin\Apps\Plugins\avs\AddGrainC\AddGrainC.dll") LoadPlugin("C:\Users\frank\Daten\Projekte\VB\staxrip\bin\Apps\Plugins\avs\DFTTest\dfttest.dll") LoadPlugin("C:\Users\frank\Daten\Projekte\VB\staxrip\bin\Apps\Plugins\avs\masktools2\masktools2.dll") Import("C:\Users\frank\Daten\Projekte\VB\staxrip\bin\Apps\Plugins\AVS\Dither\mt_xxpand_multi.avsi") LoadPlugin("C:\Users\frank\Daten\Projekte\VB\staxrip\bin\Apps\Plugins\avs\RgTools\RgTools.dll") Import("C:\Users\frank\Daten\Projekte\VB\staxrip\bin\Apps\Plugins\AVS\Dither\dither.avsi") LoadPlugin("C:\Users\frank\Daten\Projekte\VB\staxrip\bin\Apps\Plugins\AVS\Dither\dither.dll") LoadPlugin("C:\Users\frank\Daten\Projekte\VB\staxrip\bin\Apps\Plugins\avs\L-SMASH-Works\LSMASHSource.dll") LSMASHVideoSource("C:\Users\frank\Daten\Samples\test.mp4") dither_convert_8_to_16() dither_quantize(bitdepth=10, reducerange=true, mode=0) dither_out() BicubicResize(1280, 720) Trim(1264, 1563)
__________________
https://github.com/stax76/software-list https://www.youtube.com/@stax76/playlists |
15th May 2019, 01:28 | #2 | Link |
Registered User
Join Date: Jul 2012
Location: Nottingham
Posts: 44
|
Hi , i think interleaved-10bit , i tried it with below seems to works fine (i think u don't need an BicubicResize after dither_out).
Code:
avs4x26x --x26x-binary "C:\path\to\x265.exe" --input-depth 10 --sar 1:1 --output-depth 10 -o output.h265 "input.avs" sorry i missed --sar 40:33 in above cli since my source was 720x480 for the test or this avs4x265.exe --input-depth 10 --sar 40:33 --output-depth 10 -o "output.hevc" "input.avs" or avs4x265.exe -P x265.exe --input-depth 10 --sar 40:33 --output-depth 10 -o "output.hevc" "input.avs" Last edited by gugglu; 15th May 2019 at 02:52. Reason: forgot to attach the command line |
15th May 2019, 05:16 | #3 | Link |
Registered User
Join Date: Jun 2002
Location: On thin ice
Posts: 6,837
|
I would prefer either avs2pipemod64 or ffmpeg.
__________________
https://github.com/stax76/software-list https://www.youtube.com/@stax76/playlists |
15th May 2019, 11:00 | #4 | Link |
Registered User
Join Date: Jul 2012
Location: Nottingham
Posts: 44
|
Code:
ok no problem avs2pipemod -rawvideo "input.avs" | x264-10bit - --input-depth 10 --input-csp i420 --input-res 720x480 --sar 40:33 --fps 24000/1001 -o "outputx26410bit.264" avs2pipemod -rawvideo "input.avs" | x265 - --input-depth 10 --input-csp i420 --input-res 720x480 --sar 40:33 --fps 24000/1001 --output-depth 10 -o "outputx26510bit.hevc" Last edited by gugglu; 15th May 2019 at 11:06. |
15th May 2019, 16:38 | #5 | Link |
Broadcast Encoder
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,904
|
Before regular high bit depth was introduced, there were two high bit depth version: stacked and interleaved. Stacked was used by Dither Tools and Interleaved was used by HDRTools, however the most used was stacked by dither tools.
Since Avisynth wasn't actually able to have 16bit internally, but only 8bit, in order to be able to work with 16bit precision, the image was divided in two parts: MSB (most significant bits) and LSB (less significant bits). With 16bit stacked, the image has double height as MSB and LSB are "stacked" one on the top of the other. This is what Dither_Tools uses. With 16bit interleaved, the image has double weight as MSB and LSB are "interleaved" one after the other. This is what HDRTools uses. In you case, this is your code: Code:
LSMASHVideoSource("C:\Users\frank\Daten\Samples\test.mp4") dither_convert_8_to_16() dither_quantize(bitdepth=10, reducerange=true, mode=0) dither_out() BicubicResize(1280, 720) Trim(1264, 1563) Code:
LSMASHVideoSource("C:\Users\frank\Daten\Samples\test.mp4") Code:
dither_convert_8_to_16() Code:
dither_quantize(bitdepth=10, reducerange=true, mode=0) Code:
dither_out() Code:
BicubicResize(1280, 720) Trim(1264, 1563) For instance, this is ColorBars 848x480 8bit planar: This is colorbars 16bit stacked (848x960) 'cause MSB and LSB are stacked one on the top of the other: Once you apply reduce range, you get 10bit stacked 848x960, 'cause MSB and LSB are still stacked one on the top of the other, but with 10bit precision rather than 16bit. If you are using a pipe to x264 or x265, you can definitely output 10bit stacked and let it encode it in 10bit planar, however, unless you are using a particular dithering method and you wanna stick with that for any particular reason, then I suggest you to output 16bit stacked to x264/x265 and then let x264/x265 dither it down and encode to 12bit/10bit/8bit planar. Please note that every time you are using high bit depth (16bit stacked or interleaved) and you wanna filter in Avisynth, the filter you are using MUST be high bit depth aware and you MUST set it to work with the correct version of high bit depth, 'cause otherwise you are gonna screw up MSB and LSB. I've been stuck with Avisynth 2.6.1 for years after 2016, but in the end I moved to Avisynth+ and I gotta say that it made my life so much easier as I can work with regular 10/12/14/16bit planar, which is great as I don't have to bother about MSB and LSB anymore. Sure, there are some "legacy" filters that have never been updated to work with planar 16bit, so I still have to use 16bit stacked or 16bit interleaved, but in the end I can go from one to the other and always go back to regular 16bit planar and output it to my target application/encoder and be sure that it's gonna read it, no matter what. For instance, with Avisynth+ pinterf mod: Code:
#Indexing 10bit source video=FFVideoSource("test.mxf") audio=FFAudioSource("test.mxf") AudioDub(video, audio) #From 10bit planar to 16bit planar ConvertBits(bits=16) #From 16bit planar to 16bit stacked ConvertToStacked() #Denoise with 16bit precision dfttest(sigma=64, tbsize=1, lsb_in=true, lsb=true, Y=true, U=true, V=true, opt=3, dither=0) #From 16bit stacked to 16bit planar ConvertFromStacked() #Resize with 16bit planar precision Spline64Resize(1280, 720) #Dithering down from 16bit planar to 10bit with the Floyd-Steinber error diffusion ConvertBits(bits=10, dither=1) #Clipping for limited TV Range 10bit Limiter(min_luma=64, max_luma=940, min_chroma=64, max_chroma=940) If I want to, I could go from Planar to Interleaved and vice-versa as well. If I was in Avisynth 2.6.1, I would have done something like: Code:
#Indexing 10bit source as 16bit stacked video=LWLibavVideoSource("test.mxf", stacked=true) audio=LWLibavAudioSource("test.mxf") AudioDub(video, audio) #Denoise with 16bit stacked precision dfttest(sigma=64, tbsize=1, lsb_in=true, lsb=true, Y=true, U=true, V=true, opt=3, dither=0) #Resize with 16bit stacked precision Dither_resize16nr(1280, 720, kernel="spline64") #Dithering down to 10bit stacked with the Floyd-Steinberg error diffusion Dither_quantize(bitdepth=10, reducerange=true, mode=6) Anyway, I hope this helps and clarifies your doubts about stacked, interleaved and planar. Please also note that Avisynth 2.6.1 is no longer maintained and that new filters won't work in stacked/interleaved but only in planar. For instance, DGHDRtoSDR by Donald Graft works with 16bit planar only, ResizeMT by Jean Philippe works in planar only, so with Avisynth 2.6.1 it will be limited to 8bit precision, Hable, Mobius and Reinhard tone-mapping algorithms will work in 16bit planar only so you won't be able to use them in Avisynth 2.6.1, Cube will work in planar RGB 16bit only with a good enough precision, 'cause in 8bit planar RGB it would be too approximated and so on. Last edited by FranceBB; 15th May 2019 at 16:47. |
15th May 2019, 17:36 | #6 | Link |
Registered User
Join Date: Jun 2002
Location: On thin ice
Posts: 6,837
|
@FranceBB
Great explanation, thanks! @gugglu You should be fine if your script outputs planar.
__________________
https://github.com/stax76/software-list https://www.youtube.com/@stax76/playlists |
15th May 2019, 18:48 | #9 | Link | |
Registered User
Join Date: Jul 2012
Location: Nottingham
Posts: 44
|
Quote:
yes thats what i am wondering will staxrip read this script and will it output the correct output instead of the greenish look |
|
15th May 2019, 18:54 | #10 | Link |
Registered User
Join Date: Jun 2002
Location: On thin ice
Posts: 6,837
|
It outputs stacked format, right?
I don't know if stacked format is supported by Avs2pipemod, x265 or ffmpeg, the docs don't contain the word 'stacked' http://avisynth.nl/index.php/Avs2pipemod https://x265.readthedocs.io/en/latest/cli.html
__________________
https://github.com/stax76/software-list https://www.youtube.com/@stax76/playlists |
15th May 2019, 19:08 | #11 | Link | |
Noob
Join Date: Mar 2017
Posts: 221
|
Quote:
i dont know much but i think we need a list of native planar high bit depth supported filters, and some filters need to be ported to HBD in avs, which are already working in HBD in VapourSynth |
|
15th May 2019, 19:23 | #12 | Link | |
Registered User
Join Date: Jul 2012
Location: Nottingham
Posts: 44
|
Quote:
yes sure i have all these program x264.exe / x265.exe avs2pipemod and avs4x26x also avs4x265 in this location C:\Users\administrator and i use these below cli.bat files via cmd.exe to output and it works Code:
avs2pipemod -rawvideo "input.avs" | x264-10bit - --input-depth 10 --input-csp i420 --input-res 720x480 --sar 40:33 --fps 24000/1001 -o "outputx26410bit.264" avs2pipemod -rawvideo "input.avs" | x265 - --input-depth 10 --input-csp i420 --input-res 720x480 --sar 40:33 --fps 24000/1001 --output-depth 10 -o "outputx26510bit.hevc" avs4x265.exe -P x265.exe --input-depth 10 --sar 40:33 --output-depth 10 -o "output.hevc" "input.avs" it was giving the double_width green output when i was trying it in staxrip , but avs2pipemod works fine with command line but it refuse to detect the dither_out hacked format high-bit depth in staxrip this is what is upsetting me a little , for everything else staxrip works brilliant as it should and i m happy with it . can i request you to add avs4x26x or avs4x265 into staxrip if it is possible? thanks for the staxrip, really appreciate your great work. |
|
15th May 2019, 19:33 | #13 | Link |
Registered User
Join Date: Jun 2002
Location: On thin ice
Posts: 6,837
|
and if you do this:
dither_convert_8_to_16() dither_quantize(bitdepth=10, reducerange=true, mode=0) dither_out() ConvertFromDoubleWidth(bits=10)
__________________
https://github.com/stax76/software-list https://www.youtube.com/@stax76/playlists |
15th May 2019, 19:42 | #14 | Link | |
Registered User
Join Date: Jul 2012
Location: Nottingham
Posts: 44
|
Quote:
Edit: Awesome! that works fine, just tried it. bunch of thanks. Last edited by gugglu; 15th May 2019 at 19:46. Reason: tested the script |
|
|
|