From be7afa810a2d843498cfe3d93c0c3b968f7a509b Mon Sep 17 00:00:00 2001 From: Chimorin <47946984+TNFB@users.noreply.github.com> Date: Thu, 11 Jul 2024 14:16:40 +0200 Subject: [PATCH 1/8] Update run --- rootfs/etc/services.d/autovideoconverter/run | 1 + 1 file changed, 1 insertion(+) diff --git a/rootfs/etc/services.d/autovideoconverter/run b/rootfs/etc/services.d/autovideoconverter/run index 415cb1c..f0d6913 100755 --- a/rootfs/etc/services.d/autovideoconverter/run +++ b/rootfs/etc/services.d/autovideoconverter/run @@ -291,6 +291,7 @@ process_video() { # Set the temporary output directory: this is where the video will be # actually written before being moved its final location once conversion is # terminated. +##################################################################################################### OUTPUT_DIR_TMP="$(mktemp -d "$AC_OUTPUT_DIR/.XXXXXX")" if [ ! -d "$OUTPUT_DIR_TMP" ]; then hb_rc=1 From b377034ad6418dc1987464140d3bd87d6427a9cb Mon Sep 17 00:00:00 2001 From: Chimorin <47946984+TNFB@users.noreply.github.com> Date: Thu, 11 Jul 2024 14:20:12 +0200 Subject: [PATCH 2/8] Update Dockerfile Add AUTOMATED_CONVERSION_OUTPUT_TEMP envvar --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 0d09318..3d95d99 100644 --- a/Dockerfile +++ b/Dockerfile @@ -155,6 +155,7 @@ ENV \ AUTOMATED_CONVERSION_KEEP_SOURCE=1 \ AUTOMATED_CONVERSION_OUTPUT_DIR=/output \ AUTOMATED_CONVERSION_OUTPUT_SUBDIR= \ + AUTOMATED_CONVERSION_OUTPUT_TEMP= \ AUTOMATED_CONVERSION_OVERWRITE_OUTPUT=0 \ AUTOMATED_CONVERSION_VIDEO_FILE_EXTENSIONS= \ AUTOMATED_CONVERSION_NON_VIDEO_FILE_ACTION=ignore \ From b8d85affaac1cc19947ae3fd13a9d066397a8c5f Mon Sep 17 00:00:00 2001 From: Chimorin <47946984+TNFB@users.noreply.github.com> Date: Thu, 11 Jul 2024 14:24:49 +0200 Subject: [PATCH 3/8] Update run --- rootfs/etc/services.d/autovideoconverter/run | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/rootfs/etc/services.d/autovideoconverter/run b/rootfs/etc/services.d/autovideoconverter/run index f0d6913..d097275 100755 --- a/rootfs/etc/services.d/autovideoconverter/run +++ b/rootfs/etc/services.d/autovideoconverter/run @@ -292,12 +292,17 @@ process_video() { # actually written before being moved its final location once conversion is # terminated. ##################################################################################################### - OUTPUT_DIR_TMP="$(mktemp -d "$AC_OUTPUT_DIR/.XXXXXX")" - if [ ! -d "$OUTPUT_DIR_TMP" ]; then - hb_rc=1 - log "ERROR: Failed to create temporary directory under '$AC_OUTPUT_DIR'." - break + if echo "$AC_VIDEO_FILE_EXTENSIONS"; then + FILE_EXT_IN_VIDEO_LIST=true + else + OUTPUT_DIR_TMP="$(mktemp -d "$AC_OUTPUT_DIR/.XXXXXX")" + if [ ! -d "$OUTPUT_DIR_TMP" ]; then + hb_rc=1 + log "ERROR: Failed to create temporary directory under '$AC_OUTPUT_DIR'." + break + fi fi + # Set the temporary output filename. OUTPUT_FILE_TMP="$OUTPUT_DIR_TMP/$basename.$AC_FORMAT" From 5381a418b9d2a34391a05b63bfe52b1661940069 Mon Sep 17 00:00:00 2001 From: Chimorin <47946984+TNFB@users.noreply.github.com> Date: Thu, 11 Jul 2024 14:41:28 +0200 Subject: [PATCH 4/8] Update run Add AC_OUTPUT_TEMP --- rootfs/etc/services.d/autovideoconverter/run | 61 +++++++++++++------- 1 file changed, 41 insertions(+), 20 deletions(-) diff --git a/rootfs/etc/services.d/autovideoconverter/run b/rootfs/etc/services.d/autovideoconverter/run index d097275..bb2d789 100755 --- a/rootfs/etc/services.d/autovideoconverter/run +++ b/rootfs/etc/services.d/autovideoconverter/run @@ -291,18 +291,24 @@ process_video() { # Set the temporary output directory: this is where the video will be # actually written before being moved its final location once conversion is # terminated. -##################################################################################################### - if echo "$AC_VIDEO_FILE_EXTENSIONS"; then - FILE_EXT_IN_VIDEO_LIST=true - else - OUTPUT_DIR_TMP="$(mktemp -d "$AC_OUTPUT_DIR/.XXXXXX")" - if [ ! -d "$OUTPUT_DIR_TMP" ]; then - hb_rc=1 - log "ERROR: Failed to create temporary directory under '$AC_OUTPUT_DIR'." - break - fi - fi - + case "$AC_OUTPUT_TEMP" in + UNSET) + OUTPUT_DIR_TMP="$(mktemp -d "$AC_OUTPUT_DIR/.XXXXXX")" + if [ ! -d "$OUTPUT_DIR_TMP" ]; then + hb_rc=1 + log "ERROR: Failed to create temporary directory under '$AC_OUTPUT_DIR'." + break + fi + ;; + *) + OUTPUT_DIR_TMP="/output_tmp" + if [ ! -d "$OUTPUT_DIR_TMP" ]; then + hb_rc=1 + log "ERROR: Failed to create temporary directory under '$AC_OUTPUT_TEMP'." + break + fi + ;; + esac # Set the temporary output filename. OUTPUT_FILE_TMP="$OUTPUT_DIR_TMP/$basename.$AC_FORMAT" @@ -417,14 +423,29 @@ process_watch_folder() { log "ERROR: Cannot process watch folder '$WF', because the associated output directory '$AC_OUTPUT_DIR' doesn't exist." return else - TMPFILE="$(mktemp "$AC_OUTPUT_DIR"/.test_XXXXXX 2>/dev/null)" - RC=$? - if [ "$RC" -eq 0 ]; then - rm "$TMPFILE" - else - log "ERROR: Cannot process watch folder '$WF', because the associated output directory '$AC_OUTPUT_DIR' is not writable." - return - fi + case "$AC_OUTPUT_TEMP" in + UNSET) + TMPFILE="$(mktemp "$AC_OUTPUT_DIR"/.test_XXXXXX 2>/dev/null)" + RC=$? + if [ "$RC" -eq 0 ]; then + rm "$TMPFILE" + else + log "ERROR: Cannot process watch folder '$WF', because the associated output directory '$AC_OUTPUT_DIR' is not writable." + return + fi + ;; + *) + TMPFILE="$(mktemp /output_tmp/.test_XXXXXX 2>/dev/null)" + RC=$? + if [ "$RC" -eq 0 ]; then + rm "$TMPFILE" + else + log "ERROR: Cannot process watch folder '$WF', because the associated output directory '$AC_OUTPUT_TEMP' is not writable." + return + fi + ;; + esac + fi if WATCHDIR_HASH_isset "$WF"; then From e808e0187da741719a399fcf3ba15ee622e7e822 Mon Sep 17 00:00:00 2001 From: Chimorin <47946984+TNFB@users.noreply.github.com> Date: Thu, 11 Jul 2024 14:42:40 +0200 Subject: [PATCH 5/8] Update Dockerfile add volume /output_tmp --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 3d95d99..a7fb242 100644 --- a/Dockerfile +++ b/Dockerfile @@ -170,6 +170,7 @@ ENV \ # Define mountable directories. VOLUME ["/storage"] VOLUME ["/output"] +VOLUME ["/output_tmp"] VOLUME ["/watch"] VOLUME ["/trash"] From e19e046f84a0063acc9320cd061c3ac625f5421e Mon Sep 17 00:00:00 2001 From: Chimorin <47946984+TNFB@users.noreply.github.com> Date: Thu, 11 Jul 2024 16:00:25 +0200 Subject: [PATCH 6/8] Update run set AC_OUTPUT_TEMP --- rootfs/etc/services.d/autovideoconverter/run | 1 + 1 file changed, 1 insertion(+) diff --git a/rootfs/etc/services.d/autovideoconverter/run b/rootfs/etc/services.d/autovideoconverter/run index bb2d789..c4cbf71 100755 --- a/rootfs/etc/services.d/autovideoconverter/run +++ b/rootfs/etc/services.d/autovideoconverter/run @@ -529,6 +529,7 @@ while true; do AC_SOURCE_MAIN_TITLE_DETECTION="${AUTOMATED_CONVERSION_SOURCE_MAIN_TITLE_DETECTION:-0}" AC_OUTPUT_DIR="${AUTOMATED_CONVERSION_OUTPUT_DIR:-/output}" AC_OUTPUT_SUBDIR="${AUTOMATED_CONVERSION_OUTPUT_SUBDIR:-UNSET}" + AC_OUTPUT_TEMP="${AUTOMATED_CONVERSION_OUTPUT_TEMP:-UNSET}" AC_KEEP_SOURCE="${AUTOMATED_CONVERSION_KEEP_SOURCE:-1}" AC_VIDEO_FILE_EXTENSIONS="${AUTOMATED_CONVERSION_VIDEO_FILE_EXTENSIONS:-}" AC_NON_VIDEO_FILE_ACTION="${AUTOMATED_CONVERSION_NON_VIDEO_FILE_ACTION:-ignore}" From dcdef965f23db652fbee638845f2e15adceb8a77 Mon Sep 17 00:00:00 2001 From: Chimorin <47946984+TNFB@users.noreply.github.com> Date: Thu, 11 Jul 2024 16:50:58 +0200 Subject: [PATCH 7/8] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 51fadf0..0d01ae3 100644 --- a/README.md +++ b/README.md @@ -152,6 +152,7 @@ of this parameter has the format `=`. |`AUTOMATED_CONVERSION_NON_VIDEO_FILE_EXTENSIONS`| Space-separated list of file extensions to be considered as not being videos. Most non-video files are properly rejected by HandBrake. However, some files, like images, are convertible by HandBrake even if they are not video files. | `jpg jpeg bmp png gif txt nfo` | |`AUTOMATED_CONVERSION_OUTPUT_DIR`| Root directory, inside the container, where converted videos should be written. **NOTE**: Make sure a volume mapping for this directory is defined when creating the container. | `/output` | |`AUTOMATED_CONVERSION_OUTPUT_SUBDIR`| Subdirectory of the output folder into which converted videos should be written. By default, this variable is not set, meaning that videos are saved directly into `/output/`. If `Home/Movies` is set, converted videos will be written to `/output/Home/Movies`. Use the special value `SAME_AS_SRC` to use the same subfolder as the source. For example, if the video source file is `/watch/Movies/mymovie.mkv`, the converted video will be written to `/output/Movies/`. | (no value) | +|`AUTOMATED_CONVERSION_OUTPUT_TEMP`| If unset, Handbrake will create a temp folder .XXXXXX inside /output directory. When set to specific path **ON THE HOST**, temporary files will get written inside (in a subdir .XXXXXX) before being moved to /output. | `(no value)` | |`AUTOMATED_CONVERSION_OVERWRITE_OUTPUT`| Setting this to `1` allows the final destination file to be overwritten if it already exists. | `0` | |`AUTOMATED_CONVERSION_SOURCE_STABLE_TIME`| Time (in seconds) during which properties (e.g. size, time, etc) of a video file in the watch folder need to remain the same. This is to avoid processing a file that is being copied. | `5` | |`AUTOMATED_CONVERSION_SOURCE_MIN_DURATION`| Minimum title duration (in seconds). Shorter titles will be ignored. This applies only to video disc sources (ISO file, `VIDEO_TS` folder or `BDMV` folder). | `10` | From 33a26cfb198d48ed4d8b28d540a4cbcd7114a7a2 Mon Sep 17 00:00:00 2001 From: Chimorin <47946984+TNFB@users.noreply.github.com> Date: Thu, 11 Jul 2024 16:53:25 +0200 Subject: [PATCH 8/8] Update run --- rootfs/etc/services.d/autovideoconverter/run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rootfs/etc/services.d/autovideoconverter/run b/rootfs/etc/services.d/autovideoconverter/run index c4cbf71..5676b52 100755 --- a/rootfs/etc/services.d/autovideoconverter/run +++ b/rootfs/etc/services.d/autovideoconverter/run @@ -301,7 +301,7 @@ process_video() { fi ;; *) - OUTPUT_DIR_TMP="/output_tmp" + OUTPUT_DIR_TMP="$(mktemp -d "/output_tmp/.XXXXXX")" if [ ! -d "$OUTPUT_DIR_TMP" ]; then hb_rc=1 log "ERROR: Failed to create temporary directory under '$AC_OUTPUT_TEMP'."