使用ffmpeg
将一系列帧作为图像输出时,the only format I can find documentation for为frame_%d.jpg
。 %d
标识符由顺序帧计数替换。
我可以在输出文件格式中使用其他参数吗?具体来说,我需要能够添加特定帧的时间戳。
答案 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”。你可以在以下地址看到它:
答案 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"