Skip to content

Commit

Permalink
Improve the logical
Browse files Browse the repository at this point in the history
  • Loading branch information
kn007 authored Aug 19, 2016
1 parent b8280bd commit 5f4f7d9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions converter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@ while [ $3 ]; do
$cur_dir/silk/decoder "$1/$line" "$2/$line.pcm" > /dev/null 2>&1
if [ ! -f "$2/$line.pcm" ]; then
ffmpeg -y -i "$1/$line" "$2/${line%.*}.$3" > /dev/null 2>&1 &
while pidof /usr/bin/ffmpeg; do sleep 1; done > /dev/null
ffmpeg_pid=$!
while kill -0 "$ffmpeg_pid"; do sleep 1; done > /dev/null
[ -f "$2/${line%.*}.$3" ]&&echo -e "[$CURRENT/$TOTAL]${GREEN}[OK]${RESET} Convert $line to ${line%.*}.$3 success, ${YELLOW}but not a silk v3 encoded file.${RESET}"&&continue
echo -e "[$CURRENT/$TOTAL]${YELLOW}[Warning]${RESET} Convert $line false, maybe not a silk v3 encoded file."&&continue
fi
ffmpeg -y -f s16le -ar 24000 -ac 1 -i "$2/$line.pcm" "$2/${line%.*}.$3" > /dev/null 2>&1 &
while pidof /usr/bin/ffmpeg; do sleep 1; done > /dev/null
ffmpeg_pid=$!
while kill -0 "$ffmpeg_pid"; do sleep 1; done > /dev/null
rm "$2/$line.pcm"
[ ! -f "$2/${line%.*}.$3" ]&&echo -e "[$CURRENT/$TOTAL]${YELLOW}[Warning]${RESET} Convert $line false, maybe ffmpeg no format handler for $3."&&continue
echo -e "[$CURRENT/$TOTAL]${GREEN}[OK]${RESET} Convert $line To ${line%.*}.$3 Finish."
Expand All @@ -59,7 +61,8 @@ done
$cur_dir/silk/decoder "$1" "$1.pcm" > /dev/null 2>&1
if [ ! -f "$1.pcm" ]; then
ffmpeg -y -i "$1" "${1%.*}.$2" > /dev/null 2>&1 &
while pidof /usr/bin/ffmpeg; do sleep 1; done > /dev/null
ffmpeg_pid=$!
while kill -0 "$ffmpeg_pid"; do sleep 1; done > /dev/null
[ -f "${1%.*}.$2" ]&&echo -e "${GREEN}[OK]${RESET} Convert $1 to ${1%.*}.$2 success, ${YELLOW}but not a silk v3 encoded file.${RESET}"&&exit
echo -e "${YELLOW}[Warning]${RESET} Convert $1 false, maybe not a silk v3 encoded file."&&exit
fi
Expand Down

0 comments on commit 5f4f7d9

Please sign in to comment.