8fc75ed046db6372515ea4344d4a9867ab765b21
[BK-2020-03.git] / user / mp4_make480.sh
1 #!/bin/bash
2 # Desc: Reèˆncodes .mp4 videos in a specified directory.
3 # Usage: mp4_make480.sh [dir]
4 # Output: dir ./out/
5 # file ./out/[files]_480.mp4
6 # Version: 0.0.1
7
8 dir_in="$1";
9 dir_out="./out";
10 if [[ $# -ne 1 ]]; then echo "FATAL:No dir specified." 1>&2; exit 1; fi;
11 if [[ ! -d "$dir_in" ]]; then echo "FATAL:Not a dir:$dir_in" 1>&2; exit 1; fi;
12 mkdir -p "$dir_out";
13 declare -p dir_in dir_out; # debug
14
15 while read -r line; do
16 path_out=./"$dir_out"/"${line%.mp4}"_480.mp4;
17 declare -p line path_out; # debug
18 ffmpeg -nostdin -i "$dir_in" -vf "scale=-2:480" -c:a copy "$path_out";
19 done < <(find . -mindepth 1 -maxdepth 1 -type f -name "*.mp4")