From: James Bunton Date: Wed, 24 Oct 2018 21:48:48 +0000 (+1100) Subject: fix-pal-speedup: don't try to adjust chapter-sync if there are zero chapters X-Git-Url: https://code.delx.au/transcoding/commitdiff_plain/8cfbb41e63dbb416030e3a9ad4b50691b3289901 fix-pal-speedup: don't try to adjust chapter-sync if there are zero chapters This stops mkvmerge from exiting with an error --- 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 "$@"