From 8cfbb41e63dbb416030e3a9ad4b50691b3289901 Mon Sep 17 00:00:00 2001 From: James Bunton Date: Thu, 25 Oct 2018 08:48:48 +1100 Subject: [PATCH] fix-pal-speedup: don't try to adjust chapter-sync if there are zero chapters This stops mkvmerge from exiting with an error --- fix-pal-speedup | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/fix-pal-speedup b/fix-pal-speedup index 4fb9dcb..51ab6ed 100755 --- a/fix-pal-speedup +++ b/fix-pal-speedup @@ -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 "$@" -- 2.39.2