@@ -102,6 +102,14 @@ log_hb_encode_progress_yad() {
102102 2> /dev/null
103103}
104104
105+ log_hb_encode_detect_success () {
106+ while read -r OUTPUT; do
107+ if [ " $OUTPUT " = " Encode done!" ]; then
108+ touch " $1 "
109+ fi
110+ done
111+ }
112+
105113WATCHDIR_HASH_calculate () {
106114 local watchdir=" $1 "
107115 find " $watchdir " -follow -type f -not -path ' */\.*' -printf ' %T@:%s:%p:%m\n' | md5sum | cut -d' ' -f1
@@ -435,8 +443,8 @@ process_video() {
435443 $title_arg \
436444 --preset " $AC_PRESET " \
437445 $HANDBRAKE_HOOK_CUSTOM_ARGS \
438- $AC_HANDBRAKE_CUSTOM_ARGS 2>> \
439- /config/log/hb/conversion.log | \
446+ $AC_HANDBRAKE_CUSTOM_ARGS \
447+ 2> >( tee -a /config/log/hb/conversion.log | log_hb_encode_detect_success " $OUTPUT_FILE_TMP " .success ) | \
440448 /usr/bin/unbuffer -p grep " ^Encoding" | \
441449 stdbuf -oL cut -d' ' -f2- | \
442450 tee >( log_hb_encode_progress) >( log_hb_encode_progress_yad) > /dev/null
@@ -445,9 +453,11 @@ process_video() {
445453 # Close YAD window.
446454 killall -SIGUSR1 yad 2> /dev/null
447455
448- # Make sure the output file has been generated.
449- if [ $hb_rc -eq 0 ] && [ ! -f " $OUTPUT_FILE_TMP " ]; then
450- hb_rc=1
456+ # Make sure the video has been converted successfully.
457+ if [ $hb_rc -eq 0 ]; then
458+ if [ ! -f " $OUTPUT_FILE_TMP " ] || [ ! -f " $OUTPUT_FILE_TMP " .success ]; then
459+ hb_rc=1
460+ fi
451461 fi
452462
453463 # Move the file to its final location if conversion terminated
0 commit comments