From 84bd61eb9b21afacc861c9f03ea8431701538ccc Mon Sep 17 00:00:00 2001 From: James Ketrenos Date: Sat, 9 Apr 2022 02:08:37 +0000 Subject: [PATCH] Fail abort Signed-off-by: James Ketrenos --- video-convert | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/video-convert b/video-convert index 30aea53..5291b3f 100755 --- a/video-convert +++ b/video-convert @@ -1,6 +1,10 @@ #!/bin/bash # Look into HW video encoding to vp9 instead of h264: # https://www.reddit.com/r/VP9/comments/g9uzzv/hardware_encoding_vp9_on_intel/ +fail() { + echo "$*" >&2 + exit -1 +} video_detect() { for file in "${*}"; do @@ -39,8 +43,8 @@ function move { base="$(dirname "${IN}")" [ ! -d "${base}" ] && continue base=/remote/media/backup/"${base}" - [ ! -d "${base}" ] && mkdir -p "${base}" - [ -e "${base}" ] && mv "${IN}" "${base}"/ + [ ! -d "${base}" ] && mkdir -p "${base}" || fail "Unable to mkdir '${base}'" + [ -e "${base}" ] && mv "${IN}" "${base}"/ || fail "Unable to move '$IN'" } function convert { @@ -139,13 +143,11 @@ function convert { # If the original file was an '.mkv' then OUT was '.transcoded.mkv' # during transcode. Now that the transcode is complete, set the # file back to the original name. - mv "${OUT}" "${IN}" + mv "${OUT}" "${IN}" || fail "Unable to mv '${OUT}' -> '${IN}'" fi } NOW=$(date +%s) echo -e "\nCompleted in $(mstodate $(( NOW - STARTTIME ))000)" -# -vcodec copy \ -# -acodec aac \ } function check_and_convert {