-
Notifications
You must be signed in to change notification settings - Fork 0
/
handbrakebatch.sh
72 lines (51 loc) · 1.6 KB
/
handbrakebatch.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#! /bin/bash
# Handbrake Script for Bulk Conversion
# 2021/08/19 Created
# 2021/11/16 Updated
#debug if needed
#set -x
#trap read debug
#Logging
DATE=$(date +"%Y-%m-%d_%H:%M-[%Z]")
exec 3>&1 4>&2
trap 'exec 2>&4 1>&3' 0 1 2 3
exec 1>~/handbrake-${DATE}.log 2>&1
#### Variables Section #####
#### Video Source Directory
source="/home/jeff/rip2/handbrake"
#### Video Output Directory
out="/home/jeff/rip"
#### Temp File Directory
temp="/tmp/videos"
#### Video Codec
video="x265_10bit"
#Video Options: x264 | x264_10bit | nvenc_h264 | x265 | x265_10bit | x265_12bit | nvenc_h265 | mpeg4 | mpeg2 | VP8 | VP9 | theora
#### Audio Codec
#audio="flac16"
#Audio Options: none | av_aac | copy:aac | ac3 | copy:ac3 | eac3 | copy:eac3 | copy:truehd | copy:dts | copy:dtshd | copy:mp2 | mp3 | copy:mp3 | vorbis | flac16 | flac24 | copy:flac | opus | copy
#### Subtitle Settings
sub="--all-subtitles"
#### Start Script ####
####clean up previous list
find $temp -delete
#### Grab all video files and dump names to temp location
ls $source >> $temp
#### Handbrake Batch Conversion
for i in $(cat $temp)
do
if [[ $(mkvinfo ${source}/${i} |grep "Bit depth:" |awk '{print $5}'|head -1) == "24" ]]
then
audio="flac24"
echo "UPDATE: 24 bit audio found"
else
audio="flac16"
echo "UPDATE: 16 bit audio found"
fi
#if [[ $(echo ${i} |grep "chapters") ]]
#then
# chapters=$echo ${i}|cut -d',' -f1}
#fi
echo "UPDATE: Encoding $i"
HandBrakeCLI -i $source/$i -o $out/$i ${chapter} -e $video -q 20 -m --encopts="gpu=1" --all-audio -E $audio $sub && sleep .5
echo "UPDATE: All Work Complete!"
done