littlejeem / control_scripts

A collection of scripts that control functions, primarily on my media pc
GNU General Public License v3.0
0 stars 0 forks source link

BD_ripping.sh - issue with the method of choosing correct audio #13

Closed littlejeem closed 2 years ago

littlejeem commented 2 years ago

The section for determining availiable audio and choosing the correct audio based on hierarchical preferences is flawed when there are two available tracks of same quality availiable in the same title.

#+----------------------------------+
#+---"Determine Availiable Audio"---+
#+----------------------------------+
#First we search the file for the line number of our preferred source because line number = track number of the audio
#these tests produce boolean returns
#First lets test for uncompressed LPCM
BD_lpcm=$(grep -hn "BD LPCM" parsed_audio_tracks | cut -c1)
[[ ! -z "$BD_lpcm" ]] && edebug "BD LPCM detected, track: $BD_lpcm" || edebug "BD LPCM not detected"
#Check for True_HD
True_HD=$(grep -hn "TrueHD" parsed_audio_tracks | cut -c1)
[[ ! -z "$True_HD" ]] && edebug "True HD detected, track: $True_HD" || edebug "True_HD not detected"
#Now lets test for DTS-HD
Dts_hd=$(grep -hn "DTS-HD" parsed_audio_tracks)
Dts_hd=$(echo $Dts_hd | cut -c1)
[[ ! -z "$Dts_hd" ]] && edebug "DTS-HD detected, track: $Dts_hd" || edebug "DTS-HD not detected"
#Now lets test for DTS
Dts=$(grep -hn "(DTS)" parsed_audio_tracks)
Dts=$(echo $Dts | cut -c1)
[[ ! -z "$Dts" ]] && edebug "DTS detected, track: $Dts" || edebug "DTS not detected"
#Finally lets test for AAC
Ac3=$(grep -hn "AC3" parsed_audio_tracks)
Ac3=$(echo $Ac3 | cut -c1)
[[ ! -z "$Ac3" ]] && edebug "AC3 detected, track: $Ac3" || edebug "AC3 not detected"
#
#
#+------------------------------+
#+---"Determine 'Best' Audio"---+
#+------------------------------+
#Now we make some decisons about audio choices
# if its present always prefer: TrueHD, if not; DTS-HD, if not; BD LPCM; if not DTS. if none of the above then AC3,
if [[ ! -z "$True_HD" ]]; then #true = TrueHD
  selected_audio_track=$(echo $True_HD)
  edebug "Selecting True_HD audio, track $True_HD"
elif [[ ! -z "$True_HD" ]] && [[ ! -z "$Dts_hd" ]]; then #true false = TrueHD
  selected_audio_track=$(echo $True_HD)
  edebug "Selecting True_HD audio, track $True_HD"
elif [[ -z "$True_HD" ]] && [[ ! -z "$Dts_hd" ]]; then #false true = DTS-HD
  selected_audio_track=$(echo $Dts_hd)
  edebug "Selecting DTS-HD audio, track $Dts_hd"
elif [[ ! -z "$BD_lpcm" ]] && [[ -z "$True_HD" ]] && [[ -z "$Dts_hd" ]]; then #true false false = BD LPCM
  selected_audio_track=$(echo $BD_lpcm)
  edebug "Selecting BD LPCM audio, track $BD_lpcm"
elif [[ -z "$True_HD" ]] && [[ -z "$Dts_hd" ]] && [[ -z "$BD_lpcm" ]] && [[ ! -z "$Dts" ]]; then #false false false true = DTS
  selected_audio_track=$(echo $Dts)
  edebug "Selecting DTS audio, track $Dts"
elif [[ -z "$True_HD" ]] && [[ -z "$Dts_hd" ]] && [[ -z "$BD_lpcm" ]] && [[ -z "$Dts" ]]; then #false false false false = AC3 (default)
  selected_audio_track=1
  edebug "no matches for audio types, defaulting to track 1"
fi
#
#insert the audio selection into the audio_options variable, something different wiht BD_lpcm if selected as cannot be passed thru
if [[ ! -z $BD_lpcm ]]; then
  audio_options="-a $selected_audio_track -E flac24 --mixdown 5point1"
else
  audio_options="-a $selected_audio_track -E copy --audio-copy-mask dtshd,truehd,dts,flac"
fi
edebug "audio options passed to HandBrakeCLI are: $audio_options"