如何在ffmpeg中添加时间戳作为生成的图像文件名的一部分 [英] How to add the timestamp as a part of the generated image file name in ffmpeg

查看:2311
本文介绍了如何在ffmpeg中添加时间戳作为生成的图像文件名的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用ffmpeg从视频中提取png图像,并将时间戳作为生成的图像文件名称的一部分添加。

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.

请参阅以下命令I正在使用相同的

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]无法从
pattern获取帧文件名2。 /compare_multiple_10_09_58_490.png'(设置updatefirst
或使用文件名模式中的%03d模式)
av_interleaved_write_frame():无效的参数帧= 10 fps = 0.0
q = -0.0 Lsize = N / A时间= 00:00:00.12比特率= N / A视频:1047kB音频:0kB
字幕:0kB其他流:0kB全局头文件:0kB多路复用开销:
未知转换失败!

[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!


推荐答案

对于可以使用的输出文件名模式:

For the output filename pattern you can use:

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

这篇关于如何在ffmpeg中添加时间戳作为生成的图像文件名的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆