Changes between Initial Version and Version 1 of ChangingFrameRate


Ignore:
Timestamp:
Oct 12, 2018, 11:53:18 AM (14 months ago)
Author:
slhck
Comment:

create fps guide

Legend:

Unmodified
Added
Removed
Modified
  • ChangingFrameRate

    v1 v1  
     1{{{
     2#!html
     3<h1 style="font-size: 22px;">
     4Changing the frame rate
     5</h1>
     6}}}
     7
     8[[PageOutline(1, Contents)]]
     9
     10ffmpeg can be used to change the frame rate of an existing video, such that the output frame rate is lower or higher than the input frame rate. The output duration of the video will stay the same.
     11
     12This is useful when working with, for example, high-framerate input video that needs to be temporally scaled down for devices that do not support high FPS.
     13
     14When the frame rate is changed, ffmpeg will drop or duplicate frames as necessary to achieve the targeted output frame rate. A detailed explanation of how ffmpeg decides to drop/duplicate frames is [https://superuser.com/a/843363/48078 given in this post].
     15
     16{{{
     17#!div style="border: 1px solid #e5e5c7; margin: 1em; background-color: #ffd;"
     18'''Note:''' Changing frame rates requires the video to be re-encoded. Without setting appropriate output quality or bit rate, the video quality may be degraded. Please look at the respective encoding guides for the codec you've chosen.
     19}}}
     20
     21If you are interested in keeping the number of frames, but squeezing / stretching the video, see: [[How to speed up / slow down a video]]
     22
     23= How to change the frame rate =
     24
     25There are two ways to change the output frame rate:
     26
     271. With the `-r` option used as an output option
     282. With the [http://ffmpeg.org/ffmpeg-filters.html#fps fps filter]
     29
     30There are minor differences in implementation of those two;  particularly, `-r` as an output option applies to all streams, whereas `fps` can be set for each stream individually within complex filter chains. In the following we will focus on using the `fps` filter, as it is more configurable.
     31
     32== Example ==
     33
     34To change the output frame rate to 30 fps, use the following command:
     35
     36{{{
     37ffmpeg -i <input> -filter:v fps=fps=30 <output>
     38}}}
     39
     40If the input video was 60 fps, ffmpeg would drop every other frame to get 30 fps output.
     41
     42= Verifying frame rate changes =
     43
     44In order to verify which frames are duplicated or dropped by a frame rate change, you can first generate a sample video:
     45
     46{{{
     47ffmpeg -f lavfi -i testsrc=duration=10:size=854x480:rate=60 \
     48-vf "drawtext=text=%{n}:fontsize=72:r=60:x=(w-tw)/2: y=h-(2*lh):fontcolor=white:box=1:boxcolor=0x00000099" test.mp4
     49}}}
     50
     51This 10 second, 60 fps video called `test.mp4` will show the frame count at the bottom, and a second counter in the middle of the frame. By playing the output in a player that allows seeking frame-by-frame, you can inspect which frames have been dropped or duplicated.