tc-video-generic: fixed wrong audio bitrate when it was >= 1000.

master
Pierre Neidhardt 2013-11-01 20:34:07 +01:00
parent e0da10b159
commit ccf39c4428
1 changed files with 3 additions and 1 deletions

View File

@ -154,8 +154,10 @@ _audiobitrate()
## default value.
## AWK note: in "(bitrate+0 > 500)", the +0 is required to make sure bitrate is numeric.
## WARNING: mediainfo puts a space every 3 digits, hence the 'for' loop.
if command -v mediainfo >/dev/null; then
mediainfo "$1" | awk 'BEGIN {id=0} /^Audio/ { getline; while(getline && ! index($0,"Bit rate ")); if($4) res=$4; else res=0; print id, res; id++}'
mediainfo "$1" | awk 'BEGIN {id=0} /^Audio/ { getline; while(getline && ! index($0,"Bit rate ")); for(i=4; i<NF; i++) res=$i; print id, res; id++}'
else
ffmpeg -nostdin -i "$1" 2>&1 | awk 'BEGIN {id=0} /^ *Stream.*Audio/ {match($0, / [^ ]+ kb\/s/); res=substr($0, RSTART+1, RLENGTH-6); print id, res; id++}'
fi | awk -v codec="$AUDIO_CODEC" -v bitrate="$AUDIO_DEFAULT_RATE" \