Converting videos to wav files and mp3 files
Works with OpenBSD systems. Useful with YouTube videos or wav files from CDs.
To convert all mp4 files to wav or mp3.
faad lame libmp3lame and mplayer or ffmpeg are needed. Single files may also be converted, without a script.
To convert mp4 videos to mp3 files:
mp4 to mp3
script called: mp4-mp3.sh #!/bin/sh # # mp4 to mp3 # for i in *.mp4; do echo $i out=$(echo $i | sed -e 's/.mp4//g') echo $out faad -o - $out.mp4 | lame - $out.mp3 done
Or you may use this script instead:
script called: mp4-mp3.sh #!/bin/sh # # mp4 to mp3 # for i in *.mp4; do out=$(ls $i | sed -e 's/.mp4//g') echo "In = $i" echo "Out = $out.mp3" ffmpeg -vn -i "$i" -vn -ac 2 -ab 128k -acodec libmp3lame "$out.mp3" done
mp4 to wav
To convert mp4 videos to wave files:
script called: mp4-wav.sh #!/bin/sh # # mp4 to wav # for i in *.mp4; do echo $i out=$(echo $i | sed -e 's/.mp4//g') echo $out mplayer -vc null -vo null -ao pcm:fast "$i" -ao pcm:file="${out}.wav" done
Or you may use this script instead:
script called: mp4_to_wav.sh #!/bin/sh # # mp4 to wav # for i in *.mp4; do out=$(ls $i | sed -e 's/.mp4//g') echo "In = $i" echo "Out = $out.wav" faad -o "$out.wav" "$i" done
Both together
You may also do both jobs all at once like this:
script called: mp4_to_all.sh #!/bin/sh # # mp4_to_all # echo "current directory =" `pwd` echo "Please enter working directory:" echo read BASE cd $BASE ########################## # # mp4 to wav # for i in *.mp4; do out=$(ls $i | sed -e 's/.mp4//g') echo "In = $i" echo "Out = $out.wav" faad -o "$out.wav" "$i" done ########################## # # wav to mp3 # for i in *.wav; do out=$(ls $i | sed -e 's/.wav//g') echo "In = $i" echo "Out = $out.mp3" # lame -h -b 128 "$i" "$out.mp3" #use this line instead of following if your mp3 player cannot do variable bitrate mp3s lame -V2 "$i" "$out.mp3" done
You may also do single files like this:
lame -h -b 128 "badsong.wav" "badsong.mp3" faad -o "badsong.wav" "badvideo.mp4" mplayer -vc null -vo null -ao pcm:fast "badvideo.mp4" -ao pcm:file="badsong.wav" ffmpeg -vn -i "badvideo.mp4" -vn -ac 2 -ab 128k -acodec libmp3lame "badsong.mp3"
To convert all wav files to a CD. This works for OpenBSD. Insert a blank CD, then:
cdio -f cd0c tao -a *.wav
To put all mp3 files onto a CD. This works for OpenBSD.
mkhybrid -R -o mp3s.iso /home/whoever/mp3 (use directory where mp3s are at) cdio -f cd1c tao mp3s.iso
To play it, use a CD or DVD player that plays mp3s or:
sudo mount /dev/cd0c /mnt mplayer /mnt/*.mp3
To copy a CD or get wav files from it to make mp3s:
cdio -f cd1c cdrip
This gives you all of the songs in wav files, copy as above or make mp3s.
How to play a DVD
mplayer dvd://
How to play a CD
cdio cdplay (with track numbers if wanted or plays whole CD) Ctrl-c (to stop playing)
Or you may play in analog with:
cdio play cdio next cdio previous cdio stop cdio eject cdio close cdio quit
How to get OpenBSD?
You may install it onto your system, go to OpenBSD. Be sure to look at FAQ page: FAQ
Or you may make a live USB drive, go to Live-USB OpenBSD.
Last Updated: January 8, 2010