Skip to content

Instantly share code, notes, and snippets.

@nkmrgk
Created August 12, 2011 03:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nkmrgk/1141362 to your computer and use it in GitHub Desktop.
Save nkmrgk/1141362 to your computer and use it in GitHub Desktop.
convert mp4 to mp3
@echo off
setlocal
set FFMPEG=ffmpeg.exe
set LAME=lame.exe
set touch=touch.exe
if "%1"=="" echo usage: mp4tomp3 {directory} && goto err
if not exist %1 echo %1: Not found. && goto err
pushd %1
if not %errorlevel%==0 echo pushd failed. && goto err
for %%F in (*.mp4) do (
echo "%%~nF"
if not exist %FFMPEG% echo No ffmpeg. && goto err
%FFMPEG% -y -i "%%~nF.mp4" -vn -acodec pcm_s16le -ac 2 -ar 44100 "%%~nF.wav"
if not %errorlevel%==0 echo ffmpeg failed. && goto err
if exist %LAME% (
%LAME% -V2 --priority 0 "%%~nF.wav" "%%~nF.mp3"
if not %errorlevel%==0 echo lame failed. && goto err
del /f/q "%%~nF.wav"
if exist %touch% %touch% -r "%%~nF.mp4" "%%~nF.mp3"
)
)
popd
exit /b 0
:err
exit /b 255
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment