当前位置: 首页 > 工具软件 > Luminance HDR > 使用案例 >

x264压制4K HDR电影的vs转换脚本,由HDR到SDR

景鹏飞
2023-12-01

转载自doom9论坛

其中‘path/to/file’填写对应的视频文件

注意内存的控制,对4K电影的压制一般会要求极大的内存

import vapoursynth as vs


core = vs.get_core()
c = core.ffms2.Source(source = 'path/to/file')

source_peak=1200 #set manually


c=core.resize.Bilinear(clip=c, format=vs.YUV444PS, range_in_s="limited", range_s="full",chromaloc_in_s="center",dither_type="none")

c=core.resize.Bilinear(clip=c, format=vs.RGBS, matrix_in_s="2020ncl", range_in_s="full",dither_type="none")

c=core.resize.Bilinear(clip=c, format=vs.RGBS, transfer_in_s="st2084", transfer_s="linear",dither_type="none", nominal_luminance=source_peak)


exposure_bias=source_peak/100

#hable/uncharted tone mapping
tm = core.std.Expr(c, expr="x  {exposure_bias} * 0.15 x  {exposure_bias} * * 0.05 + * 0.004 + x  {exposure_bias} * 0.15 x  {exposure_bias} * * 0.50 + * 0.06 + / 0.02 0.30 / -  ".format(exposure_bias=exposure_bias),format=vs.RGBS)#12=1200 nits / 100 nits

w = core.std.Expr(c, expr="{exposure_bias} 0.15 {exposure_bias} * 0.05 + * 0.004 + {exposure_bias} 0.15 {exposure_bias} * 0.50 + * 0.06 + / 0.02 0.30 / -  ".format(exposure_bias=exposure_bias),format=vs.RGBS)#  


c = core.std.Expr(clips=[tm,w], expr=" x  1 y  / *  ",format=vs.RGBS)

#c=core.fmtc.primaries(clip=c, prims="2020", primd="709")
c=core.resize.Bilinear(clip=c, format=vs.RGBS, primaries_in_s="2020", primaries_s="709",dither_type="none")
c=core.resize.Bilinear(clip=c, format=vs.RGBS, transfer_in_s="linear", transfer_s="709",dither_type="none")

c=core.resize.Bilinear(clip=c, format=vs.YUV420P8, matrix_s="709", range_in_s="full",range_s="limited",chromaloc_in_s="center")


c.set_output()

 

 类似资料: