tc-audio-*: proper while read loops.
parent
7d556955f1
commit
4d5337a6a1
|
@ -94,21 +94,19 @@ _worker()
|
||||||
CORE=$1
|
CORE=$1
|
||||||
shift
|
shift
|
||||||
|
|
||||||
## WARNING: ffmpeg should not be called from within a while<<EOF loop since
|
## WARNING: ffmpeg continues to read stdin once it has started, so it should
|
||||||
## it continues to read input while running.
|
## not be called from within a while<<EOF loop without redirecting stdin.
|
||||||
OLDIFS=$IFS
|
|
||||||
IFS="
|
|
||||||
"
|
|
||||||
|
|
||||||
for file in $(echo "$INPUT" | sed -n "$CORE~${CPUNO}p"); do
|
while IFS= read -r file; do
|
||||||
if [ -n "$file" ]; then
|
if [ -n "$file" ]; then
|
||||||
echo "$(tput setf 2)$(tput bold)==>$(tput sgr0) $file"
|
echo "$(tput setf 2)$(tput bold)==>$(tput sgr0) $file"
|
||||||
|
|
||||||
[ $CPUNO -eq 1 ] && "${0%/*}"/tc-audio-transcode "$@" "$file" || \
|
[ $CPUNO -eq 1 ] && "${0%/*}"/tc-audio-transcode "$@" "$file" || \
|
||||||
tc-audio-transcode -q "$@" "$file" >/dev/null
|
tc-audio-transcode -q "$@" "$file" >/dev/null
|
||||||
fi
|
fi
|
||||||
done
|
done<<EOF
|
||||||
IFS=$OLDIFS
|
$(echo "$INPUT" | sed -n "$CORE~${CPUNO}p")
|
||||||
|
EOF
|
||||||
|
|
||||||
echo "$(tput setf 5)$(tput bold)::$(tput sgr0) Thread $CORE/$CPUNO terminated."
|
echo "$(tput setf 5)$(tput bold)::$(tput sgr0) Thread $CORE/$CPUNO terminated."
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,19 +6,13 @@ if [ -z "$(command -v mediainfo)" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## This will check for badly encoded audio.
|
## This will check for badly encoded audio.
|
||||||
while read -r i; do
|
while IFS= read -r i; do
|
||||||
BUFFER="$(mediainfo "$i")"
|
BUFFER="$(mediainfo "$i")"
|
||||||
if [ -n "$(echo "$BUFFER" | grep "Bit rate mode *: Constant")" ]; then
|
[ -n "$(echo "$BUFFER" | grep "Bit rate mode *: Constant")" ] && echo "$i : CBR"
|
||||||
echo "$i : CBR"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$(echo "$BUFFER" | grep "Cover *: Yes")" ]; then
|
[ -n "$(echo "$BUFFER" | grep "Cover *: Yes")" ] && echo "$i : Cover"
|
||||||
echo "$i : Cover"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$(echo "$BUFFER" | grep "Track name/Position *: 0+")" ]; then
|
[ -n "$(echo "$BUFFER" | grep "Track name/Position *: 0+")" ] && echo "$i : Leading zeros"
|
||||||
echo "$i : Leading zeros"
|
|
||||||
fi
|
|
||||||
done <<EOF
|
done <<EOF
|
||||||
$(find "." \( \
|
$(find "." \( \
|
||||||
-iname '*.mp3' -o \
|
-iname '*.mp3' -o \
|
||||||
|
|
|
@ -410,7 +410,7 @@ fi
|
||||||
|
|
||||||
## COVER. We copy cover only if it does not already exist. Only files found in
|
## 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.
|
## 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
|
[ -z "$i" ] && break
|
||||||
OUTPUT_COVER="$OUTPUT_FOLDER/${OUTPUT_ALBUM:+$OUTPUT_ALBUM - }Cover"
|
OUTPUT_COVER="$OUTPUT_FOLDER/${OUTPUT_ALBUM:+$OUTPUT_ALBUM - }Cover"
|
||||||
OUTPUT_COVERFILE="$OUTPUT_COVER.${i##*.}"
|
OUTPUT_COVERFILE="$OUTPUT_COVER.${i##*.}"
|
||||||
|
@ -443,6 +443,9 @@ STATUS="$(set -o | grep 'shwordsplit' | awk '{print $2}')"
|
||||||
|
|
||||||
## TAG/RECODE
|
## TAG/RECODE
|
||||||
## With the -map_metadata parameter we clear all metadata.
|
## 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..."
|
echo ":: Processing..."
|
||||||
ffmpeg $LOGLEVEL $OVERWRITE -i "$1" -vn -sn $OGG_PARAM \
|
ffmpeg $LOGLEVEL $OVERWRITE -i "$1" -vn -sn $OGG_PARAM \
|
||||||
-map_metadata -1 \
|
-map_metadata -1 \
|
||||||
|
@ -453,7 +456,7 @@ ffmpeg $LOGLEVEL $OVERWRITE -i "$1" -vn -sn $OGG_PARAM \
|
||||||
-metadata album="$OUTPUT_ALBUM" \
|
-metadata album="$OUTPUT_ALBUM" \
|
||||||
-metadata album_artist="$OUTPUT_ARTIST" \
|
-metadata album_artist="$OUTPUT_ARTIST" \
|
||||||
-metadata genre="$OUTPUT_GENRE" \
|
-metadata genre="$OUTPUT_GENRE" \
|
||||||
"$OUTPUT_FOLDER/$OUTPUT_FILE.$OUTPUT_EXT"
|
"$OUTPUT_FOLDER/$OUTPUT_FILE.$OUTPUT_EXT" </dev/null
|
||||||
echo ":: Process finished!"
|
echo ":: Process finished!"
|
||||||
|
|
||||||
## If we are overwriting inplace.
|
## If we are overwriting inplace.
|
||||||
|
|
Loading…
Reference in New Issue