j’utilise mencoder en 2 passes avec
-ovc lavc -lavcopts vcodec=mpeg4 avec un bitrate=(HxL)/325 à (HxL)/350 où H et L sont les largeur et hauteur.
Le bitrate video par défaut de mencoder, je crois est de 800. J’utilisais plutôt 900.
Pour le fun, le script fait par moi que j’utilisais quand je n’arrivais pas à avoir crop et aspect correct avec avidemux (qui utilise lavc, xvid et bien d’autres).
##################################################################################################################
#!/bin/bash
#######################################
Nautilus script
Encodage de mpeg en avi
Mplayer, mencoder, transcode, zenity
#######################################
for arg
do
identifie le type video de l’argument
typevid=file -bi "$arg"
Si l’argument est video/mp2p
if [ $typevid = video/mp2p ]; then
identifie les pistes audio
audioinfo()
{
zenity --info --title=“INFO” --text="Identifier ID_AUDIO \n ex: 128"
mplayer -identify -vc null -ac null -frames 0 “$arg” | grep “ID_AUDIO_ID=” | zenity --text-info & atrack=zenity --entry --title="ENTREE" --text="Entrer la piste audio \n ex 128" 2>&1
zenity --info --title=“INFO” --text="Teste la piste audio"
mplayer “$arg” -ss 00:02:00 -aid $atrack
zenity --question --title=“QUESTION” --text="Audio correct ?"
if [ $? = 0 ]; then
Amplification audio
ampli=zenity --entry --title="ENTREE" --text="Entrer le facteur d'AMPLIFICATION \n ex: 5 (0 - 10)" 2>&1
Recherche de l’aspect video
aspect=mplayer -identify -vc null -frames 0 "$arg" | cat | grep ^"ID_VIDEO_ASPECT" | awk '{print}' | cut -d= -f2
zenity --info --title=“INFO” --text=“Recherche du crop \n lire jusqu’à scene claire \n … puis Echap”
Recherche du crop
crop=mplayer "$arg" -vf cropdetect | tail -n 4 | head -n 1 | cat | awk '{print $22}'| cat | cut -d")" -f1 | cut -d= -f2
crop=mplayer "$arg" -ss 00:02:00 -vf cropdetect | tail -n 4 | head -n 1 | cat | cut -d= -f2 | cut -d")" -f1
zenity --info --text="Vérification du crop"
mplayer “$arg” -aid $atrack -ss 00:02:00 -vf crop=$crop
zenity --question --title=“QUESTION” --text="Crop correct ?"
if [ $? = 0 ]; then
vbitrate=zenity --entry --title="ENTREE" --text="Entrer le BITRATE VIDEO \n ex: 900 \n (defaut 800)" 2>&1
Crée un fichier texte des paramètres entrés
echo parametres de transcodage: >> "${arg/%./.txt}"
echo titre = “$arg” >> "${arg/%./.txt}"
echo vbitrate = $vbitrate >> "${arg/%./.txt}"
echo audio = $atrack, ampli = $ampli >> "${arg/%./.txt}"
echo crop = $crop >> "${arg/%./.txt}"
echo autoaspect >> "${arg/%./.txt}"
else zenity --info --title=“INFO” --text=“Crop incorrect \n Recommencer” && exit
fi
else zenity --info --title=“INFO” --text=“Audio incorrect \n Recommencer” && exit
fi
Encodage mencoder lavc 2 passes
}
lavcenc()
{
passe 1
mencoder “$arg” -aid $atrack -oac mp3lame -lameopts vbr=3:vol=$ampli -ovc lavc -lavcopts vcodec=mpeg4:vhq:v4mv:vqmin=2:vpass=1:vbitrate=$vbitrate:autoaspect:turbo -vf crop=$crop -ffourcc DX50 -passlogfile “${arg/%.*/.log}” -o /dev/null | nice zenity --progress --auto-close --pulsate --title=“MENCODER lavc” --text=“Encodage en mpeg4 de: \n … “$arg” … \n Bitrate video = $vbitrate \n Audio = $atrack \n Volume = ampli x $ampli \n Crop = $crop \n Autoaspect \n Qualité VHQ \n PASSE 1 (turbo) … en cours”
passe 2
mencoder “$arg” -aid $atrack -oac mp3lame -lameopts vbr=3:vol=$ampli -ovc lavc -lavcopts vcodec=mpeg4:vhq:v4mv:vqmin=2:vpass=2:vbitrate=$vbitrate:autoaspect -vf crop=$crop -ffourcc DX50 -passlogfile “${arg/%./.log}" -o "${arg/%./.avi}” | nice zenity --progress --auto-close --pulsate --title=“MENCODER lavc” --text=“Encodage en mpeg4 de: \n … “$arg” … \n Bitrate video = $vbitrate \n Audio = $atrack \n Volume = ampli x $ampli \n Crop = $crop \n Autoaspect \n Qualité VHQ \n PASSE 2 … en cours”
}
Encodage mencoder xvid 2 passes
xvidenc()
{
passe 1
mencoder “$arg” -aid $atrack -oac mp3lame -lameopts vbr=3:vol=$ampli -ovc xvid -xvidencopts chroma_opt:vhq=4:bvhq=1:quant_type=mpeg:pass=1:bitrate=$vbitrate:autoaspect:turbo -vf crop=$crop -passlogfile “${arg/%.*/.log}” -o /dev/null | nice zenity --progress --auto-close --pulsate --title=“MENCODER xvid” --text=“Encodage en mpeg4 de: \n … “$arg” … \n Bitrate video = $vbitrate \n Audio = $atrack \n Volume = ampli x $ampli \n Crop = $crop \n Autoaspect \n Qualité VHQ \n PASSE 1 (turbo) … en cours”
passe 2
mencoder “$arg” -aid $atrack -oac mp3lame -lameopts vbr=3:vol=$ampli -ovc xvid -xvidencopts chroma_opt:vhq=4:bvhq=1:quant_type=mpeg:pass=2:bitrate=$vbitrate:autoaspect -vf crop=$crop -passlogfile “${arg/%./.log}" -o "${arg/%./.avi}” | nice zenity --progress --auto-close --pulsate --title=“MENCODER xvid” --text=“Encodage en mpeg4 de: \n … “$arg” … \n Bitrate video = $vbitrate \n Audio = $atrack \n Volume = ampli x $ampli \n Crop = $crop \n Autoaspect \n Qualité VHQ \n PASSE 2 … en cours”
}
Encodage transcode 2 passes scale fixé à 576x328 (préférer dvd::rip qui fait mieux)
transcodeenc()
{
nice transcode -i “$arg” -y xvid4 -Z 576x328,fast -w $vbitrate -V -N 0x55 -b 128 -s 3 -o /dev/null -R 1 | nice zenity --progress --pulsate --auto-close --title=“TRANSCODE” --text=""$arg" \n Vbitrate = $vbitrate \n Resolution = 576x328 \n Passe 1 … en cours"
nice transcode -i “$arg” -y xvid4 -Z 576x328,fast -w $vbitrate -V -N 0x55 -b 128 -s 3 -o “${arg/%.*/.avi}” -R 2 | nice zenity --progress --pulsate --auto-close --title=“TRANSCODE” --text=""$arg" \n Vbitrate = $vbitrate \n Resolution = 576x328 \n Passe 2 … en cours"
rm -f divx4.log
}
Boîte de choix
encode=zenity --title="MPEG to AVI" --text="MPEG to AVI 2 passes (Mencoder/Transcode)" --list --radiolist --height="250" --width="350" --column="Selection" \ --column="Codec"\ --column="Encodage"\ FALSE "lavc" "Encodage mencoder lavc"\ TRUE "xvid" "Encodage mencoder xvid"\ FALSE "transcode" "Encodage transcode xvid"\ | sed 's/ max//g'
if [ “$encode” = “lavc” ]; then
audioinfo && lavcenc && rm -f “${arg/%./.log}" && zenity --info --title=“INFO” --text="Encodage … OK"
elif [ “$encode” = “xvid” ]; then
audioinfo && xvidenc && rm -f "${arg/%./.log}” && zenity --info --title=“INFO” --text="Encodage … OK"
elif [ “$encode” = “transcode” ]; then
zenity --info --title=“INFO” --text="Encodage video et toutes pistes audio"
vbitrate=zenity --entry --title="ENTREE" --text="Entrer le BITRATE VIDEO \n ex: 900 \n (defaut 800)" 2>&1
transcodeenc && zenity --info --title=“INFO” --text="Encodage … OK"
else exit
fi
else zenity --info --title=“INFO” --text=“Argument non video/mp2p \n Encodage annulé” && exit
fi
done
##################################################################################################################