利用AviSynth+将SDR转到HDR的测试 (非正规)


在尝试将SDR转到HDR的过程中, 使用AviSynth+将做到最轻量级的软件安装, 下面是方法:
准备软件:
核心软件:
AviSynth+(3.7.5 版本日期2025.04.21) https://github.com/AviSynth/AviSynthPlus/releases
HDRTools (1.0.5 版本日期2023.11.21) https://github.com/jpsdr/HDRTools/releases
L-SMASH-Works (1253 版本日期2025.05.05) https://github.com/HomeOfAviSynthPlusEvolution/L-SMASH-Works/releases/
或 DGdecNV (255 版本日期2025.05.12) https://www.rationalqm.us/dgdecnv/binaries/
x265 https://www.free-codecs.com/download/x265_hevc_encoder.htm
ffmpeg https://www.gyan.dev/ffmpeg/builds/
备用插件:
LinearTransformation (3.0 版本日期2025.05.15) https://github.com/FranceBB/LinearTransformation/releases
AVSCube或DGCube 用于加载LinearTransformation https://rationalqm.us/cube/AVSCube_test.rarhttps://rationalqm.us/misc/DGCube.zip

AVS核心代码:
方法A:

1
2
3
4
5
6
ConvertBits(16)
ConvertYUVtoXYZ()
ConvertXYZtoYUV(Color=1,pColor=2)
ConvertYUVtoLinearRGB(Color=0,HDRMode=1,HLGLw=1500,OOTF=false)
ConvertLinearRGBtoYUV(Color=0,OOTF=false)
ConvertToYUV420()

方法B:

1
2
3
4
5
6
7
ConvertBits(16)
ConvertYUVtoXYZ()
ConvertXYZ_Scale_SDRtoHDR(Coeff_X=60)
ConvertXYZtoYUV(Color=0,pColor=1)
ConvertYUVtoLinearRGB(Color=1,OOTF=false)
ConvertLinearRGBtoYUV_BT2446_A_HDRtoSDR(Lhdr=1000.0,CoeffAdj=1.2)
ConvertToYUV420()

方法C(旧): (太过复杂不建议使用)

1
2
3
4
5
6
7
8
9
10
11
ConvertBits(16)
ConvertYUVtoXYZ()
ConvertXYZ_Scale_SDRtoHDR(Coeff_X=70)
ConvertXYZtoYUV(Color=0,pColor=1)
ConvertYUVtoLinearRGB(Color=1,OOTF=false)
ConvertLinearRGBtoYUV_BT2446_A_HDRtoSDR(Lhdr=1000.0,CoeffAdj=1)
ConvertYUVtoLinearRGB(Color=0,OOTF=false)
ConvertLinearRGBtoYUV(Color=0,HDRMode=1,HLGLw=1000,HLGColor=2,OOTF=false)
ConvertYUVtoLinearRGB(Color=0,HDRMode=1,HLGLw=3000,OOTF=false)
ConvertLinearRGBtoYUV(Color=0,OOTF=false)
ConvertToYUV420()

方法C(新):

1
2
3
4
5
6
7
ConvertBits(16)
ConvertYUVtoXYZ()
ConvertXYZ_Scale_SDRtoHDR(Coeff_X=60)
ConvertXYZtoYUV(Color=0,pColor=1)
ConvertYUVtoLinearRGB(Color=1,OOTF=false)
ConvertLinearRGBtoYUV_BT2446_A_HDRtoSDR(Lhdr=1000.0,CoeffAdj=1.5)
ConvertToYUV420().Tweak(-0,0.8,0,1)

方法D 备用方案(不推荐):

1
2
3
4
5
6
7
ConvertBits(16)
ConvertToPlanarRGB()
Cube("BT709_to_PQ.cube")#文件来自LinearTransformation
ConvertToYUV420()
ConvertYUVtoLinearRGB(Color=1,OOTF=false)
ConvertLinearRGBtoYUV_BT2446_A_HDRtoSDR(Lhdr=1000.0,CoeffAdj=0.8)
ConvertToYUV420()

x265核心代码:

1
--output-depth 10 --colorprim bt2020 --transfer smpte2084 --colormatrix bt2020nc --max-cll "0,0" --master-display "G(8500,39850)B(6550,2300)R(35400,14600)WP(15635,16450)L(10000000,1)"

2025-06-23更新: (之前的方法C太过复杂, 以下内容基于新方法总结)
以上方法的优缺点: A对于高光部分做了明显提亮, 对中间调和暗部保留正常亮度, 有点像新版达芬奇的效果, 可惜中间调偏色了, 特别是肤色, 由于中间调和高光过于明显的差别, 也会导致非动画会出现明显色带, 但就明暗对比度而言A的观感最好
B没有了偏色问题, 但整体对比度范围较小, 效果类似RTX VIDEO HDR, 但B的效果更强更好一些, 适合转制真人影视
C在B的基础上加大了参数力度, 能发挥高亮显示器的优点, 但可能会整体偏亮, 颜色偏浓艳, 可以使用Tweak(-0,0.8,0,1)降低一下饱和度, 适合转制动画影视
D借用了别人做的BT709_to_PQ的lut曲线, 效果完全取决于该曲线, 目前的版本(3.0)有严重的偏色问题, 亮部比A弱, 中间调跟A差不多, 暗部比AB都更亮

我的总结:
A最符合HDR的定义, 但是偏色问题我还没有找到解决办法
B和C都有不错的转换效果, 不对比很难察觉出区别, 所以真人影视可以用B, 动画影视用C
D只是借用了别人的劳动成果来快速转换, 毕竟很多专业软件都支持lut, 如果有更好的lut文件, 转换起来会更加方便

测试视频下载地址: (未更新新方法C)
百度网盘: https://pan.baidu.com/s/1QrHDtxHt51Vu18NUJdu0Vw?pwd=v71t
阿里云盘: https://www.alipan.com/s/S6yxtBDm8kU 提取码: 5fb6
移动云盘: https://caiyun.139.com/m/i?2nc6q8zRBjudp 提取码:9pdw
博客视频除电影外均为本人压制 转载请注明来源
如有疑问可以到微博或B站联系我, 链接在右上角