Using ffmpeg to change framerate

ffmpeg change frame rate without dropping frames
ffmpeg change frame rate without 're encoding
ffmpeg change frame rate without changing speed
ffmpeg change frame rate and duration
ffmpeg fps
ffmpeg constant frame rate
ffmpeg framerate vs r
ffmpeg fps filter

I am trying to convert a video clip (MP4, yuv420p) from 30 fps to 24 fps. The number of frames is correct so my output should change from 20 minutes at 30fps to 25 minutes at 24fps. Everything else should remain the same.

Try as I might everything I try with ffmpeg converts the frame rate but changes the number of frames to keep the same duration or changes the duration without altering the framerate.

So I have been typically trying things like;

ffmpeg -y -r 30 -i seeing_noaudio.mp4 -r 24 seeing.mp4

(I'm doing this on windows but normally would be on linux). That converts the framerate but drops frames so the total duration is unaltered.

Or I have tried

ffmpeg -y -i seeing_noaudio.mp4 -filter:v "setpts=1.25*PTS" seeing.mp4

Which changes the duration but not the framerate.

Surely I should be able to do this with a single ffmpeg command without having to reencode or even as some people suggested going back to the original raw frames.

Help please

With re-encoding:

ffmpeg -y -i seeing_noaudio.mp4 -vf "setpts=1.25*PTS" -r 24 seeing.mp4

Without re-encoding:

First step - extract video to raw bitstream

ffmpeg -y -i seeing_noaudio.mp4 -c copy -f h264 seeing_noaudio.h264

Remux with new framerate

ffmpeg -y -r 24 -i seeing_noaudio.h264 -c copy seeing.mp4

Using ffmpeg to change framerate, With re-encoding: ffmpeg -y -i seeing_noaudio.mp4 -vf "setpts=1.25*PTS" -r 24 seeing.mp4. Without re-encoding: First step - extract video to  Basically, frame rate as an input option will make ffmpeg ignores the original frame rate of the video and use the designated frame rate without adding or dropping frames. If the frame rate of your source is variable, the above method may work but the video may speed up or slow down intermittently due to variable nature of the frame rate.

Simply specify the desired framerate in "-r " option before the input file:

ffmpeg -y -r 24 -i seeing_noaudio.mp4 seeing.mp4

Options affect the next file AFTER them. "-r" before an input file forces to reinterpret its header as if the video was encoded at the given framerate. No recompression is necessary. There was a small utility avifrate.exe to patch avi file headers directly to change the framerate. ffmpeg command above essentially does the same, but has to copy the entire file.

Change frame rate without changing film speed/duration, To change the frame rate without modifying the total length of the video, FFmpeg has to duplicate or drop some frames. Unfortunately this process can turn a  Using ffmpeg to change framerate. I am trying to convert a video clip (MP4, yuv420p) from 30 fps to 24 fps. The number of frames is correct so my output should change from 20 minutes at 30fps to 25 minutes at 24fps.

To the best of my knowledge you can't do this with ffmpeg without re-encoding. I had a 24fps file I wanted at 25fps to match some other material I was working with. I used the command ffmpeg -i inputfile -r 25 outputfile which worked perfectly with a webm,matroska input and resulted in an h264, matroska output utilizing encoder: Lavc56.60.100

You can accomplish the same thing at 6fps but as you noted the duration will not change (which in most cases is a good thing as otherwise you will lose audio sync). If this doesn't fit your requirements I suggest that you try this answer although my experience has been that it still re-encodes the output file.

For the best frame accuracy you are still better off decoding to raw streams as previously suggested. I use a script for this as reproduced below:

#!/bin/bash
#This script will decompress all files in the current directory, video to huffyuv and audio to PCM
#unsigned 8-bit and place the output #in an avi container to ease frame accurate editing.
for f in *
do
ffmpeg -i "$f" -c:v huffyuv -c:a pcm_u8 "$f".avi
done

Clearly this script expects all files in the current directory to be media files but can easily be changed to restrict processing to a specific extension of your choosing. Be aware that your file size will increase by a rather large factor when you decompress into raw streams.

How to change framerate with ffmpeg without re-encoding?, This can't normally be done, but luckily for you, MJPEG is a codec for which streamcopy + piping can work ffmpeg -i in.avi -c copy -f image2pipe  The command ffmpeg -codecs will print every codec FFmpeg knows about. The output of this command will change depending on the version of FFmpeg you have installed. The output of this command will change depending on the version of FFmpeg you have installed.

You can use this command and the video duration is still unaltered.

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

FFmpeg to the Rescue: Converting 60 fps to 30 fps – Streaming , To make a long story short, in FFmpeg-speak, I didn't want to change the frame rate, I wanted to slow the video down, which you do with the  I'd like to use FFmpeg to change the speed of a video, which I thought would have been easy enough by forcing the framerate. For example, a PAL DV video with framerate of 25fps, changed to 50fps should play back twice as fast, and be half the duration.

You may consider using fps filter. It won't change the video playback speed:

ffmpeg -i <input> -filter:v fps=fps=30 <output>

Worked nice for reducing fps from 59.6 to 30.

Changing video framerate with FFmpeg – corbpie, Changing a videos frame rate can be easily done with FFmpeg. From the official FFmpeg documentation to change frame rate is required. ffmpeg will automatically determine the frame rate of the input, and if you simply want to output all images adding a frame rate option is not needed or recommended. – llogan May 23 '16 at 16:12 @LordNeckbeard when I run this script without -r option on some videos I get very big number of images, more than frame_rate*number_of_seconds. – mrgloom May 23 '16 at 16:37

Is There A Way Of Changing The Framerate Without Dropping , 31.25-second video, running at 23.976fps, containing the exact same sequence of 750 frames, just playing at a slower rate. Can I do that with ffmpeg? How to change video fps from 29.970 to 25?. Hello, from a couple of days I am fighting with problem of fps conversion with ffmpeg. I discovered that conversion from 23.976fps to 25fps is easy and we

ffmpeg - ffmpeg video converter, Filtering Before encoding, ffmpeg can process raw audio and video frames using E.g. the "fps" filter in the example above changes number of frames, but does not If multiple loglevel parameters are given, using 'repeat' will not change the​  Without the use of specific filters, ffmpeg can only duplicate or drop frames when the framerate is changed. Is there any better option other than the above command to 'smoothly' raise the fps? ffmpeg now has a motion interpolation filter, which will generate new frames.

change frame rate, convert in a movie. I use happily the command ffmpeg -i still%04d.jpg -vcodec mjpeg -qscale 1 -r 30 -an out_mjpg.avi The only way I got it working is ffmpeg -r 10 -i video.avi -vsync 0 output.mp4, but this encodes the output with mpeg4. If I use -vcodec copy, the -r 10 looses its power. The PTS rescaling method creates and drops frames. I do not care about timestamps, I want a file with all of the input frames at a fixed (higher) frame rate.

Comments
  • Thanks for that. The first of those worked but the second didn't returning an error message along the lines of "Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument". I've no idea what that meant but the first one worked.
  • Looks like the video codec is not H.264. Which is it?
  • -filter:v fps OR -r fps. which one is preferred?
  • Generally, -r. Use the filter when you need to change framerate before applying further filters.
  • It looks promising, but I'm getting "Timestamps are unset in a packet for stream 0." and "pts has no value" warnings, and the resulting video is very choppy, as if it was playing two steps forward and one step back.
  • Neither answer works for me with a VP8 WebM file (which I'm trying to slow down from 25 fps to 6fps without re-encoding). Output video is same as input.
  • This doesn't change the frame rate of the output file at all for me.
  • If you do this your video will be cut off. You should specify the -r parameter before the input file.
  • @zenw0lf cut off how? I tested this and it worked fine. It's documented on ffmpeg's website.