I am a newbie with ripping / Hanbrake and now. I have a huge collection of Dvds (more 500) and I want to rip them all.
The goal is this :
- An input string to set if it is a movie or an episode (tv - anime) : OK
- Audio & subtitles : with french / english / japanese (lot of animes) : Only if the choice is episode : OK
- if audio 2.0 only : encode with coreaudio aac 2.0 : OK
- if audio 5.1 is available : encore without mixdown (I want true 5.1) : OK
Last modification :
- Added 2 passes with turbo mode
- Choix of movie or anime (high quality or normal)
- Added check foreign subtitles
Code
Code: Select all
#!/bin/bash
#
# Liste des presets : https://trac.handbrake.fr/wiki/BuiltInPresets
#
type="$1"
dossiersource="$2"
#IFS=$'\n'
config_video_defaut=" -t 1 -e x264 -q 19.25 -B 160,160 -f mp4 -R Auto,Auto -D 0.0,0.0 -m -2 --turbo --subtitle scan,1-9 --subtitle-burn --subtitle-forced scan --native-language fre"
if [ $type == "film" ]; then
config_video_x264=" --detelecine --decomb --loose-anamorphic -x b-adapt=2:rc-lookahead=50"
elif [ $type == "anime" ]; then
config_video_x264=" --strict-anamorphic -x ref=1:weightp=1:subq=2:rc-lookahead=10:trellis=0:8x8dct=0"
fi
#for i in `find $2 -type f -name "*.mkv"`
find $2 -type f -name "*.mkv" | while read fichiers; do
#Nombre de piste audio + type (vérification seulement si 5.1)
tracks=`echo '' | /Applications/HandBrakeCLI -t 0 -i "$fichiers" 2>&1|grep "Audio:"|wc -l`
if [ $tracks -eq "1" ]; then
audio="1"
elif [ $tracks -eq "2" ]; then
audio="1,2"
elif [ $tracks -eq "3" ]; then
audio="1,2,3"
fi
#Si pas de 5.1, converti sinon copie
audio_type=`echo '' | /Applications/HandBrakeCLI -t 0 -i "$fichiers" 2>&1|grep "5.1 ch"|wc -l`
if [ $audio_type -eq "0" ]; then
aencoder="ca_aac"
audio_type_ch=`echo '' | /Applications/HandBrakeCLI -t 0 -i "$fichiers" 2>&1|grep "1.0 ch"|wc -l`
if [ $audio_type_ch -eq "0" ]; then
mixdown="stereo"
else
mixdown="mono"
fi
else
aencoder="copy"
mixdown="auto"
fi
#Lancement de handbrake
echo '' | /Applications/HandBrakeCLI $config_video_defaut $config_video_x264 --audio $audio --aencoder $aencoder --mixdown $mixdown -i "$fichiers" -o "${fichiers%.*}.m4v"
done