FFmpeg is a powerful tool for handling multimedia files. Whether you're a podcaster, musician, or just someone who loves audio, knowing how to use FFmpeg can be a game changer for your workflow. In this post, we’ll focus on how to speed up audio files and explore some other handy terminal-based edits for MP3 files on Mac or Unix.
To speed up an audio file with FFmpeg, you can adjust the playback speed using the -filter:a option. Here’s a simple command to increase the speed of an MP3 file:
ffmpeg -i input.mp3 -filter:a "atempo=1.5" output.mp3
In this command:
-i input.mp3 specifies the input file.-filter:a "atempo=1.5" increases the speed by 50%. You can change 1.5 to any value greater than 1.0 to further increase the speed. For example, atempo=2.0 will double the speed.output.mp3 is the name of your new, faster file.The atempo filter only accepts values between 0.5 and 2.0. If you want to speed it up beyond that range, you’ll need to apply multiple filters in sequence. For example:
ffmpeg -i input.mp3 -filter:a "atempo=2.0,atempo=1.5" output.mp3
This command first doubles the speed and then increases it by another 50%.
If you need to trim audio files, FFmpeg makes this easy too. Use the -ss option to specify the start time and the -t option for duration:
ffmpeg -i input.mp3 -ss 00:00:30 -t 00:01:00 output.mp3
This command will start at 30 seconds and trim for 1 minute.
Converting audio formats can be done with a simple command. For instance, to convert an MP3 to WAV:
ffmpeg -i input.mp3 output.wav
If you need to adjust the volume, you can use the -filter:a option again:
ffmpeg -i input.mp3 -filter:a "volume=1.5" output.mp3
This increases the volume by 50%. You can use values less than 1.0 to decrease the volume.
Want to get audio from a video file? Just use the following command:
ffmpeg -i video.mp4 -q:a 0 -map a output.mp3
This command extracts the audio track from a video file and saves it as an MP3.
FFmpeg is a robust tool for audio editing directly from your terminal. Whether you’re speeding up audio files, trimming, converting formats, or adjusting volume, it’s all at your fingertips. Dive into these commands and see how they can streamline your audio editing tasks. Happy editing!