What if we could watch movies at 1.5x or 2x speed without changing the audio pitch? This post will show you how to do exactly that on Ubuntu 10.04.

Maybe you have wished you could watch boring movies or slow-but-still-interesting lectures or interviews faster. If we use the standard fast-forward functionality from most video players, the audio pitch goes higher and higher as we play the movie faster, until the audio sounds like everyone has been inhaling helium.

But if you are an Ubuntu 10.04 user, there is a neat trick we can use to dynamically transform the audio on the fly so that people speak twice as fast, but at the same pitch. I thought I’d post this note here for the benefit of others and so I can remember how to do it in the future.

UPDATE: If you have a very recent version of mplayer, the support for variable speed playback may be already built in. Try out

mplayer -af ladspa -speed 1.5 file.avi

If that didn’t work, you’ll need to try it the longer way.

First, you’ll need to install tap-plugins:

sudo apt-get install tap-plugins

Then, you will use a command of the following form to play the file (NOTE: This won’t work just yet, read on!):

mplayer -speed x -af ladspa=/usr/lib/ladspa/tap_pitch.so:tap_pitch:0:y:-90:0 file.mp3

In the above command, x is the rate at which the file should play, with 1 being normal speed. So if you want to play at 80% of normal speed, x = 0.8, and if you want to play it at 150% of normal speed, x = 1.5. Also in the above expression, y is the modified pitch, as a percentage change, with 0 being normal. So if you want to increase the pitch by 50%, y = 50, and if you want to decrease the pitch by 50%, then y = -50.

The challenge we have is that we want to keep the pitch the same, so we need to work out the relationship between x and y so that if we decrease the speed (tempo), we increase the pitch to compensate. This relationship is given by the following equation:

y = (100-100x)/x

So if we want to play the file at 80% of normal speed, x = 0.8 and y = (100-100*0.8)/(0.8) = 25, and the command we would use to play the file becomes:

mplayer -speed 0.8 -af ladspa=/usr/lib/ladspa/tap_pitch.so:tap_pitch:0:25:-90:0 file.mp3

If we want to play the file at 200% of normal speed, x = 2 and y = (100-100*2)/2 = -50, and the command we would use to play the file becomes:

mplayer -speed 2 -af ladspa=/usr/lib/ladspa/tap_pitch.so:tap_pitch:0:-50:-90:0 file.mp3

tap-pitch only works with a pitch shift range of -50 to 100, which corresponds to speeds of 0.5x to 2.0x, although it is possible to chain the filters if you want to increase that range (so run tap-pitch on tap-pitch), but frankly watching things at faster than 2.0x is usually an exercise in futility anyway.

I usually put these two commands in my .bashrc so I can just call them on any file I want to run fast (or fastest!):

alias mplayerfast='mplayer -speed 1.5 -af ladspa=/usr/lib/ladspa/tap_pitch.so:tap_pitch:0:-33:-90:0'
alias mplayerfastest='mplayer -speed 2.0 -af ladspa=/usr/lib/ladspa/tap_pitch.so:tap_pitch:0:-50:-90:0'

Enjoy!