Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using ffmpeg to change framerate

Tags:

ffmpeg

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

like image 495
J Brand Avatar asked Aug 02 '17 13:08

J Brand


People also ask

How do I change fps in FFmpeg?

How to change the frame rate. There are two ways to change the output frame rate: With the -r option used as an output option. With the ​fps filter.

How can I change the framerate of an mp4 video?

Click the Video tab for options to change the video output. Use the "Framerate (FPS)" drop-down menu to select a new frame rate. A good average frame rate is between 24-30 frames per second. Anything lower than 20 frames-per-second will result in choppy videos motion.

How do I speed up a video with FFmpeg?

Speeding up/slowing down video This can be done via two methods: using the ​setpts video filter (which requires re-encoding) or by erasing the timestamps by exporting the video to a raw bitstream format and muxing to a container while creating new timestamps.


1 Answers

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 
like image 150
Gyan Avatar answered Oct 05 '22 02:10

Gyan