This sript extracts the soundtrack from any video format and converts it to mp3. Put all videos in a single folder and run this script on them. This works on all kinds of video. This is specially useful on those bunch of youtube videos.
It works like flv to mp3, mp4 to mp3, avi to mp3 etc.
==================================
#!/bin/bash
# convert-video-to-mp3 v2.0 by JOnes.
# This sript extracts the soundtrack from any video format and converts it to mp3.
# Put all videos in a single folder and run this script on them. This works on all kinds of video. This is specially useful on those bunch of youtube videos.
echo -e "\nThis sript extracts the soundtrack from any video format and converts it to mp3. Put all videos in a single folder and run this script on them. This works on all kinds of video. This is specially useful on those bunch of youtube videos.\n\n"
if [ ! `which mplayer` ] ; then
echo -e "Install mplayer \nsudo apt-get install mplayer"
exit 0
fi
if [ ! `which lame` ] ;then
echo -e "Install lame \nsudo apt-get install lame"
exit 0
fi
IFS=$'\n'
for fullfile in `ls -1`
do
fullfilename=$(basename $fullfile)
# extension=${filename##*.}
filename=${fullfilename%.*}
if [[ `file "$fullfilename" | grep -i "video"` ]]; then
# -i in grep ignores case
echo $filename
else
file "$fullfilename"
echo "Not a video file."
echo "----------"
continue
fi
mplayer $fullfile -ao pcm:file=temp.wav
lame -f temp.wav $filename.mp3
rm temp.wav
echo "----------"
done
echo "finished"
Comments