从下载的的有声文学《盗墓笔记》,由青雪播讲,下来都是flv的,在window上面有工具先转换成wmv,然后从wmv里面提取mp3,非常麻烦。后来忽然想到以前在linux上面利用mplayer和lame将rm转换mp3的脚本,是否可以在linux上面转换呢?
首先需要确认mplayer是否可以播放flv文件,经确认是可以播放的。然后修改脚本,实现mplayer+lame将flv转换为mp3:
[root@lvs191 misc]# cat rm2flv.sh
#!/bin/bash
#
# Converts a Real Audio file to a mono MP3 and adds an ID3 tag.
#
# Usage: rm2mp3 infile [outfile]
function au2mp3
{
#mplayer "$1" -ao pcm -vc dummy -vo null
tmp=${1%\.rm}".mp3"
echo -e "---------------begin converting $1 ------------------\n"
mplayer "$1" -ao pcm -vc dummy -vo null
#maybe the filename's suffix become rmvb.mp3,remove rmvb symbols
newfile=`echo $tmp |sed s'/flv.mp3/mp3/'`
lame -h audiodump.wav -b 32 $newfile --tt "$title" --ta "$author" rm -f audiodump.wav echo -e "--------------finish $1 converting-------------------\n" } if [ $# -lt 1 ] then echo "Usage: `basename $0` inputfile or directory" exit 1 fi if [ -d $1 ] #if the argument is directory,then convert them batched then for i in $1/*.flv do au2mp3 $i done #just only one file else au2mp3 $1 fi [root@lvs191 misc]# ./rm2flv.sh manghaiqigou/
|
lame跟了-b 32参数,强制将转换成的mp3设定为32 kbps。用法是直接跟目录。
注:脚本改自的脚本。
阅读(6623) | 评论(0) | 转发(0) |