From c2be0112fbfe02496bcadb8e205350f5683ac74b Mon Sep 17 00:00:00 2001 From: Levon Gevorgyan Date: Wed, 4 Mar 2026 18:55:09 -0600 Subject: [PATCH] handle when crop values are all 0 and supmover minimally warning about cropping --- lib/encode.sh | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/lib/encode.sh b/lib/encode.sh index 585ca51..05ee000 100644 --- a/lib/encode.sh +++ b/lib/encode.sh @@ -266,24 +266,32 @@ setup_pgs_mkv() { right=${left} bottom=${top} fi - # crop sup - ( - set -x - "${SUPMOVER}" \ - "${ogSup}" \ - "${cropSup}" \ - --crop \ - "${left}" "${top}" "${right}" "${bottom}" &>"${cropSup}.out" || return 1 - ) - local cropRet=$? - # supmover does not error for out-of-bounds subtitles - if grep 'Window is outside new screen area' "${cropSup}.out"; then - echo_fail "check ${cropSup}.out for complete logs" - cropRet=1 - fi - if [[ ${cropRet} -ne 0 ]]; then - rm -r "${tmpdir}" || return 1 - return 1 + + # only crop if actually required + if [[ "${left}${top}${right}${bottom}" != "0000" ]]; then + # crop sup + ( + set -x + "${SUPMOVER}" \ + "${ogSup}" \ + "${cropSup}" \ + --crop \ + "${left}" "${top}" "${right}" "${bottom}" &>"${cropSup}.out" || return 1 + ) + local cropRet=$? + # supmover does not error for out-of-bounds subtitles + # so error only when there is most certainly an issue + if [[ "$(grep -c 'Window is outside new screen area' "${cropSup}.out")" -gt 5 ]]; then + echo_fail "check ${cropSup}.out for complete logs" + cropRet=1 + fi + if [[ ${cropRet} -ne 0 ]]; then + rm -r "${tmpdir}" || return 1 + return 1 + fi + else + # create placeholder copy for replacement + cp "${ogSup}" "${cropSup}" || return 1 fi else # create placeholder copy for replacement