user6807: 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?

user32472: 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...

user22836: ffmpeg -framerate 30 -i img%03d.png output.mp4  

will be sufficient in the latest version of ffmpeg.

user2178: 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).

user1760: 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.


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

<p>To that purpose I use ffmpeg like this</p>

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

<p>which was taken <a href="https://trac.ffmpeg.org/wiki/Create%20a%20video%20slideshow%20from%20images">from this site</a>, however I was wondering if it is possible to have a video that shows the animation at 30 FPS?</p>
 32472: <p>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...</p>
 22836: <pre><code>ffmpeg -framerate 30 -i img%03d.png output.mp4  
</code></pre>

<p>will be sufficient in the latest version of ffmpeg.</p>
 2178: <p>I'm using the below code to do the same thing.</p>

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

<p>Breaking down the command:</p>

<pre><code>ffmpeg             &lt;- call ffmpeg
  -framerate 30    &lt;- set the input framerate to 30
  -i img%03d.png   &lt;- 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     &lt;- Set the codec to libx264
  -pix_fmt yuv420p &lt;- Set the pixel format to planar YUV 4:2:0, 12bpp
  -crf 23          &lt;- set the Constant Rate Factor to 23 (default value)
  -output.mp4      &lt;- the output filename
</code></pre>

<p>This reads the input at 30 fps (the <code>-framerate 30</code> option) and encodes it using the <code>libx264</code> codec with <a href="https://trac.ffmpeg.org/wiki/Encode/H.264#crf" rel="noreferrer">constant rate factor</a> of 23 (the <code>-crf 23</code> option).</p>
 1760: <h1>Image inputs</h1>
<p>Default frame rate for image inputs is 25. You can change it with the <code>-framerate</code> input option. Example for 24 fps:</p>
<pre><code>ffmpeg -framerate 24 -i input_%03d.jpg -vf format=yuv420p output.mp4
</code></pre>
<ul>
<li><code>-vf format=yuv420p</code> (or the legacy alias <code>-pix_fmt yuv420p</code>) will ensure compatible <a href="https://en.wikipedia.org/wiki/Chroma_subsampling" rel="noreferrer">chroma subsampling</a> for MP4. Otherwise, <code>ffmpeg</code> will try to preserve color fidelity, but most players can't handle advanced chroma subsampling.</li>
<li>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 <em>Using a different frame rate for image inputs and video output</em> below.</li>
</ul>
<h1>Video inputs</h1>
<p>Use the <code>-r</code> output option:</p>
<pre><code>ffmpeg -i input.mp4 -r 25 output.mp4
</code></pre>
<hr />
<h2>Using a different frame rate for image inputs and video output</h2>
<p>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 <code>ffmpeg</code> 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.</p>
<p>Example: input images at 1 fps, but make the output 25 fps.</p>
<pre><code>ffmpeg -framerate 1 -i input_%03d.png -r 25 output.mp4
</code></pre>
<ul>
<li>Frames will be duplicated or dropped to match the desired output frame rate.</li>
<li>The <a href="https://ffmpeg.org/ffmpeg-formats.html#image2-1" rel="noreferrer">image demuxer</a> uses <code>-framerate</code>, while the output frame rate is set using <code>-r</code>.</li>
</ul>
<h3>Error: Option framerate not found</h3>
<p>The <code>-framerate</code> option:</p>
<ul>
<li>Is not a generic option. It doesn't work for everything.</li>
<li>Is only an input option.</li>
<li>Only works with certain <a href="https://ffmpeg.org/ffmpeg-formats.html" rel="noreferrer">demuxers</a> (including: images, x11grab, rawvideo).</li>
<li>You probably only need to use the <code>-r</code> output option. See the <em>Video inputs</em> section above.</li>
</ul>
