我正在尝试从视频中提取每 30 帧并向其中添加文本,然后输出为 jpg。这是我正在使用的代码:
ffmpeg -i test.mp4 -vf "select=not(mod(n\,30)), drawtext=fontfile='C\:\\Windows\\Fonts\\arial.ttf:text='test':fontcolor=white:fontsize=45:x=(main_w/2-text_w/2):y=1800:" -vsync vfr -q:v 2 img_%03d.jpg
选择的第一帧输出为 img_batch3d.jpg,然后这是我得到的错误消息:
[image2 @ 00000146e59d0500] Could not get frame filename number 2 from pattern 'img_batch3d.jpg' (either set update or use a pattern like %03d within the filename pattern)
av_interleaved_write_frame(): Invalid argument
请帮忙。
最佳答案
你必须逃离 %
在 Windows 批处理文件中,所以更改 img_%03d.jpg
至img_%%03d.jpg
.
见 Batch files - Escape Characters .
关于batch-file - ffmpeg使用drawtext并一起选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49183363/