[Bash] Problème avec paramètres dans variables
Salut à tous,
Je suis en train de programmer un script pour encoder des vidéos via Handbrake. J'ai un problème car mon script ne fonctionne pas lorsque j'appelle l'application avec les paramètres en variable.
Exemple : - si je lance l'application avec cette ligne :
Code:
/Applications/HandBrakeCLI $config_video_defaut $config_video_x264 --audio $audio --aencoder $aencoder --mixdown $mixdown -i "$i" -o "${i%.*}.m4v"
alors, les paramètres ne sont pas pris en compte (ou pas tous en tout cas, c'est assez bizarre) - si je fais un echo de la ligne de lancement de l'application et que je la copie / colle dans un shell, l'application de lance correctement (en rajoutant des backslashs pour les -i et -0
J'avoue avoir chercher un moment et ne trouve vraiment pas de pistes... Votre aide est la bienvenue.
Merci d'avance ;-)
Code:
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
|
#!/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 |