Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2031929
  • 博文数量: 220
  • 博客积分: 8531
  • 博客等级: 中将
  • 技术积分: 4976
  • 用 户 组: 普通用户
  • 注册时间: 2007-07-18 13:33
文章分类

全部博文(220)

文章存档

2017年(1)

2015年(1)

2014年(5)

2013年(6)

2012年(6)

2011年(30)

2010年(37)

2009年(53)

2008年(41)

2007年(40)

分类: LINUX

2007-08-03 16:53:30

    从下载的的有声文学《盗墓笔记》,由青雪播讲,下来都是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。用法是直接跟目录。
   
    注:脚本改自的脚本。
阅读(6552) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~