From 375712a07d7daa446539fc24e21d2bebcb4c2ffc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20V=C3=A1squez=20P=C3=A9rez?= Date: Fri, 9 Nov 2018 10:26:08 -0800 Subject: [PATCH] Added argument parsing for setting custom size and custom video bitrate. --- bash/make_h264.sh | 59 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 55 insertions(+), 4 deletions(-) diff --git a/bash/make_h264.sh b/bash/make_h264.sh index 4727872..c8e257d 100755 --- a/bash/make_h264.sh +++ b/bash/make_h264.sh @@ -1,6 +1,57 @@ +while getopts "s:b:" opt; do + case ${opt} in + s ) + height=$OPTARG + ;; + b ) + videorate=$OPTARG + ;; + \? ) + echo "Invalid option: $OPTARG" 1>&2 + ;; + : ) + echo "Invalid option: $OPTARG requires an argument" 1>&2 + ;; + esac +done + +shift "$(($OPTIND -1))" + g=6; -vb=16M; -for i; - do ffmpeg -i "$i" -c:v libx264 -x264opts keyint=$g:scenecut=-1 -profile:v main -pix_fmt yuv420p -q 0 -strict -2 -vb $vb "${i%.*}_h264.mov" ; -done; + + +if [ -z "$videorate" ] +then + vb=16M; +else + vb=$videorate; +fi + + +if [ -z "$height" ] +then + for i; + do ffmpeg -i "$i" -c:v libx264 -x264opts keyint=$g:scenecut=-1 -profile:v main -pix_fmt yuv420p -q 0 -strict -2 -vb $vb -y "${i%.*}_h264.mp4" ; + done; +else + width=$(($height*16/9)) + for i; + do ffmpeg -i "$i" -s $width'x'$height -c:v libx264 -x264opts keyint=$g:scenecut=-1 -profile:v main -pix_fmt yuv420p -q 0 -strict -2 -vb $vb -y "${i%.*}_"$width"x"$height"_h264.mp4" ; + done; +fi + +#/Volumes/pegasus/01_PROJECTS/18060_DSDC035_25_Days_Of_Christmas_2018/09_Graphics/05_Graphics_Output/01_GFX_Scenes/103018 + +get_project_base () { + dir=$(pwd) + IFS='/' read -r a discs_root disc folder project a <<<"$dir" + echo "/$discs_root/$disc/$folder/$project" +} +get_todays_review_folder (){ + base=$(get_project_base) + review_folder=$(ls $base | grep -i review) + echo $base/$review_folder +} + +#get_todays_review_folder