In this post by MiniTool MovieMaker (a free and easy-to-use video editor), you will learn how to speed up video in FFmpeg. Specifically, use the appropriate commands to change the speed at which the video plays.

Are you attempting to speed up video with FFmpeg? We are here to help. It is an open-source, cross-platform software that handles multimedia data, including videos. But if you are inexperienced with the command-line interface, even simple operations like speeding up a video can be perplexing.

That is why this tutorial seeks to make things easier for you by breaking the procedure down into easy steps. Even if you’re new to FFmpeg, you’ll know the right command for the software to speed up your footage and use it to create a timelapse effect or just lessen the duration.

How to Use FFmpeg to Speed Up Video

Accelerating video using FFmpeg entails manipulating each video frame’s Presentation Timestamp (PTS). The PTS determines when every frame appears during playback, and by changing these timestamps, you can control the video’s speed.

There are two main ways of doing this: use the setpts video filter or export a video to the raw bitstream format and re-mux it using new timestamps.

Method 1: Setpts Video Filter

In FFmpeg, the setpts (set presentation timestamp) filter is a tool that enables you to adjust the PTS values of video frames. By setting the PTS, you can use FFmpeg to efficiently speed up or slow down the video. It will change the frame timestamps based on the formula you offer.

For instance, to twice the video’s speed, scale the PTS to half of its original value:

ffmpeg -i input.mp4 -vf “setpts=0.5PTS” output.mp4

Each element in the command indicates that:

  • -i input.mp4 is the name of the input video.
  • -vf “setpts=0.5PTS” uses the setpts filter to set the PTS to 0.5 times its original value, thereby doubling the playback speed.
  • output.mp4 specifies the output video.
  • The setpts=0.5PTS expression sets the PTS by 0.5, meaning every frame is presented twice as fast so that the video file will play at double speed.

But it is important to remember that applying the setpts filter only alters the video speed, not the audio. If you also would like to remove the audio track (as it will not be in sync with the accelerated video), you can use the -an option, as seen below:

ffmpeg -i input.mp4 -vf “setpts=0.5PTS” -an output.mp4

In the meantime, to get a significant increase in video speed, like 60 times the original rate, you can do this by entering the “setpts=PTS/60” command. The command divides the PTS by 60, so the video plays 60 times faster:

ffmpeg -i input.mp4 -filter:v “setpts=PTS/60” -an output.mp4

To speed up the video in FFmpeg by 60 times and then resample it to play at a specific FPS (in this case, 24 FPS), you can include the “fps=24” in your command as follows:

ffmpeg -I input.mp4 -filter:v “setpts=PTS/60,fps=24” -an output.mp4

How to Speed Up Video in Avidemux & An Alternatively Way
How to Speed Up Video in Avidemux & An Alternatively Way

If you want to know how to create timelapse or speed up video in Avidemux, then don’t miss this step-by-step guide.

Read More
Tips:
By the way, a straightforward and affordable solution for accelerating or decelerating your videos is MiniTool MovieMaker.

MiniTool MovieMakerClick to Download100%Clean & Safe

Method 2: Raw Bitstream

Another method to speed up video in FFmpeg is using raw bitstream. It is a lossless process that only modifies the timestamps of the video frames while keeping the video stream exactly as it is. The method is ideal if you need to modify the playback speed without making any other modifications to the video quality or content. Do the following:

Step 1. Copy the video to the raw bitstream format

First of all, copy the video stream to the raw bitstream format. The process entails converting the video file into a format that FFmpeg can effortlessly work with while creating new timestamps.

For instance, you can enter the command below for H.264 encoded videos:

ffmpeg -i input.mp4 -map 0:v -c:v copy -bsf:v h264_mp4toannexb raw.h264

The command extracts the video stream from the input file (input.mp4) and converts it to the raw bitstream format (in this example, raw.h264), so the video content remains unaltered.

Step 2. Create new timestamps as muxing to the container

After you convert the video to the raw bitstream, you can create new timestamps by muxing the raw stream back into the container format such as MP4. In this step, you will specify the playback frame rate you desire, determining the speed of the output video. Like this:

ffmpeg -fflags +genpts -r 30 -i raw.h264 -c:v copy output.mp4

In the command:

  • -fflags +genpts causes FFmpeg to create new PTS values.
  • -r 30 adjusts the playback frame rate to 30 FPS. You can set the value to control the output video’s speed.
  • -c:v copy makes sure the video stream is copied without re-encoding, retaining its original quality.

By altering the value of -r, you can achieve the playback speed you desire. Increasing the frame rate will accelerate the video while reducing the frame rate will slow it down.

FFmpeg Flip Video Vertically or Horizontally in Seconds
FFmpeg Flip Video Vertically or Horizontally in Seconds

Have you ever heard about FFmpeg? Check out this post right now to learn how you can use the FFmpeg flip video tool.

Read More

Conclusion

How to speed up video in FFmpeg? You can accomplish this using the setpts video filter or raw bitstream method, as described above.

  • linkedin
  • reddit