|
- #!/bin/bash
- BLUE="\033[0;34m"
- GREEN="\033[0;32m"
- GREY="\033[1;30m"
- CYAN="\033[1;36m"
- PURPLE="\033[1;35m"
- RED="\033[1;31m"
- NO_color="\033[0m"
- clear_output_exit(){
- [ -f "$OUTPUTFILE" ] && rm -f "$OUTPUTFILE"
- #wait for the sub process to stop
- sleep 1
- [ -f "$MAGICFILE" ] && rm -f "$MAGICFILE"
- [ -f "$SIGNALFILE" ] && rm -f "$SIGNALFILE"
- echo "Interrupted" 1>&2
- exit 1
- }
- trap clear_output_exit INT QUIT HUP
- cecho(){
- echo -n -e $1
- shift
- echo $@
- echo -n -e $NO_COLOR
- }
- cecho $GREEN ----------Convert Music To Ogg Vorbis Format-----------
- if [ $# = 0 ];then
- cecho $RED usage: $0 [filelist]
- exit 10
- fi
- while [ true ];do
- INPUTFILE="$1"
- OUTPUTFILE="${INPUTFILE%.*}.ogg"
- if [ "$INPUTFILE" == "$OUTPUTFILE" ];then
- cecho $RED ERROR:your input file is already ogg-post-prefix
- exit 1
- fi
- echo INPUTFILE :$INPUTFILE
- echo OUTPUTFILE:$OUTPUTFILE
- cecho $PURPLE convert to tmp wave file...
- echo -e $GREY
- MAGICFILE=$INPUTFILE.magic
- SIGNALFILE=$INPUTFILE.signal
- mplayer -ao pcm:file=>(oggenc - -o "$OUTPUTFILE" &>/dev/null; [ $? == 0 ] && touch "$MAGICFILE";touch "$SIGNALFILE") "$INPUTFILE"
- echo -e $NO_COLOR
- while [ ! -f "$SIGNALFILE" ];do usleep $(( 100*1000 ));done
- rm -f "$SIGNALFILE"
- if [ -f "$MAGICFILE" ];then
- rm -f "$MAGICFILE"
- cecho $PURPLE 'success!deleting unused file and old music...'
- rm -f "$INPUTFILE"
- else
- cecho $RED error detected when encoding tmp wave file
- rm -f "$OUTPUTFILE"
- fi
- shift
- if [ x"$1" == x ];then
- cecho $GREEN done.
- exit 0
- fi
- done
复制代码 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|