From 27c0d929cf9b0ea0a2fb735978e9db36aec837dc Mon Sep 17 00:00:00 2001
From: Steven Baltakatei Sandoval <baltakatei@gmail.com>
Date: Thu, 11 Apr 2024 13:55:03 +0000
Subject: [PATCH 1/1] feat(user/mp4_make480.sh):Add script to convert video to
 480 res

---
 user/mp4_make480.sh | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 user/mp4_make480.sh

diff --git a/user/mp4_make480.sh b/user/mp4_make480.sh
new file mode 100644
index 0000000..8fc75ed
--- /dev/null
+++ b/user/mp4_make480.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+# Desc: Reëncodes .mp4 videos in a specified directory.
+# Usage: mp4_make480.sh [dir]
+# Output: dir   ./out/
+#         file  ./out/[files]_480.mp4
+# Version: 0.0.1
+
+dir_in="$1";
+dir_out="./out";
+if [[ $# -ne 1 ]]; then echo "FATAL:No dir specified." 1>&2; exit 1; fi;
+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
+
+while read -r line; do
+    path_out=./"$dir_out"/"${line%.mp4}"_480.mp4;
+    declare -p line path_out;  # debug
+    ffmpeg -nostdin -i "$dir_in" -vf "scale=-2:480" -c:a copy "$path_out";
+done < <(find . -mindepth 1 -maxdepth 1 -type f -name "*.mp4")
-- 
2.39.5