cft
Become a CreatorSign inGet Started

Re-Encoding MP3 files for faster playback speed

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.


user

Barak Merimovich

3 months ago | 1 min read
Follow

re-encoding-mp3-files-faster-playbackspeed-bqpii

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.

How?

I will use the awesome ffmpeg open source library to re-encode my media files.

First, you need to install the ffmpeg CLI. Go ahead and download the package for your operating system. If you are using MacOS and have brew installed, you can install ffmpeg with this command:

$: 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!

Upvote


user
Created by

Barak Merimovich

Follow

Head of Architecture at Logz.io


people
Post

Upvote

Downvote

Comment

Bookmark

Share


Related Articles