I have no knowledge whatsoever about video encoding, I have an application written in OpenGL and I am saving the frames it generated into png images. The frames from my app are at 7 FPS and I am trying to create a video from those.

To that purpose I use ffmpeg like this

ffmpeg -framerate 30 -i img%03d.png -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4

which was taken from this site, however I was wondering if it is possible to have a video that shows the animation at 30 FPS?


I'm using the below code to do the same thing.

ffmpeg -framerate 30 -i img%03d.png -c:v libx264 -pix_fmt yuv420p -crf 23 output.mp4

Breaking down the command:

ffmpeg             <- call ffmpeg
  -framerate 30    <- set the input framerate to 30
  -i img%03d.png   <- read PNG images with filename img001, img002, img003, etc..
                     img can be changed to another prefix
                     %03d can be changed to %04d for 0001, %05d for 00001 formats, etc...
  -c:v libx264     <- Set the codec to libx264
  -pix_fmt yuv420p <- Set the pixel format to planar YUV 4:2:0, 12bpp
  -crf 23          <- set the Constant Rate Factor to 23 (default value)
  -output.mp4      <- the output filename

This reads the input at 30 fps (the -framerate 30 option) and encodes it using the libx264 codec with constant rate factor of 23 (the -crf 23 option).

  • How do you compute the -crf value? What does it represent compared to the 30 fps and 7 frames per second in the source? (i.e. is it "30 - 7 = 23"?) Oct 3 at 17:28
  • It's not related to the fps (I think). Did you read the linked page about the constant rate factor (crf)? Oct 3 at 19:24
  • Oh, yeah, so I really don't understand how your answer was chosen as the answer. It's wrong. In OP's question, the input FPS is 7 and the output 30. You are not taking care of that in your examples. Oct 4 at 0:08
  • Thanks for trying to improve my answer. I don't entirely follow, Could you perhaps explain what is not being addressed? The question asker wants a video that plays 30 of their frames per second. The command in my answer outputs 30 frames per second. The framerate at which the frames are captured (7) seems not relevant, right? Oct 4 at 5:48
  • Assuming you count from 1, frames 1 to 7 from the input have to be played in 1 second (spread over 30 frames in the output video). Then frames 8 to 15 will be played on the 2nd second of the output video. Etc. I think that with your command line you will end up playing 30 frames of input in 1 second (a little over 4 times too fast). Oct 4 at 16:26

Image inputs

Default frame rate for image inputs is 25. You can change it with the -framerate input option. Example for 24 fps:

ffmpeg -framerate 24 -i input_%03d.jpg -vf format=yuv420p output.mp4
  • -vf format=yuv420p (or the legacy alias -pix_fmt yuv420p) will ensure compatible chroma subsampling for MP4. Otherwise, ffmpeg will try to preserve color fidelity, but most players can't handle advanced chroma subsampling.
  • The output will use the same frame rate as the input. So you do not need to set an output frame rate. But there are a few reasons to do so. See Using a different frame rate for image inputs and video output below.

Video inputs

Use the -r output option:

ffmpeg -i input.mp4 -r 25 output.mp4

Using a different frame rate for image inputs and video output

Why? For example, you may want all images to be displayed for 1 second each (1 fps). But most players can't play very low frame rates (about 6 fps or lower). So you can make ffmpeg use a different output frame rate. The output will look like 1 fps, but will actually be a normal frame rate, such as 25 fps.

Example: input images at 1 fps, but make the output 25 fps.

ffmpeg -framerate 1 -i input_%03d.png -r 25 output.mp4
  • Frames will be duplicated or dropped to match the desired output frame rate.
  • The image demuxer uses -framerate, while the output frame rate is set using -r.

Error: Option framerate not found

The -framerate option:

  • Is not a generic option. It doesn't work for everything.
  • Is only an input option.
  • Only works with certain demuxers (including: images, x11grab, rawvideo).
  • You probably only need to use the -r output option. See the Video inputs section above.
  • 2
    ffmpeg version 3.2.2 tells me: Option framerate not found. :-(
    – erik
    Jan 4 '17 at 11:26
  • Yes, you are right. But nevertheless the option -framerate does not exist anymore. I will delete my comment, as it really has nothing to do with converting a series of images to a video with a certain framerate.
    – erik
    Jan 4 '17 at 21:24
  • 5
    @erik -framerate does exist. It's used by the image and rawvideo demuxers and some input devices such as x11grab and v4l2.
    – llogan
    Jan 4 '17 at 22:33
  • 2
    Where is the option -framerate documented? I've read the man ffmpeg page, but I couldn't find it. Any pointer, perhaps?
    – Atcold
    Feb 27 '17 at 17:02
  • 3
    OK, found it... FFMPEG-DEVICES(1).
    – Atcold
    Feb 27 '17 at 17:12
ffmpeg -framerate 30 -i img%03d.png output.mp4  

will be sufficient in the latest version of ffmpeg.

  • Dont forget the -pix_fmt yuv420p or you may end up with files that many software tools don't like: trac.ffmpeg.org/ticket/8856
    – bers
    Aug 19 '20 at 7:18
  • I don't see how that would be sufficient since the input is at 7 fps. That frame rate has to appear somewhere. Oct 3 at 17:33

You are talking about video interpolation. There is no way for 7 fps to become 30 fps without video interpolation... Basically you want to get 30fps from the start, in the process of making videos... As video interpolation will take lots of resources and time, and it might be filled with artifacts. I heard you can make a single shot picture into a short movies, with adobe, but lots of manual work there...


It sounds like you may the resultant video to have 30 frames per second for compatibility with certain devices (e.g. a DVD player), but you want the content to play back at an effective 7 frames per second to maintain the original temporal resolution. In that case, you'll need to use an FFmpeg video filter like tblend or minterpolate to interpolate the 7 frames' worth of content to 30 frames (with varying visual changes), or use a third party application like butterflow which itself uses FFmpeg.

If you purely want the 7 fps source content to be sped up to 30 fps (shortening the playback time ~4:1) then the other -framerate based answers will suffice.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.