]> code.delx.au - transcoding/commitdiff
fix-pal-speedup: don't try to adjust chapter-sync if there are zero chapters
authorJames Bunton <jamesbunton@delx.net.au>
Wed, 24 Oct 2018 21:48:48 +0000 (08:48 +1100)
committerJames Bunton <jamesbunton@delx.net.au>
Wed, 24 Oct 2018 21:49:13 +0000 (08:49 +1100)
This stops mkvmerge from exiting with an error

fix-pal-speedup

index 4fb9dcbf3b9dae3295445e917346deac19697e0a..51ab6ed52fcacf4742c489eec58bc2cc458aaaf5 100755 (executable)
@@ -59,11 +59,16 @@ function remux_file {
         suboptions+=("--sync" "${subtitletrackid}:0,${OLDFPS}/${NEWFPS}")
     done < <(get_track_id "$infile" "subtitles")
 
+    local chapteroptions=()
+    if [ "$(get_chapter_count "$infile")" -gt 0 ]; then
+        chapteroptions=("--chapter-sync" "0,${OLDFPS}/${NEWFPS}")
+    fi
+
     mkvmerge \
         -o "${outfile}" \
         --default-duration "${videotrackid}:${NEWFPS}fps" \
         --sync "${videotrackid}:$((videodelay / 1000000))" \
-        --chapter-sync "0,${OLDFPS}/${NEWFPS}" \
+        "${chapteroptions[@]}" \
         "${suboptions[@]}" \
         --no-audio "$infile" \
         --sync "0:$((audiodelay / 1000000))" \
@@ -78,4 +83,8 @@ function get_minimum_timestamp {
     mkvmerge -i -F json "$1" | jq -r ".tracks[] | select(.type == \"$2\") | .properties.minimum_timestamp"
 }
 
+function get_chapter_count {
+    mkvmerge -i -F json "$1" | jq -r ".chapters | length"
+}
+
 main "$@"