This post is not exactly in my usual cloud/automation/things I do at work area, but it took me enough time to figure out how to do this that I figure writing about it might save someone else some effort.
Why would you want to do this?
While many music players can change the playback speed of files at runtime, a rather interesting exception is old-school mp3 players, and specifically water-proof mp3 players used by swimmers.
Bluetooth and water don’t mix well so using your phone with wireless headphones, waterproof or not, does not work. And these tiny waterproof music players (I use the excellent Syryn player from Underwater Audio) just don’t have the oomph (or the interface) to change the playback speed of an audio stream at runtime.
I will use the awesome ffmpeg open source library to re-encode my media files.
$: brew install ffmpeg
To encode a single mp3 file run the following shell command:
$: ffmpeg -i some_file.mp3 -filter:a "atempo=2" some_file_x2.mp3
And to re-encode an entire directory of files, with the new re-encoded files saved in a sub-directory called ‘fast’, run this shell command in the directory with your files:
$: for f in *.mp3; do ffmpeg -i "$f" -filter:a "atempo=2" fast/"$f"; done
Note the ‘atempo‘ parameter. This is the parameter that sets the new playback speed. In this example, the generated files will play at twice the speed of the original file.
Originally Published here!