— FFmpeg, Video Editing, Frame Rate — 1 min read
FFmpeg is a powerful command-line tool that can manipulate various aspects of video and audio files. One common task is altering the frame rate (FPS) of a video.
Frame rate determines the smoothness of a video. A higher frame rate means more frames per second, resulting in a smoother playback. Common frame rates include 24 fps for films, 25 fps for PAL video, and 30 fps for NTSC video.
The fundamental command to change the frame rate using FFmpeg is:
1ffmpeg -i input.mp4 -r new_fps output.mp4
new_fps
with the target frame rate.Example:
To convert a 60 fps video to 30 fps:
1ffmpeg -i input_60fps.mp4 -r 30 output_30fps.mp4
While the basic command works for simple frame rate changes, you might need more control in specific scenarios.
fps
FilterFor finer control over frame rate conversion, use the fps
filter:
1ffmpeg -i input.mp4 -filter:v fps=new_fps output.mp4
To maintain video quality during frame rate conversion, consider using the -crf
option for constant rate factor encoding:
1ffmpeg -i input.mp4 -r new_fps -c:v libx264 -crf 23 output.mp4
The -crf
value ranges from 0 (lossless) to 51 (highest compression). A value of 23 is often a good starting point for balancing quality and file size.
To ensure audio synchronization, you can copy the audio stream without re-encoding:
1ffmpeg -i input.mp4 -c:a copy -r new_fps output.mp4