How to add the timestamp as a part of the generate

2019-03-06 15:14发布

I am trying to extract png images from a video using ffmpeg and add the timestamp as a part of the generated image file name.

Please see the below command I am using for the same

ffmpeg -vcodec mpeg2video -f mpegts -i test_movie.ts -f image2 -vf "drawtext=fontfile=/Library/Fonts/Tahoma.ttf: timecode='$(date +%H\\:%M\\:%S).00': r=30: x=(w-tw)/2: y=h-(2*lh): fontcolor=white: box=1: boxcolor=0x00000000@1" -vsync vfr -pattern_type glob ./compare_multiple_$(gdate +%H\_%M\_%S_%3N).png

But this is not appending the filename properly. It gives an error as shown below:

[image2 @ 0x7ff01301f600] Could not get frame filename number 2 from pattern './compare_multiple_10_09_58_490.png' (either set updatefirst or use a pattern like %03d within the filename pattern) av_interleaved_write_frame(): Invalid argument frame= 10 fps=0.0 q=-0.0 Lsize=N/A time=00:00:00.12 bitrate=N/A video:1047kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown Conversion failed!

1条回答
甜甜的少女心
2楼-- · 2019-03-06 15:32

For the output filename pattern you can use:

ffmpeg -i ... -f image2 -strftime 1 "%Y-%m-%d_%H-%M-%S.png"
查看更多
登录 后发表回答