Skip to content

Instantly share code, notes, and snippets.

@intijk
Created April 3, 2012 16:06
Show Gist options
  • Save intijk/2293216 to your computer and use it in GitHub Desktop.
Save intijk/2293216 to your computer and use it in GitHub Desktop.
转换各种音频文件为mp3格式
#!/bin/bash
#Usage example: ./convmp3 *.wma
while [ ! $# -eq 0 ]
do
affix=`echo $1|perl -pe 's|(.*)(\..*?)$|\2|'`
echo $affix
inTmpFile=`cat /dev/urandom | strings -n 5 | head -n 1`$affix
outTmpFile=`cat /dev/urandom | sed 's/[^a-zA-Z0-9]//g' | strings -n 5 | head -n 1`.mp3
ln -s "$1" $inTmpFile
outputFile=`echo $1 | perl -pe 's|(.*\.).*?$|\1mp3|'`
ffmpeg -i "$inTmpFile" -id3v2_version 3 "$outTmpFile"
mv "$outTmpFile" "$outputFile"
rm "$outTmpFile" "$inTmpFile"
shift
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment