ffmpeg文件名输出格式

时间:2011-12-17 12:41:23

标签: ffmpeg

使用ffmpeg将一系列帧作为图像输出时,the only format I can find documentation forframe_%d.jpg%d标识符由顺序帧计数替换。

我可以在输出文件格式中使用其他参数吗?具体来说,我需要能够添加特定帧的时间戳。

6 个答案:

答案 0 :(得分:6)

原来这种行为尚未实施。

我在FFmpeg(https://github.com/yuvadm/FFmpeg)的分支上实现了%t支持的初始版本,目前正在清理补丁,以便可以在上游合并。

答案 1 :(得分:3)

The strftime option允许您使用日期和时间信息扩展文件名。检查the documentation of the strftime() function的语法。

例如,要从strftime()%Y-%m-%d_%H-%M-%S模式生成图像文件,可以使用以下ffmpeg命令:

ffmpeg -f v4l2 -r 1 -i /dev/video0 -f image2 -strftime 1 "%Y-%m-%d_%H-%M-%S.jpg"

答案 2 :(得分:1)

我破解了一个bash脚本,根据时间进入电影创建文件名。它在文件名中使用格式:“hh_mm_ss”。你可以在以下地址看到它:

https://github.com/pozar/makemoviethumbs

答案 3 :(得分:0)

Another option you'd have would be to run ffprobe -show_packets on it, and use that data to "infer" the timestamp of each generated jpg file (assuming you generate one per incoming video frame). Yikes!

答案 4 :(得分:0)

对于帧数,可以使用具有特殊调试模式的报告:

FFREPORT=file=\'file.log\':level=48 && ffmpeg ... -vf select=eq(pict_type\,PICT_TYPE_I) -vsync vfr -f image2 OUTPUT

然后您可以将该名称与preg_match_all匹配:

preg_match_all("/] n:(\\d+)\\.[^>]+pict_type:I/Us",$log,$m,PREG_PATTERN_ORDER,5000);
$frames=$m[1];

请享受!

答案 5 :(得分:0)

如果要附加纪元,可以尝试使用 -strftime %s

示例:

ffmpeg -rtsp_transport tcp -i 'input.mp4' -vf fps=1 -strftime 1 "%s_frame.png"