Last active
August 29, 2015 14:12
-
-
Save andrenarchy/d70b8f636139bccc70a4 to your computer and use it in GitHub Desktop.
Converts a dir with videos into mp4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
BASE_DIR=/home/andre/ | |
INPUT_DIR=$BASE_DIR/handbrake_input/ | |
OUTPUT_DIR=$BASE_DIR/handbrake_output/ | |
OUTPUT_EXT=mp4 | |
HANDBRAKE=HandBrakeCLI | |
LOG=$BASE_DIR/handbrake_batch.log | |
for INPUT in `ls $INPUT_DIR`; do | |
INPUT_FILE=$(basename $INPUT) | |
OUTPUT_FILE=${INPUT_FILE%.*}.$OUTPUT_EXT | |
if [ -f $OUTPUT_DIR/$OUTPUT_FILE ]; then | |
echo "skipping $INPUT_FILE because $OUTPUT_FILE exists." | |
continue | |
fi | |
echo "processing $INPUT_FILE..." | |
HandBrakeCLI -i $INPUT_DIR/$INPUT_FILE -o $OUTPUT_DIR/$OUTPUT_FILE -O -U \ | |
-e x264 -q 26 -E av_aac -B 192 -6 stereo 2>&1 \ | |
| tee -a $LOG \ | |
| stdbuf -o0 tr "\r" "\n" \ | |
| ( while read line; do echo -en "\033[K\rStatus: $line"; done) | |
STATUS=${PIPESTATUS[0]} | |
echo | |
if [ $STATUS -ne 0 ]; then | |
echo "Aborted! Exiting batch conversion..." | |
exit 1 | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment