
In the world of video editing, one of the most common tasks is changing the framerate of a video. However, doing so often requires reencoding, which can degrade the quality of the video. In this article, we’ll explore how to change the video framerate without reencoding, using tools like MP4Box and MKVmerge GUI.
Understanding Framerate
Before we dive into the methods, let’s first understand what framerate is. Framerate, or frames per second (fps), is the frequency at which consecutive images called frames appear on a display. The term applies equally to film and video cameras, computer graphics, and motion capture systems.
Method 1: Using MP4Box
MP4Box is a multimedia packaging tool, which can manipulate MP4 files without reencoding. It can extract the video stream as a raw file, change its framerate, and then remux it back into an MP4 file.
Here’s an example command:
MP4Box -add SourceMovie.mp4#video -raw 1 -new test
MP4Box -add test_track1.h264:fps=30 -new DestMovie.mp4
In the first command, -add
is used to specify the source file, SourceMovie.mp4#video
extracts the video stream, -raw 1
extracts the video stream as a raw file, and -new test
creates a new file named test
.
In the second command, -add
is used to specify the raw file, test_track1.h264:fps=30
changes the framerate to 30 fps, and -new DestMovie.mp4
creates the final MP4 file with the new framerate.
Method 2: Using MKVmerge GUI
If you don’t need to keep the file as an MP4, you can use MKVmerge GUI to remux the video into a Matroska container and easily change the framerate. This method only modifies the metadata and not the video stream itself.
Here are the steps:
- Install MKVmerge GUI:
sudo apt-get install mkvtoolnix-gui
- Open MKVmerge GUI and add your video file.
- Go to “Format specific actions” and change the FPS value or use the “Stretch by” option.
- Specify the output file name and start the remuxing process.
Method 3: Lossless Slow Down with Script
If you want to slow down the video without reencoding, you can use a script that combines avconv, sondstretch, and MP4Box. This method changes the sound tempo and modifies the FPS directly in the MP4 container.
Here is an example script:
#!/bin/bash
IN_FILE="$1"
NAME=$(echo "${IN_FILE}" | sed 's/\.[^.]*//')
rm -f "${NAME}.ac3" "${NAME}.wav" "${NAME}_.wav" "${NAME}" "${NAME}_track1.h264" "${NAME}_slow.mp4"
avconv -i "${IN_FILE}" -vn -acodec pcm_s16le "${NAME}_.wav"
soundstretch "${NAME}_.wav" "${NAME}.wav" -tempo=-75
avconv -i "${NAME}.wav" -vn -codec:a ac3_fixed -b:a 448k "${NAME}.ac3"
MP4Box -add "${IN_FILE}#video" -raw 1 -new "${NAME}"
MP4Box -add "${NAME}_track1.h264:fps=30" -add "${NAME}.ac3" -new "${NAME}_slow.mp4"
rm -f "${NAME}.ac3" "${NAME}.wav" "${NAME}_.wav" "${NAME}" "${NAME}_track1.h264"
This script first extracts the audio from the video file, slows down the tempo by 75%, reencodes the audio to AC3 format, extracts the video stream, changes the framerate to 30 fps, and then combines the audio and video into a new MP4 file.
Conclusion
Changing the framerate of a video without reencoding can be a bit technical, but it’s possible with the right tools and commands. Remember, changing the framerate in the header of the video container does not affect the video stream itself. Reencoding is usually necessary to achieve the desired framerate. However, the methods outlined in this article provide a workaround to avoid quality loss due to reencoding.
Yes, it is possible to change the framerate of a video without reencoding using tools like MP4Box and MKVmerge GUI.
Framerate, or frames per second (fps), is the frequency at which consecutive images called frames appear on a display. It determines the smoothness of motion in a video.
MP4Box can extract the video stream from an MP4 file as a raw file, change its framerate, and then remux it back into an MP4 file without reencoding. This helps to avoid quality loss.
MKVmerge GUI is primarily designed to work with Matroska container format. While it can remux videos of other formats, it is recommended to convert them to MKV format first for optimal compatibility.
Changing the framerate in the header of the video container does not affect the video stream itself, so there should be no loss in quality. However, reencoding may be necessary to achieve the desired framerate, which can result in quality loss.
Yes, it is possible to slow down a video without reencoding by using a script that combines avconv, soundstretch, and MP4Box. This method changes the sound tempo and modifies the framerate directly in the MP4 container.
While changing the framerate without reencoding can help avoid quality loss, it may have limitations. For example, certain video players or devices may not support non-standard framerates, and some video editing software may require reencoding for compatibility or advanced editing features. It’s important to test the resulting video to ensure it works as intended.