- 论坛徽章:
- 0
|
供大家批评!
有个客户要要在linux 把mov 文件转成 图片序列,我就边摸索边学习的完成了第一个脚本.- #!/bin/sh
- # filename: conv.sh
- INFILE=$1
- OUTDIR=$2
- FFCOMMAND="/var/www/cgi-bin/WiretapCentral/ffmpeg"
- #Validate syntax
- if [[ ! -n $INFILE || ! -n $OUTDIR || -n $3 ]];then
- echo "!Error: syntax error"
- echo "Please using : conv.sh <source media> <output directory>"
- exit
- fi
- #Validate input file
- echo ""
- echo "Validating source media file..."
- if [ ! -f $INFILE ];then
- echo $INFILE" isn't find."
- exit
- else
- echo $INFILE" is found."
- fi
- #Validate output direcotry
- echo ""
- echo "Validating output directory..."
- if [ ! -d $OUTDIR ];then
- echo $OUTDIR" isn't find."
- exit
- else
- echo $OUTDIR" is found."
- fi
- #Get the file name
- xbase=${INFILE##*/}
- xpref=${xbase%.*}
- FILENAME=${xpref}
- #Confirme the convertion
- echo
- echo "Converting "$INFILE" to "$OUTDIR"/"FILENAME.tga
- i=1
- while true;do
- echo ""
- echo -n "Please confirm[yes/y(default) or no/n]?"
- read Arg
- case $Arg in
- Y|y|YES|yes)
- break;;
- N|n|NO|no)
- exit;;
- "")
- echo "By default select..."
- break;;
- *)
- echo ""
- echo "!Warrning: Input error,Please tpye yes or no!"
- echo ""
- if ((i<3));then
- ((i=i+1))
- else
- echo ""
- echo "!Error: 3 times input error,Program exit!"
- echo ""
- exit
- fi
- continue;;
-
- esac
- done
- #Execute ffmpeg command
- echo
- echo "Converting ..."
- FFPARM="-i "$INFILE" "$OUTDIR/$FILENAME"_"%6d.tga
- echo ""
- $FFCOMMAND $FFPARM
复制代码 |
|