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

How can I make a simple capture from a video. Preferably from the command line?

Idea: take 9 snapshots for 9 even placed (on the timeline) times, and save them as JPGs


Movie length = 10 min
T1= snapshot of 1 min
T2= snapshot of 2 min
T9= snapshot of 9 min
   |   |
 T1| T2| T3
 T4| T5| T6
 T7| T8| T9
   |   |

What's the best program to do this? Are there any opensource programs?

share|improve this question

ffmpeg is an excellent open source tool for manipulating videos, including extracting frames.

To extract single frame from specific timestamp you can use command like

ffmpeg -i video.avi -r 1  -t 00:01:00 -f image2 image%05d.png

-r is framerate. You can also use command like

ffmpeg -i video.avi -r 1/1440 -f image2 image%05d.png

to get one frame every one minute (assuming 24FPS video). The %05d means that ordinal number of each thumbnail image should be formatted using 5 digits.

If you want to combine images as montage (your grid), you can use imagemagick after extracting frames using ffmpeg.

share|improve this answer

It's not a command line program, but you may also use qframecatcher.

For ubuntu/debian the requirements are: sudo apt-get install libqt4-dev libxine-dev build-essential

tar xzf qframecatcher-0.4.1.tar.gz
cd qframecatcher/src


share|improve this answer

My use-case is just one thumbnail from a video, just a single file to use as a <video> tag poster. So, what would be a fast way to make this?

With ffmpeg, you can do this:

ffmpeg -ss 123 -y -i video.mp4 -r 1 -updatefirst 1 -frames 1 poster.jpg

That will give you the frame near second 123 of the video.mp4 saved as poster.jpg.

The problem, as you can see, is that we need to know which second is right.

In order to keep our dependencies low, we'll use ffmpeg itself for this:

# Get the time as h:m:s (non-padded)
l=$(ffmpeg -i video.mp4 2>&1 | grep Duration: | sed -r 's/\..*//;s/.*: //;s/0([0-9])/\1/g')
# Convert that into seconds
s=$((($(cut -f1 -d: <<< $l) * 60 + $(cut -f2 -d: <<< $l)) * 60 + $(cut -f3 -d: <<< $l)))
# Get frame at 25% as the thumbnail
ffmpeg -ss $((s / 4)) -y -i video.mp4 -r 1 -updatefirst 1 -frames 1 poster.jpg

25% of the video seems like a common choice, but you can make it 33% or 50% too.

Here's a script that does this.

share|improve this answer

You must log in to answer this question.

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