2 # Desc: Reèˆncodes .mp4 videos in a specified directory.
3 # Usage: mp4_make480.sh [dir in] [dir out]
4 # Input: arg1 dir input dir
5 # arg2 dir output dir (optional)
7 # file ./out/[files]_480.mp4
9 # Depends: GNU parallel 20161222, ffmpeg 4.3.6-0
10 # Ref/Attrb: [1]: FFmpeg wiki: https://trac.ffmpeg.org/wiki/Scaling
11 declare -g dir_in dir_out
;
15 if [[ $# -le 0 ]]; then echo "FATAL:Insufficient args:$#" 1>&2; exit 1; fi;
16 if [[ $# -eq 2 ]]; then
22 if [[ ! -d "$dir_in" ]]; then echo "FATAL:Not a dir:$dir_in" 1>&2; exit 1; fi;
24 declare -p dir_in dir_out
; # debug
27 find "$dir_in" -mindepth 1 -maxdepth 1 -type f
-name "*.mp4" | \
28 parallel job_ffmpeg
"{}" "$path_out";
33 file_in
="$(basename "$path_in")";
34 path_out
=.
/"$dir_out"/"${file_in%.mp4}"_480.mp4
;
35 opt_scale
="scale=-2:480"; # See [1]
36 declare -p path_in path_out file_in dir_out path_out opt_scale
;
37 ffmpeg
-nostdin -i "$path_in" -vf "$opt_scale" -c:a copy
"$path_out" 1>/dev
/random
2>&1;
48 # Author: Steven Baltakatei Sandoval