FFMPEG 可以从带有时间戳的视频中提取图像吗?

Bil*_*arc 5 ffmpeg

我正在尝试从视频中提取帧并获取提取的每个帧的确切时间戳(在图片上)。

要从没有时间戳的视频中提取帧,我使用以下语法:

ffmpeg -i video.wmv -r 0.08 -f image2 -s 512x384 video2%%4d.jpg
Run Code Online (Sandbox Code Playgroud)

llo*_*gan 7

您可以使用drawtext过滤器执行此操作。您的构建将需要使用--enable-libfreetype. ffmpegWindows 和 Linux 的大多数静态构建似乎都支持此过滤器。有关链接,请参阅FFmpeg 下载页面。

时间戳

期间

期间

ffmpeg -i input -vf "drawtext=fontfile=/usr/share/fonts/TTF/Vera.ttf: text='%{pts\:hms}': x=(w-tw)/2: y=h-(2*lh): fontcolor=white: box=1: boxcolor=0x00000000@1" image%03d.png
Run Code Online (Sandbox Code Playgroud)

当前时间

当前时间

ffmpeg -i input -vf "drawtext=fontfile=/usr/share/fonts/TTF/Vera.ttf: text='%{localtime}': x=(w-tw)/2: y=h-(2*lh): fontcolor=white: box=1: boxcolor=0x00000000@1" image%03d.png
Run Code Online (Sandbox Code Playgroud)

时间码

时间码

PAL 25 fps 非丢帧:

ffmpeg -i input -vf "drawtext=fontfile=/usr/share/fonts/TTF/Vera.ttf: timecode='00\:00\:00\:00': r=25: x=(w-tw)/2: y=h-(2*lh): fontcolor=white: box=1: boxcolor=0x00000000@1" image%03d.png
Run Code Online (Sandbox Code Playgroud)

这改编自FFmpeg Wiki 中Burnt in Timecode示例。该选项将设置时间码帧速率。r