feat(user/mp4_make480.sh):Add script to convert video to 480 res
[BK-2020-03.git] / user / mp4_make480.sh
CommitLineData
27c0d929
SBS
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
8dir_in="$1";
9dir_out="./out";
10if [[ $# -ne 1 ]]; then echo "FATAL:No dir specified." 1>&2; exit 1; fi;
11if [[ ! -d "$dir_in" ]]; then echo "FATAL:Not a dir:$dir_in" 1>&2; exit 1; fi;
12mkdir -p "$dir_out";
13declare -p dir_in dir_out; # debug
14
15while 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";
19done < <(find . -mindepth 1 -maxdepth 1 -type f -name "*.mp4")