From 6ea558f92d6385b2f6d1f7677a74ef7f573335bb Mon Sep 17 00:00:00 2001 From: Steven Baltakatei Sandoval Date: Sat, 11 Jul 2026 00:32:46 +0000 Subject: [PATCH] feat(user/mp4_make_small.sh):Do not assume din is pwd - feat(user/mp4_make_480.sh): Also add start and end time stats. --- user/mp4_make_480.sh | 14 ++++++++++---- user/mp4_make_small.sh | 16 +++++++++++----- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/user/mp4_make_480.sh b/user/mp4_make_480.sh index 45760e2..9d23f77 100755 --- a/user/mp4_make_480.sh +++ b/user/mp4_make_480.sh @@ -5,21 +5,22 @@ # arg2 dir output dir (optional) # Output: dir ./out/ # file ./out/[files]_480.mp4 -# Version: 0.1.4 +# Version: 0.1.6 # Depends: GNU parallel 20161222, ffmpeg 4.3.6-0 # Ref/Attrb: [1]: FFmpeg wiki: https://trac.ffmpeg.org/wiki/Scaling declare -g dir_in dir_out; check_input() { dir_in="$1"; + if [[ ! -d "$dir_in" ]]; then echo "FATAL:Not a dir:$dir_in" 1>&2; exit 1; fi; if [[ $# -le 0 ]]; then echo "FATAL:Insufficient args:$#" 1>&2; exit 1; fi; if [[ $# -eq 2 ]]; then dir_out="$2"; else - dir_out="./out_480"; + dir_out="${dir_in}/out_480"; fi; export dir_out; - if [[ ! -d "$dir_in" ]]; then echo "FATAL:Not a dir:$dir_in" 1>&2; exit 1; fi; + mkdir -p "$dir_out"; declare -p dir_in dir_out; # debug }; @@ -31,7 +32,7 @@ job_ffmpeg() { path_in="$1"; path_out="$2"; file_in="$(basename "$path_in")"; - path_out=./"$dir_out"/"${file_in%.[mM][pP]4}"_480.mp4; + path_out="${dir_out}/${file_in%.[mM][pP]4}"_480.mp4; opt_scale="scale=-2:480"; # See [1] declare -p path_in path_out file_in dir_out path_out opt_scale; ffmpeg -nostdin -i "$path_in" -vf "$opt_scale" "$path_out"; @@ -39,8 +40,13 @@ job_ffmpeg() { export -f job_ffmpeg; main() { + SECONDS=0; + ti="$(date -Is)"; check_input "$@"; convert_video; + tf="$(date -Is)"; + printf "%s\n" "STATUS:Finished in $SECONDS seconds with status $?."; + printf "%s\n%s\n%s\n" "STATUS:Job start and end times:" "$ti" "$f"; }; main "$@"; diff --git a/user/mp4_make_small.sh b/user/mp4_make_small.sh index 75346f4..fbe79e2 100755 --- a/user/mp4_make_small.sh +++ b/user/mp4_make_small.sh @@ -5,21 +5,22 @@ # arg2 dir output dir (optional) # Output: dir ./out/ # file ./out/[files]_small.mp4 -# Version: 0.0.1 +# Version: 0.0.3 # Depends: GNU parallel 20231122, ffmpeg 6.1.1 # Ref/Attrb: declare -g dir_in dir_out; check_input() { dir_in="$1"; + if [[ ! -d "$dir_in" ]]; then echo "FATAL:Not a dir:$dir_in" 1>&2; exit 1; fi; if [[ $# -le 0 ]]; then echo "FATAL:Insufficient args:$#" 1>&2; exit 1; fi; if [[ $# -eq 2 ]]; then dir_out="$2"; else - dir_out="./out_small"; + dir_out="${dir_in}/out_small"; fi; export dir_out; - if [[ ! -d "$dir_in" ]]; then echo "FATAL:Not a dir:$dir_in" 1>&2; exit 1; fi; + mkdir -p "$dir_out"; declare -p dir_in dir_out; # debug }; @@ -31,16 +32,21 @@ job_ffmpeg() { path_in="$1"; path_out="$2"; file_in="$(basename "$path_in")"; - path_out=./"$dir_out"/"${file_in%.[mM][pP]4}"_small.mp4; + path_out="${dir_out}/${file_in%.[mM][pP]4}"_small.mp4; - declare -p path_in path_out file_in dir_out path_out opt_scale; + declare -p path_in path_out file_in dir_out path_out; ffmpeg -nostdin -i "$path_in" -c:v libx264 -preset veryslow -crf 26 -pix_fmt yuv420p "$path_out"; }; export -f job_ffmpeg; main() { + SECONDS=0; + ti="$(date -Is)"; check_input "$@"; convert_video; + tf="$(date -Is)"; + printf "%s\n" "STATUS:Finished in $SECONDS seconds with status $?."; + printf "%s\n%s\n%s\n" "STATUS:Job start and end times:" "$ti" "$f"; }; main "$@"; -- 2.39.5