ffmpeg using drawtext and select together

时间:2018-03-08 22:13:11

标签: batch-file ffmpeg

I'm trying to extract every 30th frame from a video and add text to it, and output as a jpg. Here's the code I'm using:

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

The first frame selected outputs as img_batch3d.jpg, then this is the error message I get:

[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

Please help.

1 个答案:

答案 0 :(得分:0)

您必须转义Windows批处理文件中的%,因此请将img_%03d.jpg更改为img_%%03d.jpg

请参阅Batch files - Escape Characters