How to add the timestamp as a part of the generated image file name in ffmpeg

柔情痞子 提交于 2019-12-02 17:35:36

问题


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:


For the output filename pattern you can use:

ffmpeg -i ... -f image2 -strftime 1 "%Y-%m-%d_%H-%M-%S.png"


来源:https://stackoverflow.com/questions/33473627/how-to-add-the-timestamp-as-a-part-of-the-generated-image-file-name-in-ffmpeg

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!