Home > FFmpeg, How-To, Video > How-To: Alter Video Speed with FFmpeg and mjpegtools

How-To: Alter Video Speed with FFmpeg and mjpegtools

Unfortunately my Linux based non-linear editing tool of choice, Open Movie Editor, doesn’t currently support directly altering video playback speed. For example, if you wanted a portion of your new compilation to run at 200% of original recorded speed, it can’t be done within OME. This exact functionality was something I needed for an existing editing project.

After some thought and investigation, such changes can be achieved through using a combination of FFmpeg and yuvfps, which is part of mjpeg tools, to alter the framerate of the desired footage. If your original file is PAL based, with a framerate of 25fps, changing the framerate to 50fps will result in the video running twice as fast, for half as long.

I didn’t initially have mjpegtools installed, but on my Debian based system this was easy enough with

sudo apt-get install mjpegtools

Next, the input video needs to be converted to yuv4mpegpipe format, passed through yuvfps and output to a new avi file. Here’s the command line I used to create a clip at 50fps:

ffmpeg -i input.dv -f yuv4mpegpipe - | yuvfps -s 50:1
-r 50:1  | ffmpeg -f yuv4mpegpipe -i - -b 28800k -y output.avi

Change the 50:1 ratios to whatever framerate you require. e.g. 100:1 for 100fps. Be sure to set the output file bitrate to a relevant quality level. Omitting this flag will result in a poor quality AVI output file by default.

The resulting AVI file was easily played back with Totem, and handled on the timeline admirably by OME.

Thanks to Victor Paesa on the FFmpeg mailing list for pointing me in the right direction.

Some other options to investigate include the new Libavfilter for FFmpeg and converting the original footage to a raw data file, which will lost the audio.

About these ads
  1. JingleTwinkle
    February 22, 2008 at 14:16

    Thanks for the excellent tip.
    I was having a problem of Audio desync for a video that I processed. After processing, I couldn’t mux the audio correctly, due to the video being a different frame rate. I tried your method and it works very well. Thanks again !!!

  2. Qutorial
    February 15, 2010 at 09:57

    Hello.
    Thank you very much for your article, but I still can not solve my problem :(
    How to slightly speed up video?
    For example to get 30.3 fps from 30 fps?
    Even with pitch shifted audio?

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: