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))" \
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 "$@"