@@ -1013,14 +1013,14 @@ _find_input (){
10131013 find "${LOOKHERE}" -type f -size +0 "${OBJECTS_FIND_EXCLUSIONS[@]}" | sort | while read file ; do
10141014 streamcount=$(ffprobe -loglevel quiet "$file" -show_entries format=nb_streams -of default=nw=1:nk=1)
10151015 duration_ts=$(ffprobe -loglevel quiet "$file" -show_entries stream=duration_ts -of default=nw=1:nk=1)
1016-
1017- # Cast empty value into 0 integer
1018- if [ -z "$streamcount" ]; then
1019- streamcount=0
1020- fi
1021- if [ -z "$duration_ts" ]; then
1022- duration_ts=0
1023- fi
1016+
1017+ # Cast empty value into 0 integer
1018+ if [ -z "$streamcount" ]; then
1019+ streamcount=0
1020+ fi
1021+ if [ -z "$duration_ts" ]; then
1022+ duration_ts=0
1023+ fi
10241024
10251025 if [[ "$streamcount" > 0 && "${duration_ts}" != 1 ]] ; then
10261026 _report -d "Input file: $file"
@@ -1107,18 +1107,11 @@ _find_input (){
11071107 _report -dt "Using ${SOURCEFILE} for assessment."
11081108 _report -wt "Extracting to ${MOUNTPATH}. Please unmount ${MOUNTPATH} later."
11091109 elif [[ "${SOURCEFILE#*.}" = "mkv" || "${SOURCEFILE#*.}" = "mka" ]] ; then
1110- # flag to track if presentation information is found
1111- presentation_found=false
1112- # variable to store the first file with presentation information
1113- FIRST_PRESENTATION_FILE=""
1114-
1115- # loops through each file in INPUTFILES
1116- while IFS= read -r INPUTFILE; do
11171110 # if the source file is an mkv or mka, then check if it has a Presentation Chapter Edition
1118- if [[ -n $(mkvextract tags "${INPUTFILE }" | xmlstarlet sel -t -m "/Tags/Tag/Simple[String='Presentation']" -v String) ]] ; then
1119- _report -dt "The input file ($(basename "${INPUTFILE }")) contains a Chapter Edition called 'Presentation', will use that for transcoding."
1120- LISTCHAPTERS=$(mkvextract chapters "${INPUTFILE }" | xmlstarlet sel -t -m Chapters/EditionEntry[EditionFlagDefault='1']/ChapterAtom -v ChapterTimeStart -o "-" -v ChapterTimeEnd -o "-" -v ChapterSegmentUID -n -)
1121- SegmentUIDs=$(mkvextract chapters "${INPUTFILE }" | xmlstarlet sel -t -m Chapters/EditionEntry[EditionFlagDefault='1']/ChapterAtom/ChapterSegmentUID -v . -n | sort -u)
1111+ if [[ -n $(mkvextract tags "${SOURCEFILE }" | xmlstarlet sel -t -m "/Tags/Tag/Simple[String='Presentation']" -v String) ]] ; then
1112+ _report -dt "The input file ($(basename "${SOURCEFILE }")) contains a Chapter Edition called 'Presentation', will use that for transcoding."
1113+ LISTCHAPTERS=$(mkvextract chapters "${SOURCEFILE }" | xmlstarlet sel -t -m Chapters/EditionEntry[EditionFlagDefault='1']/ChapterAtom -v ChapterTimeStart -o "-" -v ChapterTimeEnd -o "-" -v ChapterSegmentUID -n -)
1114+ SegmentUIDs=$(mkvextract chapters "${SOURCEFILE }" | xmlstarlet sel -t -m Chapters/EditionEntry[EditionFlagDefault='1']/ChapterAtom/ChapterSegmentUID -v . -n | sort -u)
11221115 if [[ -n "${LISTCHAPTERS}" ]]; then
11231116 _report -d "Found this chapter list:"
11241117 _report -d "${LISTCHAPTERS}"
@@ -1142,15 +1135,12 @@ _find_input (){
11421135 done < <(find "${MKVFOLDER}" -type f \( -name "*.mkv" -o -name "*.mka" \))
11431136 if [[ -n "${MATCHMKV}" ]]; then
11441137 INPUTFILE="$MATCHMKV"
1145- if [[ -z "${FIRST_PRESENTATION_FILE}" ]]; then
1146- FIRST_PRESENTATION_FILE="${INPUTFILE}"
1147- fi
11481138 else
11491139 echo "Error: did not find a file to match ${CHAPSEGMENTUID}"
11501140 exit
11511141 fi
11521142 else
1153- INPUTFILE="${INPUTFILE }"
1143+ INPUTFILE="${SOURCEFILE }"
11541144 fi
11551145 printf "file " >> "${FFCONCATFILE}"
11561146 printf '%q' "${INPUTFILE}" >> "${FFCONCATFILE}"
@@ -1160,18 +1150,8 @@ _find_input (){
11601150 done < <(echo "${LISTCHAPTERS}")
11611151 FFMPEGINPUT+=(-i)
11621152 FFMPEGINPUT+=("${FFCONCATFILE}")
1163- # set flag to true if presentation information is found
1164- presentation_found=true
1165- # exit loop if presentation information is found
1166- break
11671153 fi
11681154 fi
1169- done < "$INPUTFILES"
1170- # report and exit if no presentation is found
1171- if ! $presentation_found; then
1172- _report -d "No presentation chapters found in any input file."
1173- exit
1174- fi
11751155 fi
11761156}
11771157
@@ -1229,7 +1209,7 @@ _get_channel_layout(){
12291209_get_audio_mapping(){
12301210 OPTIND=1
12311211 unset PBSMIX
1232- unset ADD_VOLADJ
1212+ ADD_VOLADJ="N"
12331213 while getopts ":bvlr" OPT ; do
12341214 case "${OPT}" in
12351215 b) PBSMIX="Y" ;;
@@ -1263,8 +1243,10 @@ _get_audio_mapping(){
12631243 _add_audio_filter "[0:a:0][0:a:1]amerge,pan=stereo|c0=0.5*c0+0.5*c1|c1=0.5*c0+0.5*c1"
12641244 elif [[ "${AUDIOMAP}" = "A" ]] ; then
12651245 unset AMERGE_LIST
1266- for i in {0.."${AUDIO_TRACK_COUNT}"} ; do
1246+ C=0
1247+ while "$C" -lte "${AUDIO_TRACK_COUNT}" ; do
12671248 AMERGE_LIST+="[0:a:$i]"
1249+ ((C++))
12681250 done
12691251 _report -wt "Will mix together ${AUDIO_TRACK_COUNT} tracks into a stereo output."
12701252 _add_audio_filter -p "${AMERGE_LIST}amerge=inputs=${AUDIO_TRACK_COUNT}"
0 commit comments