[分享]wma转换成mp3的脚本程序

sh/bash/dash/ksh/zsh等Shell脚本
回复
zhu-qi
帖子: 27
注册时间: 2005-10-04 21:00

[分享]wma转换成mp3的脚本程序

#1

帖子 zhu-qi » 2006-11-14 19:20

最近在学习shell编程,发现满有意思的
正好下了一些喜欢的歌曲,是wma,用bmp不能播放
于是想写一个脚本,批量转换下,感觉满好玩的
就和大家share下。这个脚本能转换脚本所在目录下的所有wma文件
当然,运行这个脚本的前提是要求系统安装有mplayer和lame
====================
#!/bin/bash

ls *.wma > filelist.txt
filename=`head -1 filelist.txt`
while [ -n "$filename" ];
do
mplayer -vo null -ao pcm "$filename"
rm -f "$filename"
filename=`echo $filename|sed 's/wma/mp3/g'`
lame -h audiodump.wav "$filename"
ls *.wma > filelist.txt
filename=`head -1 filelist.txt`
done
rm -f audiodump.wav
rm -f filelist.txt
rm -f *~
====================
“被ubuntu所感动,也想为它和大家做点什么”
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

#2

帖子 eexpress » 2006-11-14 19:23

for i in *.wma
不行吗。
● 鸣学
头像
yaoms
帖子: 4952
注册时间: 2007-10-19 14:51
来自: 深圳

#3

帖子 yaoms » 2008-06-19 11:58

代码: 全选

$ cat ~/bin/dumpwma2mp3.sh
#!/bin/bash
#
# Dump wma to mp3

for i in *.wma
do
if [ -f $i ]; then
rm -f audiodump.wav
mplayer -vo null -vc dummy -af resample=44100 -ao pcm:waveheader "$i"
dest=../wma2mp3/`echo "$i"|sed -e 's/wma$/mp3/'`
lame -h -m j --vbr-new -b 196  audiodump.wav "$dest"
rm -f audiodump.wav
fi
done
Nothing 有事请发邮件到 yms541 AT gmail.com
alias 爱慕颇雷尔='mplayer'
头像
yaoms
帖子: 4952
注册时间: 2007-10-19 14:51
来自: 深圳

#4

帖子 yaoms » 2008-06-19 12:04

代码: 全选

$ cat ~/bin/dumpwma2mp3v2.sh
#!/bin/bash
#
# Dump wma to mp3

PATH=/opt/lame-3.97/bin:/opt/mplayer/bin:$PATH

for i in *.wma
do
if [ -f "$i" ]; then
rm -f audiodump.wav
mplayer -vo null -vc dummy -af resample=44100 -ao pcm:waveheader "$i"
dest=../huarennangeshou_wanzhenggaoqing/`echo "$i"|sed -e 's/wma$/mp3/'`
if [ ! -f "$dest" ]; then
lame -h --cbr -b 96 --resample 44.1 audiodump.wav "$dest"
fi
dest=../huarennangeshou_wanzhenggaosu/`echo "$i"|sed -e 's/wma$/mp3/'`
if [ ! -f "$dest" ]; then
lame -h --cbr -b 32 --resample 24 audiodump.wav "$dest"
fi
rm -f audiodump.wav
fi
done
这个是用来转到手机上听得。呵呵 简单改下抽样频率和比特率。
Nothing 有事请发邮件到 yms541 AT gmail.com
alias 爱慕颇雷尔='mplayer'
头像
xiooli
帖子: 6956
注册时间: 2007-11-19 21:51
来自: 成都
联系:

#5

帖子 xiooli » 2008-06-19 12:38

你们有喧宾夺主的嫌疑哦 :D
头像
yaoms
帖子: 4952
注册时间: 2007-10-19 14:51
来自: 深圳

#6

帖子 yaoms » 2008-06-19 12:46

...这叫继承和发扬 :D
Nothing 有事请发邮件到 yms541 AT gmail.com
alias 爱慕颇雷尔='mplayer'
头像
yjcong
帖子: 2470
注册时间: 2006-02-28 3:11

#7

帖子 yjcong » 2008-06-19 13:08

Exiting... (End of file)
Can't init outfile '../wma2mp3/violoncello-Vocalise.mp3'

之后一步了, 怎么就不能输出了。 所有的都一样
头像
yaoms
帖子: 4952
注册时间: 2007-10-19 14:51
来自: 深圳

#8

帖子 yaoms » 2008-06-19 13:12

你有没有这个文件夹? ../wma2mp3
Nothing 有事请发邮件到 yms541 AT gmail.com
alias 爱慕颇雷尔='mplayer'
头像
HuntXu
帖子: 5776
注册时间: 2007-09-29 3:09

#9

帖子 HuntXu » 2008-06-19 13:14

yaoms 写了:你有没有这个文件夹? ../wma2mp3
自用的放出来时应该加上些判断语句... :D
HUNT Unfortunately No Talent...
头像
yaoms
帖子: 4952
注册时间: 2007-10-19 14:51
来自: 深圳

#10

帖子 yaoms » 2008-06-19 13:21

呵呵,有问题,大家才会细看脚本嘛
Nothing 有事请发邮件到 yms541 AT gmail.com
alias 爱慕颇雷尔='mplayer'
头像
yjcong
帖子: 2470
注册时间: 2006-02-28 3:11

#11

帖子 yjcong » 2008-06-19 13:37

HuntXu 写了:
yaoms 写了:你有没有这个文件夹? ../wma2mp3
自用的放出来时应该加上些判断语句... :D
是的, 开始没注意。

但是,出了楼主的, 后面2个都用不了。 这次的错误是

代码: 全选

fatal error during initialization
头像
skyx
论坛版主
帖子: 9202
注册时间: 2006-12-23 13:46
来自: Azores Islands
联系:

#12

帖子 skyx » 2008-06-19 13:40

zhuqi zhuqin?
no security measure is worth anything if an attacker has physical access to the machine
头像
zhuqin_83
帖子: 10606
注册时间: 2006-05-13 4:02
联系:

#13

帖子 zhuqin_83 » 2008-06-20 0:19

skyx 写了:zhuqi zhuqin?
我倒 :shock: 这样都能被你联想到
HP Pavilion DV6-2064CA: AMD Turion II Ultra Dual-Core Mobile M640, HD4650, 2GBx2 DDR2-800, Seagate 500GB 7200RPM SATA, BD-ROM
DELL UltraSharp 2209WA
Arch64, Testing repo
回复