Title: command line music convertion Subject: Convert music to mp3 on command line with ffmpeg, faad, lame, mplayer # # Convert wma files to mp3, preserving metadata, handles spaces in file names. # This is the best convertion I have so far. # find ./ -name "*.wma" |(while read FOO; do if [ -f "${FOO%.wma}.mp3" ]; then # # Skip files if they already exist. # echo "File already exists. Skipping ${FOO%.wma}.mp3"; else echo "Converting ${FOO} to ${FOO%.wma}.mp3"; # # One step convertion with ffmepg # -y = yes overwirte existing files # -ab = 128bit encoding # -map_meta_data = copy meta data. # ffmpeg will exit after first file if you don't pipe in /dev/null # ffmpeg -y -i "${FOO}" -ab 128k -map_meta_data outputfile:inputfile "${FOO%.wma}.mp3" < /dev/null; fi; done) # # Two step convertion process with mplayer and lame # find ./ -name "*.wma" |(while read FOO; do # Rip echo "Converting: ${FOO} to ${FOO%.wma}.wav"; mplayer -vo null -vc dummy -af resample=44100 -ao pcm -ao pcm:waveheader:file="${FOO%.wma}.wav" "${FOO}"; # Encode echo "Converting: ${FOO%.m4a}.wav to ${FOO%.wma}.mp3"; lame "${FOO%.wma}.wav" "${FOO%.wma}.mp3" # Show result ls -laF "${FOO%.wma}.mp3" echo "Remove wav?(y/n)" read REMOVE # Cleanup if [[ "$REMOVE" == "y" ]]; then rm -f "${FOO%.wma}.wav" rm -r fi done) # # Two step convertion process with faad and lame # find ./ -name "*.m4a" | (while read FOO; do echo "Converting: ${FOO} to ${FOO%.m4a}.wav"; faad "$FOO" "${FOO%.m4a}.wav"; lame "${FOO%.m4a}.wav" "${FOO%.m4a}.mp3"; done)