Batch MP3 Re-encoding

At first, I remembered the wonderful Lame utility the old-fashioned way, which I used before, and even typed it into the search…

But then I opened a chat window and asked AI if ffmpeg can compress mp3 (and there was a suspicion that it could, because there is mp3 audio inside video).

Can you re-encode .mp3 to a different bitrate through ffmpeg?

Yes. ffmpeg supports MP3 re-encoding with bitrate changes.

Example (CBR):

ffmpeg -i input.mp3 -vn -c:a libmp3lame -b:a 192k output.mp3

Example (VBR):

ffmpeg -i input.mp3 -vn -c:a libmp3lame -q:a 2 output.mp3

Where -q:a is quality (0 — best, 9 — worst).

Stereo / frequency (optional):

ffmpeg -i input.mp3 -c:a libmp3lame -b:a 128k -ar 44100 -ac 2 output.mp3

Note: Re-encoding MP3 → MP3 always results in additional quality loss.

Write a .bat script that will process all .mp3 files in the current folder by making -b:a 128k -ar 44100 -ac 2 and putting them in the out/ subfolder

@echo off
setlocal enabledelayedexpansion

if not exist "out" mkdir "out"

for %%F in (*.mp3) do (
    echo Processing %%F
    ffmpeg -y -i "%%F" -vn -c:a libmp3lame -b:a 128k -ar 44100 -ac 2 "out\\%%F"
)

echo Done.
pause

Requirements:

ffmpeg.exe must be available through PATH or be in the same directory as the .bat file.

Only .mp3 files from the current folder are processed, and the result is in out\\ with the same names.


In general, there’s nothing more to add — the task is solved and it works, and it turned out to be faster than I would have searched, downloaded, and figured it out.

Leave a Comment

Your email address will not be published. Required fields are marked *