Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
share|improve this question
up vote 3 down vote accepted

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

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

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

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.

share|improve this answer
    
Thanks a lot! with some adaptations for Windows works well. but I extract all frames of movie with timstamp, I need to extract one frame every 10 seconds. I added something and now it is ok. At this moment appears on picture me hh:mm:ss:frame. Is possible to not appear after :ss the number of frame? – Bill Marc Mar 31 '13 at 23:02
    
This is the syntax I use now: ffmpeg -i video.avi -r 0.08 -f image2 -s 512x384 -vf "drawtext=fontfile=/WINDOWS/Fonts/arial.ttf: timecode='00\:00\:00\:00': r=25: x=(w-tw)/2: y=h-(2*lh): fontcolor=white: box=1: boxcolor=0x00000000@1 " video%%4d.png – Bill Marc Mar 31 '13 at 23:13
1  
@BillMarc I do no believe you can omit the display of the frame number. You may get more accurate results if you remove -r 0.08 and add ,fps=1/10 to the end of your filterchain. – LordNeckbeard Apr 1 '13 at 19:47
    
@BillMarc Of course you may try editing the source code and compiling. – LordNeckbeard Apr 1 '13 at 20:06
    
@BillMarc : could you please post the adaptation that you did to make it working in windows – csharpcoder Dec 31 '15 at 9:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .