linux识别不了m4a文件,[Unix/Linux Sysadmin] [Shell Script] linux m4a to mp3 converter (转换m4a到mp3格式)...

Purpose: 这个脚本用来把m4a声音文件转换成mp3文件,使得文件可以放到不支持m4a格式的mp3设备也能够播放。这个脚本需要你安装lame和faad两个命令。

NOTE: 发布的脚本我已经修复了对文件名含有空格的文件处理不了的BUG.

#!/bin/bash

#

# Purpose: convert m4a music to mp3 file.

#

# Usage: m4a2mp3 *.m4a [-C target_dir]

# TODO: [-C target_dir]

# History: Fixed the problem of processing m4a files contain characters.

#

# Written by Dooit, dooit.lee@gmail.com

# Created on Thu Sep 1 10:14:15 HKT 2011

# Refer to: http://www.scottklarr.com/topic/70/linux-m4a-to-mp3-converter-shell-script/

#

Usage="Usage: `basename $0` [-C target_dir]"

echo "There are $# m4a file will be proccessed to mp4."

if [ $# -eq 0 ]; then

echo $Usage >&2

fi

# Process target_dir if it has

target_dir=$PWD

# Converting m4a to mp3

# NOTE: if file name have space characters, we need to process them and then

#recover it.

for m4a_file in `echo $@ | sed -e 's/m4a /m4a:/g' -e 's/:/\n/g' -e 's/ /:/g'`

do

m4a_file=`echo $m4a_file | sed -e 's/:/ /g'`

mp3_file="$target_dir/`basename "${m4a_file%.m4a}.mp3"`"

#echo $m4a_file

#echo $mp3_file

echo "Converting: ${m4a_file%.m4a}.mp3"

faad -q -o - "`echo $m4a_file | sed -e 's/ /\ /g'`" | \

lame --quiet - "`echo $mp3_file | sed -e 's/ /\ /g'`"

done

Usage examples:

$ m4a2mp3 /m4a/files/directory/*.m4a

#Or

$ m4a2mp3 `find /directory/contains/m4a/files -name '*.m4a'`

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值