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 - Wrong audio encoding options if both BD_LPCM and DTS-HD found #16

Closed littlejeem closed 2 years ago

littlejeem commented 2 years ago

Desired behaviour is to set handbrakes audio encoding options based on whether BD_LPCM of not (BD_LPCM) not able to be passed through in the handbrakes filter. Issue is with this logic here:

if [[ ! -z $bdlpcm_track_list ]]; 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

This is essentially saying that if the $bdlpcm_track_list array has content choose the flac encoding line. The problem becomes if both bdlpcm_track_list has content and so does $dtshd_track_list flac will be chosen and not pass thru.

Solution would be to look at the chosen audio from:

if [[ ! -z "$truehd_track_list" ]]; then #true = TrueHD
  selected_audio_track=$truehd_track_list
  einfo "Selecting True_HD audio on $truehd_text $truehd_track_list"
  audio_codec="TrueHD"
elif [[ ! -z "$truehd_track_list" ]] && [[ ! -z "$dtshd_track_list" ]]; then #true false = TrueHD
  selected_audio_track=$truehd_track_list
  einfo "Selecting True_HD audio on $truehd_text $truehd_track_list"
  audio_codec="TrueHD"
elif [[ -z "$truehd_track_list" ]] && [[ ! -z "$dtshd_track_list" ]]; then #false true = DTS-HD
  selected_audio_track=$dtshd_track_list
  einfo "Selecting DTS-HD audio on $dtshd_text $dtshd_track_list"
  audio_codec="DTS-HD"
elif [[ ! -z "$bdlpcm_track_list" ]] && [[ -z "$truehd_track_list" ]] && [[ -z "$dtshd_track_list" ]]; then #true false false = BD LPCM
  selected_audio_track=$bdlpcm_track_list
  einfo "Selecting BD LPCM audio on $bdlpcm_text $bdlpcm_track_list"
  audio_codec="FLAC"
elif [[ -z "$truehd_track_list" ]] && [[ -z "$dtshd_track_list" ]] && [[ -z "$bdlpcm_track_list" ]] && [[ ! -z "$dts_track_list" ]]; then #false false false true = DTS
  selected_audio_track=$dts_track_list
  einfo "Selecting DTS audio on $dts_text $dts_track_list"
  audio_codec="DTS"
elif [[ -z "$truehd_track_list" ]] && [[ -z "$dtshd_track_list" ]] && [[ -z "$bdlpcm_track_list" ]] && [[ -z "$dts_track_list" ]] && [[ ! -z "$ac3_51_track_list" ]]; then #false, false, flase, false = AC3 5.1
  selected_audio_track=$ac3_51_track_list
  einfo "Selecting AC3 5.1 audio on $ac3_51_text $ac3_51_track_list"
  audio_codec="AC-3"
elif [[ -z "$truehd_track_list" ]] && [[ -z "$dtshd_track_list" ]] && [[ -z "$bdlpcm_track_list" ]] && [[ -z "$dts_track_list" ]] && [[ -z "$ac3_51_track_list" ]]; then #false false false false false false = AC3 (default)
  selected_audio_track=${ac3_array[0]}
  einfo "no matches for preferred audio types, defaulting to first AC3 track: ${ac3_array[0]}"
  audio_codec="AC-3"
fi

And potentially alter test to look at one of these options?