Fri Jul 31 22:53:31 PDT 2015

Extracting the Audio Portion of an MP4 to a MP3

If you are ever in need of just the audio portion of an .mp4 file, here are two commands and a loop to put the audio into an .mp3 file.

#!/bin/sh
for file in *.mp4
do 
  echo $file
  "/cygdrive/c/Program Files/MPlayer/mplayer.exe" -ao pcm $file \ 
  -ao pcm:file=tmp.wav 
  lame -h tmp.wav `basename $file .mp4`.mp3
done

(You might need to customize the path to mplayer.exe. I used an explicit path as I was on Windows and needed to pull in a specific cygwin dll for this executable. You may or may not have this issue.)


Posted by ZFS | Permanent link | File under: bash