tc-audio-*: proper while read loops.

master
Pierre Neidhardt 2013-10-23 20:14:09 +02:00
parent 7d556955f1
commit 4d5337a6a1
3 changed files with 19 additions and 24 deletions

View File

@ -94,21 +94,19 @@ _worker()
CORE=$1
shift
## WARNING: ffmpeg should not be called from within a while<<EOF loop since
## it continues to read input while running.
OLDIFS=$IFS
IFS="
"
## WARNING: ffmpeg continues to read stdin once it has started, so it should
## not be called from within a while<<EOF loop without redirecting stdin.
for file in $(echo "$INPUT" | sed -n "$CORE~${CPUNO}p"); do
while IFS= read -r file; do
if [ -n "$file" ]; then
echo "$(tput setf 2)$(tput bold)==>$(tput sgr0) $file"
[ $CPUNO -eq 1 ] && "${0%/*}"/tc-audio-transcode "$@" "$file" || \
tc-audio-transcode -q "$@" "$file" >/dev/null
fi
done
IFS=$OLDIFS
done<<EOF
$(echo "$INPUT" | sed -n "$CORE~${CPUNO}p")
EOF
echo "$(tput setf 5)$(tput bold)::$(tput sgr0) Thread $CORE/$CPUNO terminated."
}

View File

@ -6,19 +6,13 @@ if [ -z "$(command -v mediainfo)" ]; then
fi
## This will check for badly encoded audio.
while read -r i; do
while IFS= read -r i; do
BUFFER="$(mediainfo "$i")"
if [ -n "$(echo "$BUFFER" | grep "Bit rate mode *: Constant")" ]; then
echo "$i : CBR"
fi
[ -n "$(echo "$BUFFER" | grep "Bit rate mode *: Constant")" ] && echo "$i : CBR"
if [ -n "$(echo "$BUFFER" | grep "Cover *: Yes")" ]; then
echo "$i : Cover"
fi
[ -n "$(echo "$BUFFER" | grep "Cover *: Yes")" ] && echo "$i : Cover"
if [ -n "$(echo "$BUFFER" | grep "Track name/Position *: 0+")" ]; then
echo "$i : Leading zeros"
fi
[ -n "$(echo "$BUFFER" | grep "Track name/Position *: 0+")" ] && echo "$i : Leading zeros"
done <<EOF
$(find "." \( \
-iname '*.mp3' -o \

View File

@ -385,10 +385,10 @@ aprint <<EOF
[$INPUT_GENRE] Genre [$OUTPUT_GENRE]
[$INPUT_EXT] Ext [$OUTPUT_EXT]
[$INPUT_BITRATE] Bitrate [$OUTPUT_BITRATE]
[$INPUT_ALBUMARTIST] Albumartist
[$INPUT_COMPOSER] Composer
[$INPUT_DISC] Disc
[$INPUT_TYER] Tyer
[$INPUT_ALBUMARTIST] Albumartist
[$INPUT_COMPOSER] Composer
[$INPUT_DISC] Disc
[$INPUT_TYER] Tyer
EOF
cat <<EOF
@ -410,7 +410,7 @@ fi
## COVER. We copy cover only if it does not already exist. Only files found in
## the folder where the music is located will be taken into account.
while read -r i; do
while IFS= read -r i; do
[ -z "$i" ] && break
OUTPUT_COVER="$OUTPUT_FOLDER/${OUTPUT_ALBUM:+$OUTPUT_ALBUM - }Cover"
OUTPUT_COVERFILE="$OUTPUT_COVER.${i##*.}"
@ -443,6 +443,9 @@ STATUS="$(set -o | grep 'shwordsplit' | awk '{print $2}')"
## TAG/RECODE
## With the -map_metadata parameter we clear all metadata.
## WARNING: ffmpeg continues to read stdin once it has started, so it should not
## be called from within a while<<EOF loop without redirecting stdin.
echo ":: Processing..."
ffmpeg $LOGLEVEL $OVERWRITE -i "$1" -vn -sn $OGG_PARAM \
-map_metadata -1 \
@ -453,7 +456,7 @@ ffmpeg $LOGLEVEL $OVERWRITE -i "$1" -vn -sn $OGG_PARAM \
-metadata album="$OUTPUT_ALBUM" \
-metadata album_artist="$OUTPUT_ARTIST" \
-metadata genre="$OUTPUT_GENRE" \
"$OUTPUT_FOLDER/$OUTPUT_FILE.$OUTPUT_EXT"
"$OUTPUT_FOLDER/$OUTPUT_FILE.$OUTPUT_EXT" </dev/null
echo ":: Process finished!"
## If we are overwriting inplace.