Can FFMPEG extract images from a video with timestamps?
I'm trying to extract frames from a video and get the exact timestamps of each frame extracted (on a picture).
To extract frames from video without timestamps I use this syntax:
ffmpeg -i video.wmv -r 0.08 -f image2 -s 512x384 video2%%4d.jpg
You can do this with the drawtext
filter. Your build will need to be compiled with --enable-libfreetype
. Most static builds of ffmpeg
for Windows and Linux appear to support this filter. See the FFmpeg download page for links.
timestamp
duration
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
current time
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
timecode
PAL 25 fps non drop frame:
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
This is adapted from the Burnt in Timecode example in the FFmpeg Wiki. The r
option will set the timecode frame rate.