Tuesday, May 24, 2011

Transrate - Converting audio files from one bitrate to other using BATCH file

Follow the below steps to transrate all the audio files with extension "mp3" in a given directory.

Download the FFMPEG software from the following link:
http://www.videohelp.com/download/ffmpeg-0.5.7z

Extract the software and copy the FFMPEG.exe and create a file with any name without space and extension "bat" and copy the below contents into it.

REM START OF BATCH FILE

mkdir Transcoded

for /f "delims=" %%a IN ('dir /b/n *.mp3') do (
ffmpeg -i "%%a" -ar 44100 -ac 2 -ab 128 -f mp3 ".\Transcoded\%%a"
)

cd Transcoded
for /f "delims=" %%a IN ('dir /b/n *.mp3') do (
move /Y "%%a" "..\%%a"
)

cd ..
del /Q Transcoded
rmdir /Q Transcoded

REM END OF BATCH FILE

Copy these 2 files into the directory which has the MP3 files that you want to transrate.
Double click the batch file for transrate. This batch file converts the audio bitrate to 128kbps. If one wants a different bitrate, change the number near to -ab option to the desired value.