Topic: I just made a "silly" script to Convert flv files to mp3 using ffmpeg
Hello,
I proudly present my first all-made-by-me script which is converting flv files to mp3 using ffmpeg. You're also going to need libavcodec-unstripped-52 in order to succeed the conversion. Both ffmpeg and libavcodec-unstripped-52 can be apt-get install-ed. You can paste it to a new file inside ~/bin, make it executable with
chmode +x ~/bin/flv2mp3and run it from terminal like that:
flv2mp3 inputfile.flv outputfile.mp3or if you want to set the bit rate of the output mp3 to lets say 128kbps:
flv2mp3 inputfile.flv outputfile.mp3 128
It can also team up nicely with youtube-dl
And...here it is:
#!/bin/bash
#####################
## flv2mp3
#####################
if [ -z "$1" ]
then
echo "No input file"
echo "Help: $0 -h"
exit
else
case $1 in
*.flv)
input=$1 ;;
-h) echo "Usage: $0 {inputfile.flv} {outputfile.mp3} {optional-bit-rate}"
echo "ex: $0 test.flv test.mp3 192"
exit;;
*) echo "Input file is not flv"
echo "Help: $0 -h"
exit;;
esac
fi
if [ -z "$2" ]
then
echo "No output file"
echo "Help: $0 -h"
exit
else
case $2 in
*.mp3)
output=$2 ;;
*) output=$2".mp3"
esac
fi
if [ -z "$3" ]
then
btr=""
else
case $3 in
*[!0-9]*|"") echo "Not acceptable Bit Rate"
echo "Help: $0 -h"
exit;;
*)btr="-ab $3""k";;
esac
fi
ffmpeg -i $input $btr $output
#endI know it's not much, hence the "silly", but it was the best way to always "remember" how I can convert flvs to mp3s.
I hope it'll get handy to someone else too.
By the way this is my new ringtone ![]()