我正在尝试使用以下ffmpeg命令将HDR转换为SDR,该命令可以工作
ffmpeg -i input.mov -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,format=yuv420p -c:v libx264 -crf 0 -preset ultrafast -tune fastdecode output.mp4但是,我很难用ffmpeg-python格式转换它。你能给我指导如何处理分号,等于和奇怪==情况?
ffmpeg.input("input.mov", r=fps).filter('zscale', t='linear:npl').filter('format', 'gbrpf32le') ...发布于 2022-08-23 09:01:56
转换非常简单:
ffmpeg.input('input.mov')\
.video.filter('zscale', t='linear', npl=100)\
.filter('format', pix_fmts='gbrpf32le')\
.filter('zscale', p='bt709')\
.filter('tonemap', tonemap='hable', desat=0)\
.filter('zscale', t='bt709', m='bt709', r='tv')\
.filter('format', pix_fmts='yuv420p')\
.output('output.mp4', vcodec='libx264', crf=0, preset='ultrafast', tune='fastdecode')\
.run()arguments.
.video的.filter(...).filter(...).filter(...),应用视频语法是=param_value0,=param_value0从输出文件名开始,后面跟着输出参数。
唯一的警告是format过滤器。
format过滤器的参数名是pix_fmts (我们通常跳过它)。
获取参数名称的一种方法是使用FFmpeg帮助(在命令行中):
ffmpeg -h filter=format
输出:
Filter format
Convert the input video to one of the specified pixel formats.
Inputs:
#0: default (video)
Outputs:
#0: default (video)
(no)format AVOptions:
pix_fmts <string> ..FV....... A '|'-separated list of pixel formats这里我们可以看到参数名是pix_fmts。
当使用ffmpeg-python时,建议添加.overwrite_output() (等效于-y参数)。
对于测试,建议添加用于创建日志文件的.global_args('-report') (在完成测试后删除.global_args('-report') )。
ffmpeg.input('input.mov')\
.video.filter('zscale', t='linear', npl=100)\
.filter('format', pix_fmts='gbrpf32le')\
.filter('zscale', p='bt709')\
.filter('tonemap', tonemap='hable', desat=0)\
.filter('zscale', t='bt709', m='bt709', r='tv')\
.filter('format', pix_fmts='yuv420p')\
.output('output.mp4', vcodec='libx264', crf=0, preset='ultrafast', tune='fastdecode')\
.global_args('-report').overwrite_output().run()日志显示了实际的FFmpeg命令:
ffmpeg -i input.mov -filter_complex "[0:v]zscale=npl=100:t=linear[s0];[s0]format=pix_fmts=gbrpf32le[s1];[s1]zscale=p=bt709[s2];[s2]tonemap=desat=0:tonemap=hable[s3];[s3]zscale=m=bt709:r=tv:t=bt709[s4];[s4]format=pix_fmts=yuv420p[s5]" -map "[s5]" -crf 0 -preset ultrafast -tune fastdecode -vcodec libx264 output.mp4 -report -y
如您所见,ffmpeg-python使用-filter_complex而不是-vf,并使用临时命名为[s0]、[s1]、[s2].
结果相当于您的原始命令。
https://stackoverflow.com/questions/73453248
复制相似问题