What's the meaning of ffmpeg's fps options?

4

3

I'm trying to catch some snapshots from a video. So I found this code in their official page:

ffmpeg -i myvideo.avi -f image2 -vf fps=fps=1/60 img%03d.jpg

but, I can not find any documentation about options and they never explain it.

So if you know some reference or documentations about ffmpeg options, please share.

The main question of this post is what image2 -vf fps=fps=1/60 means. I cannot understand why they just write like fps=1/60. And image2 is some kind of option or what?

What's the difference to the following?

ffmpeg -i filename.avi -ss 00:00:01 -r 1/60 image%03d.png

Juneyoung Oh

Posted 2013-04-19T01:32:02.250

Reputation: 547

Answers

8

You can find the documentation on the FFmpeg homepage.

The fps filter has multiple options, one being fps. So, to declare that option, you have to call:

-vf fps=fps=1/60
     ↑   ↑   ↑
     |   |   |
     |   |   |__ value
     |   |______ option
     |__________ filter

You could also write -vf fps="fps=1/60", of course.

So, when you use 1/60 that means 1/60 frames per second, or 1 frame per 60 seconds. In any case the difference between this and -r 1/60 is that a filter is applied before any -r option. Both commands you gave should work in theory, however the -r one creates too many output frames for me (but I'm not the first one to notice). Stick with the fps filter.


Note that there is another filter called framerate, which is similar to fps, but not the same. Instead of duplicating or dropping frames to achieve the target framerate, it will interpolate frames, i.e. merging adjacent frames to create new images.


If you dissect the command you will find that image2 is the option value of -f. This specifies the output format. In general, you can use it in ffmpeg like this:

ffmpeg -f input-format -i input-file -f output-format output-file

In your example, we told ffmpeg to use the image2 muxer, which allows you to output single image files from video, by specifying a pattern like %02d for the output name.

The -f image2 is superfluous here as the muxer should be chosen automatically when you use an image output format.

The image2 demuxer also has a framerate option that allows you to specify the assumed input file framerate. For example, if you have a slideshow that consists of one picture every second, use -framerate 1 as an input option. See here for some examples.

slhck

Posted 2013-04-19T01:32:02.250

Reputation: 182 472

Thank you so much:D i don't even know there's filter option! – Juneyoung Oh – 2013-04-21T13:13:36.873

-vf and -filter:v mean the same, but it's more apparent that it's a filter with the -filter one, of course. I had a talk with someone on the FFmpeg mailing list and they also said that -r shouldn't be used to set the frame rate for the output. -filter:v fps is preferred. – slhck – 2013-04-21T13:16:44.353

@slhck As a trivial and mostly unrelated side note, ffplay doesn't seem to like -filter:v compared to -vf (but it has been a while since I've tried due to travel). – llogan – 2013-04-28T16:10:37.383