#!/bin/bash version=0.72c # Copyleft JOTENAKIS # ce script est sous license GPL # merci à tous les membres de OSA qui m'ont donné un coup de main et en particulier à zeb_ et à philou_a7 ;-) # ----------------------------------------TODO------------------------------------------------------------------------------------------ #-->Version 0.8 : #- mode --purge (pour supprimer tous les encodages du répertoire de travail), #- mode --grave (comment l'intégrer au -- resume ? cas de plusieurs CD ?), #- affiche les durées de traitement à la fin du processus global (rip, audio, video), #- vérifie la place dispo avant de commencer. #- chapitrage, #- internationalisation. #-->Version 0.9 : #- mode --vob pour encoder des fichiers vob cad sans avoir le DVD sous la main, #- support des sous titres (fichiers ifo...), #- mode --multiaudio pour faire des films avec plusieurs langues, #- mode --multigen pour encoder plusieurs génériques (par exemple début et fin). #-->Version 1.0 - pour beaucoup plus tard : #- utilisation sans Xfree, # ----------------------------------------/TODO------------------------------------------------------------------------------------------ # COULEURS COLOROFF="\033[1;0m" # standart color HEADCOLOR="\033[1;32m" # green MAINCOLOR="\033[1;37m" # white SUBCOLOR="\033[1;36m" # blue TABLECOLOR="\033[1;31m" # red INPUTCOLOR="\033[1;35m" # lilac echo -e "${TABLECOLOR}+------------------+" echo -e "|${HEADCOLOR} TUXRIP v${version} ${TABLECOLOR} |" echo -e "${TABLECOLOR}+------------------+" echo -e "$MAINCOLOR" #-------------------------------------------------------------------------------------------------------------------------------------------------------------- function preview () { if [ $choixres -lt 20 ]; then taille1=`ls -l $RACINE/$projet/vob/$projet.vob | awk '{print $5}'` cd $RACINE/$projet/tmp deb=`bc <>>> Voici le format de votre vidéo telle qu'elle sera encodée <<<<" echo mplayer -ao null -vo png -z 0 -sb $deb -frames 5 -vop scale=$scale,crop=$crop $RACINE/$projet/vob/$projet.vob > /dev/null 2>&1 [ -f "$RACINE/$projet/tmp/00000005.png" ] && ( $visu $RACINE/$projet/tmp/00000005.png > /dev/null 2>&1 & ) || ( $visu $RACINE/$projet/tmp/00000001.png > /dev/null 2>&1 & ) fi if [ $choixres -eq 0 ]; then isformat="" while [ "$isformat" = "" ]; do echo -e -n "${SUBCOLOR}-------> Satisfait (o/n) [défaut : n] ? " echo -e -n "${INPUTCOLOR}> " read satisf [ "$satisf" = "N" ] && satisf=n [ "$satisf" = "O" ] && satisf=o if [ "$satisf" = "" ]; then satisf=n echo "Choix par défaut : c'est pas bon..." fi isformat=`echo $satisf | grep "^[oOnN]$"` if [ "$isformat" = "" ]; then echo "Mauvaise réponse (o/n) !!!" fi done fi echo -n -e "${MAINCOLOR}" } #------------------------------------------------------------ début de la fonction finalisation ----------------------------------------------------------- function finalisation () { if [ $etapedeb -le 7 ]; then echo -e "${TABLECOLOR}++++++++MIXAGE A/V+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" echo -e "${MAINCOLOR}" pas=300 decal=$decalinit epsi=0 test="notok" until [ "$test" = "ok" ] do echo -e "${HEADCOLOR}Mixage en cours avec un décalage de "$decal "ms" ogmmerge -q -o $RACINE/$projet/video/${projet}.ogm $RACINE/$projet/video/${projet}sans-son.avi -s $decal $RACINE/$projet/audio/son.ogg echo -e "${MAINCOLOR} >>>> Vérifiez la synchronisation puis quittez en pressant ECHAP <<<<" sleep 1 mplayer -loop 0 -osdlevel 2 -vo $VO -ao $AO $RACINE/$projet/video/${projet}.ogm > /dev/null 2>&1 rep="notok" until [ "$rep" = "ok" ] do echo -e -n "${SUBCOLOR}-------> Son en retard (-), en avance (+), ou synchrone (0) ? " echo -e -n "${INPUTCOLOR}> " read test echo epsiold=$epsi case $test in -) epsi=-1 rep="ok" ;; +) epsi=1 rep="ok" ;; 0) test="ok" rep="ok";; *) echo "Erreur de frappe..." rep="notok" ;; esac done depasse=`bc < $decal" >> $RACINE/$projet/tmp/log fi case $tailleCD in 1300 ) echo -e "${TABLECOLOR}++++++++DECOUPAGE++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" echo -e "${MAINCOLOR}" ogmsplit $RACINE/$projet/video/${projet}.ogm -s 650 mv $RACINE/$projet/video/${projet}-*1.ogm $RACINE/$projet/video/cd1 mv $RACINE/$projet/video/${projet}-*2.ogm $RACINE/$projet/video/cd2;; 1404 ) echo -e "${TABLECOLOR}++++++++DECOUPAGE++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" echo -e "${MAINCOLOR}" ogmsplit $RACINE/$projet/video/${projet}.ogm -s 702 mv $RACINE/$projet/video/${projet}-*1.ogm $RACINE/$projet/video/cd1 mv $RACINE/$projet/video/${projet}-*2.ogm $RACINE/$projet/video/cd2 ;; esac echo -e "${TABLECOLOR}++++++++INFORMATIONS+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" echo -e "${MAINCOLOR}" taillefilm=`bc < /dev/null 2>&1 if [ "$?" = "1" ]; then [ "$sortie" = "notok" ] && echo -e -n "${MAINCOLOR}Le(s) programme(s) -" echo -e -n "${HEADCOLOR} ${i}${MAINCOLOR}" sortie="ok" fi; done if [ "$sortie" = "ok" ]; then echo -e " - est (sont) nécessaire(s) à tuxrip et n'a (ont) pas été trouvé(s) dans ${SUBCOLOR}\"$PATH\"" exit -1 fi #-------------- fin Tests des dépendances ------------------ # Début --- Reprise après extinction if [ -r ~/.tuxripextinction ]; then #on lit les variables nécéssaires dans le log, le txriprc et le tuxripextinction RACINE=`cat ~/.tuxripextinction | awk '{print $1}'` projet=`cat ~/.tuxripextinction | awk '{print $2}'` decalinit=`cat ~/.tuxriprc | grep synchro | awk '{print $4}'` VO=`cat ~/.tuxriprc | grep video | awk '{print $4}'` AO=`cat ~/.tuxriprc | grep "drivers audio" | awk '{print $4}'` tailleCD=`cat $RACINE/$projet/tmp/log | grep bitrate | awk '{print $6}'` echo "-->Le projet $RACINE/$projet s'est terminée précédemment grâce à l'option --extinction." echo "-->Toutes les options de tuxrip sont ignorées." echo "-->On effectue maintenant la dernière étape : mixage et synchronisation A/V." # on finit le projet : affichage,mixage echo echo -e "${HEADCOLOR}Fichier de log vidéo :${MAINCOLOR}" cat $RACINE/$projet/tmp/suivi.log | grep "Pos" cat $RACINE/$projet/tmp/suivi.log | grep "CQ" echo etapedeb=7 finalisation # on efface le fichier d'identité du projet rm -f ~/.tuxripextinction exit fi # Fin --- Reprise après extinction # Flags --------------------- full=-1 resume="" xvid="" grave="" extinction="" lb="" modetest="" testcomp="" while [ $1 ]; do case $1 in --version ) exit 0 ;; --test ) modetest="OK" shift full=$1 isnum=`echo $full | grep "^[1-9][0-9]*$"` if [ "$isnum" = "" ]; then full=1 else shift fi echo "-->Mode test : Seul le chapitre $full sera rippé..." ;; --resume ) resume="OK" echo "-->Mode resume : Un projet existant va être poursuivi..." shift;; --xvid ) xvid="OK" echo "-->Mode xvid : Encodage video en Xvid au lieu de lavc..." shift;; --config ) [ -r ~/.tuxriprc ] && rm -f ~/.tuxriprc touch ~/.tuxriprc echo "-->Mode config : Le fichier de préférence va être généré..." #repertoire de travail exist=notok until [ "$exist" = "OK" ] do echo -n -e "${SUBCOLOR}-------> Répertoire de travail [défaut : /space] ? " echo -n -e "${INPUTCOLOR}> " read RACINE if [ "$RACINE" = "" ] ; then RACINE="/space" echo "Choix par défaut : /space" fi if [ -d "$RACINE" ]; then exist=OK else echo -e "${HEADCOLOR}Ce répertoire n'existe pas..." fi done echo "Rep de travail : " $RACINE >> ~/.tuxriprc #device exist=notok until [ "$exist" = "OK" ] do echo -n -e "${SUBCOLOR}-------> Device du DVD [défaut : /dev/dvd] ? " echo -n -e "${INPUTCOLOR}> " read DEVICE if [ "$DEVICE" = "" ] ; then DEVICE="/dev/dvd" echo "Choix par défaut : /dev/dvd" fi if [ -r "$DEVICE" ]; then exist=OK else echo -e "${HEADCOLOR}Ce device n'existe pas..." fi done echo "device du dvd : " $DEVICE >> ~/.tuxriprc # decalage initial de synchronisation en ms isnum="" while [ "$isnum" = "" ] do echo -n -e "${SUBCOLOR}-------> Décalage initial A/V pour la synchro en ms [défaut : 0] ? " echo -n -e "${INPUTCOLOR}> " read decalinit if [ "$decalinit" = "" ] ; then decalinit=0 echo "Choix par défaut : 0 ms" fi isnum=`echo $decalinit | grep "^[-0-9][0-9]*$"` if [ "$isnum" = "" ] ; then isnum=`echo $decalinit | grep "^[0-9][0-9]*$"` if [ "$isnum" = "" ] ; then echo "Erreur : le décalage doit être un entier..." fi fi done echo "synchro init : " $decalinit >> ~/.tuxriprc # options libavcodec echo -n -e "${SUBCOLOR}-------> Options d'encodage video libavcodec [défaut : vcodec=mpeg4:vqmin=2:vqmax=20:vmax_b_frames=0:vhq:keyint=250:vme=4:v4mv] ? " echo -n -e "${INPUTCOLOR}> " read LAVCOPT if [ "$LAVCOPT" = "" ] ; then LAVCOPT="vcodec=mpeg4:vqmin=2:vqmax=20:vmax_b_frames=0:vhq:keyint=250:vme=4:v4mv" echo "Choix par défaut..." fi echo "options libavcodec : " $LAVCOPT >> ~/.tuxriprc # options xvid echo -n -e "${SUBCOLOR}-------> Options d'encodage video xvid [défaut : 4mv:me_quality=6:min_key_interval=6:max_key_interval=250:keyframe_boost=30] ? " echo -n -e "${INPUTCOLOR}> " read XVIDOPT if [ "$XVIDOPT" = "" ] ; then XVIDOPT="4mv:me_quality=6:min_key_interval=6:max_key_interval=250:keyframe_boost=30" echo "Choix par défaut..." fi echo "options xvid : " $XVIDOPT >> ~/.tuxriprc # normalisation maxi isnum="" while [ "$isnum" = "" ] do echo -n -e "${SUBCOLOR}-------> Gain maximum utilisé pour la normalisation audio [défaut : 3] ? " echo -n -e "${INPUTCOLOR}> " read gainmax if [ "$gainmax" = "" ] ; then gainmax=3 echo "Choix par défaut : 3" fi isnum=`echo $gainmax | grep "^[1-9]$"` if [ "$isnum" = "" ] ; then echo "Erreur : le gain maximum doit être un entier strictement positif..." fi done echo "gain audio max : " $gainmax >> ~/.tuxriprc # drivers video mplayer verif="notok" while [ "$verif" = "notok" ]; do echo -n -e "${SUBCOLOR}-------> Driver video (x11, xv, sdl) [défaut : xv] ? " echo -n -e "${INPUTCOLOR}> " read VO case $VO in x11 | xv | sdl ) verif="OK" ;; "" ) verif="OK" VO="xv" echo "Choix par défaut : xv" ;; * ) echo "Erreur : seuls (x11, xv, sdl) sont dispos" verif="notok" ;; esac done echo "drivers video : " $VO >> ~/.tuxriprc # drivers audio mplayer verif="notok" while [ "$verif" = "notok" ]; do echo -n -e "${SUBCOLOR}-------> Driver audio (oss, alsa9, sdl) [défaut : oss] ? " echo -n -e "${INPUTCOLOR}> " read AO case $AO in oss | alsa9 | sdl ) verif="OK" ;; "" ) verif="OK" AO="oss" echo "Choix par défaut : oss" ;; * ) echo "Erreur : seuls (oss, alsa9, sdl) sont dispos" verif="notok" ;; esac done echo "drivers audio : " $AO >> ~/.tuxriprc # Chaine SCSI du graveur isformat="" while [ "$isformat" = "" ] do echo -n -e "${SUBCOLOR}-------> Chaine SCSI du graveur (à déterminer avec cdrecord --scanbus) [défaut : 0,3,0] ? " echo -n -e "${INPUTCOLOR}> " read graveur if [ "$graveur" = "" ]; then graveur="0,3,0" echo "Choix par défaut : 0,3,0" fi isformat=`echo $graveur | grep "^[0-9],[0-9],[0-9]$"` if [ "$isformat" = "" ] ; then echo "Erreur : saisissez une chaine du type x,y,z ..." fi done echo "graveur : " $graveur >> ~/.tuxriprc # Vitesse de gravure isnum="" while [ "$isnum" = "" ] do echo -n -e "${SUBCOLOR}-------> Vitesse de gravure [défaut : 12] ? " echo -n -e "${INPUTCOLOR}> " read vitesse if [ "$vitesse" = "" ] ; then vitesse=12 echo "Choix par défaut : 12X" fi isnum=`echo $vitesse | grep "^[1-9][0-9]*$"` if [ "$isnum" = "" ] ; then echo "Erreur : la vitesse de gravure doit être un entier strictement positif..." fi done echo "vitesse gravure : " $vitesse >> ~/.tuxriprc # visualisateur d'images test="notok" until [ "$test" = "ok" ] do echo -n -e "${SUBCOLOR}-------> Visualisateur d'images (gqview, eog, kview, imview, display) [défaut : gqview] ? " echo -n -e "${INPUTCOLOR}> " read visu if [ "$visu" = "" ] ; then visu="gqview" echo "Choix par défaut : gqview" fi case $visu in gqview | eog | kview | imview | display ) test="ok" ;; * ) test="notok" esac done echo "visualisateur : " $visu >> ~/.tuxriprc # quantizer min/max des génériques format="" until [ "$format" = "ok" ] do echo -n -e "${SUBCOLOR}-------> Quantization des génériques (min-max) [défaut : 20-20] ? " echo -n -e "${INPUTCOLOR}> " read quantgen if [ "$quantgen" = "" ]; then quantgen="20-20" echo "Choix par défaut : 20-20" fi isformat=`echo $quantgen | grep "^[0-9][0-9]*-[0-9][0-9]*$"` if [ "$isformat" != "" ] ; then min=`echo $quantgen | cut -d- -f 1` max=`echo $quantgen | cut -d- -f 2` if [ $min -le 31 ] ; then if [ $min -ge 2 ] ; then fmin="ok" else echo "Un quantizer est un entier supérieur ou égal à 2 !" format="notok" fi ; else echo "Un quantizer est un entier inférieur ou égal à 31 !" format="notok" fi if [ $max -le 31 ] ; then if [ $max -ge 2 ] ; then fmax="ok" else echo "Un quantizer est un entier supérieur ou égal à 2 !" format="notok" fi ; else echo "Un quantizer est un entier inférieur ou égal à 31 !" format="notok" fi if [ "$fmin" = "ok" ] && [ "$fmax" = "ok" ] ; then if [ $min -le $max ] ; then format="ok" else echo "Attention : quantizer min > quantizer max !!!" format="notok" fi fi else echo "Un quantizer est un entier compris entre 2 et 31, respecter le format min-max !!!" format="notok" fi done echo "quantizer génériques : " $quantgen >> ~/.tuxriprc exit ;; --verif-prefs ) if [ -r ~/.tuxriprc ] ; then echo "-->Mode verif-prefs : les variables du fichier tuxriprc sont affichées..." RACINE=`cat ~/.tuxriprc | grep travail | awk '{print $5}'` DEVICE=`cat ~/.tuxriprc | grep device | awk '{print $5}'` decalinit=`cat ~/.tuxriprc | grep synchro | awk '{print $4}'` LAVCOPT=`cat ~/.tuxriprc | grep libavcodec | awk '{print $4}'` XVIDOPT=`cat ~/.tuxriprc | grep xvid | awk '{print $4}'` gainmax=`cat ~/.tuxriprc | grep gain | awk '{print $5}'` VO=`cat ~/.tuxriprc | grep video | awk '{print $4}'` AO=`cat ~/.tuxriprc | grep "drivers audio" | awk '{print $4}'` graveur=`cat ~/.tuxriprc | grep "graveur" | awk '{print $3}'` vitesse=`cat ~/.tuxriprc | grep "gravure" | awk '{print $4}'` visu=`cat ~/.tuxriprc | grep "visualisateur" | awk '{print $3}'` quantgen=`cat ~/.tuxriprc | grep "quantizer" | awk '{print $4}'` echo echo -e "${HEADCOLOR}Répertoire de travail : ${SUBCOLOR}"$RACINE echo -e "${HEADCOLOR}Device du DVD : ${SUBCOLOR}"$DEVICE echo -e "${HEADCOLOR}Décalage A/V initial : ${SUBCOLOR}"$decalinit"${HEADCOLOR} ms" echo -e "${HEADCOLOR}Options libavcodec : ${SUBCOLOR}"$LAVCOPT echo -e "${HEADCOLOR}Options xvid : ${SUBCOLOR}"$XVIDOPT echo -e "${HEADCOLOR}Gain audio maxi : ${SUBCOLOR}"$gainmax echo -e "${HEADCOLOR}Driver vidéo : ${SUBCOLOR}"$VO echo -e "${HEADCOLOR}Driver audio : ${SUBCOLOR}"$AO echo -e "${HEADCOLOR}Graveur : ${SUBCOLOR}"$graveur echo -e "${HEADCOLOR}Vitesse de gravure : ${SUBCOLOR}"$vitesse"${HEADCOLOR}X" echo -e "${HEADCOLOR}Visualisateur : ${SUBCOLOR}"$visu echo -e "${HEADCOLOR}Quantizer génériques : ${SUBCOLOR}"$quantgen else echo "Fichier de préférences non trouvé : relancer tuxrip en mode --config" fi echo -e "${MAINCOLOR}" exit;; --help ) echo -e "${SUBCOLOR}Mode help : tuxrip peut être lancé avec les options suivantes :${MAINCOLOR}" echo " --config : pour générer le fichier de préférences ~/.tuxriprc." echo " --desentrelace : pour forcer le désentrelacement d'une source PAL entrelacée." echo " --extinction : pour éteindre le PC après l'encodage vidéo." echo " --help : pour afficher ce contenu ;-)." #echo " --purge : pour supprimer tous les projets du repertoire de travail." echo " --resume : pour reprendre un encodage déjà effectué partiellement ou totalement." echo " --test n : pour ne ripper que le 'n ème' chapitre d'un DVD (permet de tester le script rapidement)." echo " --test-comp : pour effectuer un test de compressibilité avant l'encodage (permet d'affiner le choix de la résolution)." echo " --verif-prefs : pour vérifier le contenu du fichier de préférences." echo " --version : pour afficher le numéro de version de tuxrip." echo " --xvid : pour encoder en xvid à la place de libavcodec." shift exit;; --desentrelace ) echo "-->Mode desentrelace : la video sera desentrelacée pendant l'encodage..." lb="OK" shift;; --extinction ) echo "-->Mode extinction : le PC sera éteint après l'encodage video et le mixage A/V sera effectué au prochain démarrage de tuxrip..." extinction="OK" shift;; # --purge ) echo "-->Mode purge : tous les projets contenu dans le répertoire de travail vont être supprimés..." # RACINE=`cat ~/.tuxriprc | grep travail | awk '{print $5}'` # ls -l $RACINE # shift # exit;; --grave ) echo "-->Mode grave : la vidéo sera gravée à la fin du processus d'encodage..." grave="OK" shift;; --test-comp ) echo "-->Mode test-comp : Un préencodage rapide sera effectué afin de tester la compressibilité du film..." testcomp="OK" shift;; * ) echo "Option inconnue : $1, donc ignorée..." shift;; esac done # LECTURE FICHIER DE PREFS------------------------------- if [ -r ~/.tuxriprc ] ; then RACINE=`cat ~/.tuxriprc | grep travail | awk '{print $5}'` DEVICE=`cat ~/.tuxriprc | grep device | awk '{print $5}'` decalinit=`cat ~/.tuxriprc | grep synchro | awk '{print $4}'` LAVCOPT=`cat ~/.tuxriprc | grep libavcodec | awk '{print $4}'` XVIDOPT=`cat ~/.tuxriprc | grep xvid | awk '{print $4}'` gainmax=`cat ~/.tuxriprc | grep gain | awk '{print $5}'` VO=`cat ~/.tuxriprc | grep video | awk '{print $4}'` AO=`cat ~/.tuxriprc | grep "drivers audio" | awk '{print $4}'` graveur=`cat ~/.tuxriprc | grep "graveur" | awk '{print $3}'` vitesse=`cat ~/.tuxriprc | grep "gravure" | awk '{print $4}'` visu=`cat ~/.tuxriprc | grep "visualisateur" | awk '{print $3}'` quantgen=`cat ~/.tuxriprc | grep "quantizer" | awk '{print $4}'` else echo "Fichier de préférences non trouvé : relancer tuxrip en mode --config" exit fi # CREATION DU PROJET------------------------------- verif=n while [ "$verif" = "n" ] do echo -n -e "${SUBCOLOR}-------> Nom du projet [défaut : DVD] ? " echo -n -e "${INPUTCOLOR}> " read projet if [ "$projet" = "" ] ; then projet=DVD echo "Choix par défaut : DVD" fi echo -e "${MAINCOLOR}" if [ -d $RACINE/$projet ] ; then if [ "$resume" = "OK" ]; then onestou=`awk 'END {print NR}' $RACINE/$projet/tmp/log` echo "Etape(s) effectuée(s) :" case $onestou in 1) echo -e "${SUBCOLOR}-->1)scan du DVD" title=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $5}'` angle=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $6}'` index=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $7}'` pisteaudio=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $8}'` aspect=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $9}'` resXdvd=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $10}'` resYdvd=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $11}'` fps=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $12}'` credits=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $13}'` echo -e "${HEADCOLOR}Titre : "$title echo -e "${HEADCOLOR}Angle : "$angle echo -e "${HEADCOLOR}Piste audio : "$index echo -e "${HEADCOLOR}Langue : "$pisteaudio echo -e "${HEADCOLOR}AR : "$aspect echo -e "${HEADCOLOR}ResXdvd : "$resXdvd echo -e "${HEADCOLOR}ResYdvd : "$resYdvd echo -e "${HEADCOLOR}Framerate : "$fps echo -e "${HEADCOLOR}1ere frame du générique : "$credits ;; 2) echo -e "${SUBCOLOR}-->1)scan du DVD" title=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $5}'` angle=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $6}'` index=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $7}'` pisteaudio=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $8}'` aspect=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $9}'` resXdvd=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $10}'` resYdvd=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $11}'` fps=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $12}'` credits=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $13}'` echo -e "${HEADCOLOR}Titre : "$title echo -e "${HEADCOLOR}Angle : "$angle echo -e "${HEADCOLOR}Piste audio : "$index echo -e "${HEADCOLOR}Langue : "$pisteaudio echo -e "${HEADCOLOR}AR : "$aspect echo -e "${HEADCOLOR}ResXdvd : "$resXdvd echo -e "${HEADCOLOR}ResYdvd : "$resYdvd echo -e "${HEADCOLOR}Framerate : "$fps echo -e "${HEADCOLOR}1ere frame du générique : "$credits echo -e "${SUBCOLOR}-->2)rip du DVD" ;; 3) echo -e "${SUBCOLOR}-->1)scan du DVD" title=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $5}'` angle=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $6}'` index=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $7}'` pisteaudio=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $8}'` aspect=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $9}'` resXdvd=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $10}'` resYdvd=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $11}'` fps=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $12}'` credits=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $13}'` echo -e "${HEADCOLOR}Titre : "$title echo -e "${HEADCOLOR}Angle : "$angle echo -e "${HEADCOLOR}Piste audio : "$index echo -e "${HEADCOLOR}Langue : "$pisteaudio echo -e "${HEADCOLOR}AR : "$aspect echo -e "${HEADCOLOR}ResXdvd : "$resXdvd echo -e "${HEADCOLOR}ResYdvd : "$resYdvd echo -e "${HEADCOLOR}Framerate : "$fps echo -e "${HEADCOLOR}1ere frame du générique : "$credits echo -e "${SUBCOLOR}-->2)rip du DVD" echo -e "${SUBCOLOR}-->3)encodage audio" qualite=`cat $RACINE/$projet/tmp/log | grep audio | awk '{print $4}'` echo -e "${HEADCOLOR}Qualité audio : "$qualite ;; 4) echo -e "${SUBCOLOR}-->1)scan du DVD" title=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $5}'` angle=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $6}'` index=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $7}'` pisteaudio=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $8}'` aspect=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $9}'` resXdvd=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $10}'` resYdvd=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $11}'` fps=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $12}'` credits=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $13}'` echo -e "${HEADCOLOR}Titre : "$title echo -e "${HEADCOLOR}Angle : "$angle echo -e "${HEADCOLOR}Piste audio : "$index echo -e "${HEADCOLOR}Langue : "$pisteaudio echo -e "${HEADCOLOR}AR : "$aspect echo -e "${HEADCOLOR}ResXdvd : "$resXdvd echo -e "${HEADCOLOR}ResYdvd : "$resYdvd echo -e "${HEADCOLOR}Framerate : "$fps echo -e "${HEADCOLOR}1ere frame du générique : "$credits echo -e "${SUBCOLOR}-->2)rip du DVD" echo -e "${SUBCOLOR}-->3)encodage audio" qualite=`cat $RACINE/$projet/tmp/log | grep audio | awk '{print $4}'` echo -e "${HEADCOLOR}Qualité audio : "$qualite echo -e "${SUBCOLOR}-->4)cropping auto" crop=`cat $RACINE/$projet/tmp/log | grep cropping | awk '{print $3}'` haut=`cat $RACINE/$projet/tmp/log | grep cropping | awk '{print $4}'` larg=`cat $RACINE/$projet/tmp/log | grep cropping | awk '{print $5}'` echo -e "${HEADCOLOR}Cropping : "$crop ;; 5) echo -e "${SUBCOLOR}-->1)scan du DVD" title=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $5}'` angle=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $6}'` index=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $7}'` pisteaudio=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $8}'` aspect=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $9}'` resXdvd=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $10}'` resYdvd=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $11}'` fps=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $12}'` credits=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $13}'` echo -e "${HEADCOLOR}Titre : "$title echo -e "${HEADCOLOR}Angle : "$angle echo -e "${HEADCOLOR}Piste audio : "$index echo -e "${HEADCOLOR}Langue : "$pisteaudio echo -e "${HEADCOLOR}AR : "$aspect echo -e "${HEADCOLOR}ResXdvd : "$resXdvd echo -e "${HEADCOLOR}ResYdvd : "$resYdvd echo -e "${HEADCOLOR}Framerate : "$fps echo -e "${HEADCOLOR}1ere frame du générique : "$credits echo -e "${SUBCOLOR}-->2)rip du DVD" echo -e "${SUBCOLOR}-->3)encodage audio" qualite=`cat $RACINE/$projet/tmp/log | grep audio | awk '{print $4}'` echo -e "${HEADCOLOR}Qualité audio : "$qualite echo -e "${SUBCOLOR}-->4)cropping auto" crop=`cat $RACINE/$projet/tmp/log | grep cropping | awk '{print $3}'` haut=`cat $RACINE/$projet/tmp/log | grep cropping | awk '{print $4}'` larg=`cat $RACINE/$projet/tmp/log | grep cropping | awk '{print $5}'` echo -e "${HEADCOLOR}Cropping : "$crop echo -e "${SUBCOLOR}-->5)paramètres d'encodage video" tailleCD=`cat $RACINE/$projet/tmp/log | grep bitrate | awk '{print $6}'` bitvideo=`cat $RACINE/$projet/tmp/log | grep bitrate | awk '{print $8}'` scale=`cat $RACINE/$projet/tmp/log | grep bitrate | awk '{print $7}'` echo -e "${HEADCOLOR}Support : "$tailleCD" Mo" echo -e "${HEADCOLOR}Bitrate video : "$bitvideo" kbps" echo -e "${HEADCOLOR}Résolution : "$scale ;; 6) echo -e "${SUBCOLOR}-->1)scan du DVD" title=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $5}'` angle=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $6}'` index=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $7}'` pisteaudio=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $8}'` aspect=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $9}'` resXdvd=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $10}'` resYdvd=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $11}'` fps=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $12}'` credits=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $13}'` echo -e "${HEADCOLOR}Titre : "$title echo -e "${HEADCOLOR}Angle : "$angle echo -e "${HEADCOLOR}Piste audio : "$index echo -e "${HEADCOLOR}Langue : "$pisteaudio echo -e "${HEADCOLOR}AR : "$aspect echo -e "${HEADCOLOR}ResXdvd : "$resXdvd echo -e "${HEADCOLOR}ResYdvd : "$resYdvd echo -e "${HEADCOLOR}Framerate : "$fps echo -e "${HEADCOLOR}1ere frame du générique : "$credits echo -e "${SUBCOLOR}-->2)rip du DVD" echo -e "${SUBCOLOR}-->3)encodage audio" qualite=`cat $RACINE/$projet/tmp/log | grep audio | awk '{print $4}'` echo -e "${HEADCOLOR}Qualité audio : "$qualite echo -e "${SUBCOLOR}-->4)cropping auto" crop=`cat $RACINE/$projet/tmp/log | grep cropping | awk '{print $3}'` haut=`cat $RACINE/$projet/tmp/log | grep cropping | awk '{print $4}'` larg=`cat $RACINE/$projet/tmp/log | grep cropping | awk '{print $5}'` echo -e "${HEADCOLOR}Cropping : "$crop echo -e "${SUBCOLOR}-->5)paramètres d'encodage video" tailleCD=`cat $RACINE/$projet/tmp/log | grep bitrate | awk '{print $6}'` bitvideo=`cat $RACINE/$projet/tmp/log | grep bitrate | awk '{print $8}'` scale=`cat $RACINE/$projet/tmp/log | grep bitrate | awk '{print $7}'` echo -e "${HEADCOLOR}Support : "$tailleCD" Mo" echo -e "${HEADCOLOR}Bitrate video : "$bitvideo" kbps" echo -e "${HEADCOLOR}Résolution : "$scale echo -e "${SUBCOLOR}-->6)encodage video";; 7) echo -e "${SUBCOLOR}-->1)scan du DVD" title=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $5}'` angle=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $6}'` index=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $7}'` pisteaudio=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $8}'` aspect=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $9}'` resXdvd=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $10}'` resYdvd=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $11}'` fps=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $12}'` credits=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $13}'` echo -e "${HEADCOLOR}Titre : "$title echo -e "${HEADCOLOR}Angle : "$angle echo -e "${HEADCOLOR}Piste audio : "$index echo -e "${HEADCOLOR}Langue : "$pisteaudio echo -e "${HEADCOLOR}AR : "$aspect echo -e "${HEADCOLOR}ResXdvd : "$resXdvd echo -e "${HEADCOLOR}ResYdvd : "$resYdvd echo -e "${HEADCOLOR}Framerate : "$fps echo -e "${HEADCOLOR}1ere frame du générique : "$credits echo -e "${SUBCOLOR}-->2)rip du DVD" echo -e "${SUBCOLOR}-->3)encodage audio" qualite=`cat $RACINE/$projet/tmp/log | grep audio | awk '{print $4}'` echo -e "${HEADCOLOR}Qualité audio : "$qualite echo -e "${SUBCOLOR}-->4)cropping auto" crop=`cat $RACINE/$projet/tmp/log | grep cropping | awk '{print $3}'` haut=`cat $RACINE/$projet/tmp/log | grep cropping | awk '{print $4}'` larg=`cat $RACINE/$projet/tmp/log | grep cropping | awk '{print $5}'` echo -e "${HEADCOLOR}Cropping : "$crop echo -e "${SUBCOLOR}-->5)paramètres d'encodage video" tailleCD=`cat $RACINE/$projet/tmp/log | grep bitrate | awk '{print $6}'` bitvideo=`cat $RACINE/$projet/tmp/log | grep bitrate | awk '{print $8}'` scale=`cat $RACINE/$projet/tmp/log | grep bitrate | awk '{print $7}'` echo -e "${HEADCOLOR}Support : "$tailleCD" Mo" echo -e "${HEADCOLOR}Bitrate video : "$bitvideo" kbps" echo -e "${HEADCOLOR}Résolution : "$scale echo -e "${SUBCOLOR}-->6)encodage video" echo -e "${SUBCOLOR}-->7)mixage A/V" decalinit=`cat $RACINE/$projet/tmp/log | grep mixage | awk '{print $4}'` echo -e "${HEADCOLOR}Décalage : "$decalinit "ms" ;; esac verif=o else isformat="" while [ "$isformat" = "" ]; do echo -n -e "${SUBCOLOR}-------> Ce projet existe déjà, on écrase ou pas (o/n) [défaut : n] ? " echo -n -e "${INPUTCOLOR}> " read verif [ "$verif" = "N" ] && verif=n [ "$verif" = "O" ] && verif=o if [ "$verif" = "" ]; then verif=n echo "Choix par défaut : On n'écrase pas..." fi isformat=`echo $verif | grep "^[oOnN]$"` if [ "$isformat" = "" ]; then echo "Mauvaise réponse (o/n) !!!" fi echo -n -e "${MAINCOLOR}" [ "$verif" = "o" ] && rm -rf $RACINE/$projet || echo done fi else if [ "$resume" = "OK" ]; then echo "Mode resume enclenché sur un projet inexistant, impossible de poursuivre..." exit else verif=o fi fi done if [ "$resume" = "OK" ]; then limite=`expr $onestou \+ 1` [ $limite -eq 8 ] && limite=7 etapedeb=10 while [ $etapedeb -gt $limite ] do echo echo -n -e "${SUBCOLOR}-------> On recommence à partir de quelle étape [défaut : $limite] ? " echo -n -e "${INPUTCOLOR}> " read etapedeb if [ "$etapedeb" = "" ] ; then echo "Choix par défaut : On recommence à partir de l'étape $limite..." etapedeb=$limite fi isnum=`echo $etapedeb | grep "^[1-9][0-9]*$"` if [ "$isnum" = "" ] ; then echo "Erreur : le code correspondant à l'étape est un entier compris entre 1 et $limite..." etapedeb=10 else [ $etapedeb -gt $limite ] && echo "Impossible !" fi done case $etapedeb in 1 ) touch $RACINE/$projet/tmp/log.resume ;; 2 ) awk 'NR == 1 , NR == 1 {print $0}' $RACINE/$projet/tmp/log > $RACINE/$projet/tmp/log.resume ;; 3 ) awk 'NR == 1 , NR == 2 {print $0}' $RACINE/$projet/tmp/log > $RACINE/$projet/tmp/log.resume ;; 4 ) awk 'NR == 1 , NR == 3 {print $0}' $RACINE/$projet/tmp/log > $RACINE/$projet/tmp/log.resume ;; 5 ) awk 'NR == 1 , NR == 4 {print $0}' $RACINE/$projet/tmp/log > $RACINE/$projet/tmp/log.resume ;; 6 ) awk 'NR == 1 , NR == 5 {print $0}' $RACINE/$projet/tmp/log > $RACINE/$projet/tmp/log.resume ;; 7 ) awk 'NR == 1 , NR == 6 {print $0}' $RACINE/$projet/tmp/log > $RACINE/$projet/tmp/log.resume ;; esac rm -f $RACINE/$projet/tmp/log mv $RACINE/$projet/tmp/log.resume $RACINE/$projet/tmp/log else etapedeb=0 mkdir $RACINE/$projet mkdir $RACINE/$projet/vob mkdir $RACINE/$projet/audio mkdir $RACINE/$projet/video mkdir $RACINE/$projet/tmp touch $RACINE/$projet/tmp/log fi cd $RACINE/$projet # ANALYSE DU DVD----------------------------------- echo if [ $etapedeb -le 1 ]; then echo -e "${TABLECOLOR}++++++++SCAN DU DVD++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" echo -e "${MAINCOLOR}" dvdok="notok" while [ "$dvdok" = "notok" ]; do tcprobe -i $DEVICE 2>/dev/null > $RACINE/$projet/tmp/infos.dvd.test testdvd=`ls -l $RACINE/$projet/tmp/infos.dvd.test | awk '{print $5}'` if [ $testdvd -eq 0 ]; then echo echo -e "${SUBCOLOR}Insérez le DVD dans $DEVICE et appuyez sur ENTREE${MAINCOLOR}" rm -f $RACINE/$projet/tmp/infos.dvd.test read else dvdok="ok" fi done echo -e "${HEADCOLOR}Le DVD est en cours d'analyse...${MAINCOLOR}" titre=1 tcprobe -i $DEVICE -T $titre > $RACINE/$projet/tmp/infos.dvd.$titre 2>&1 titremax=`cat $RACINE/$projet/tmp/infos.dvd.$titre | grep "DVD title" | awk '{print $4}' | awk -F "/" '{print $2}' | awk -F ":" '{print $1}'` titre=2 while [ $titre -le $titremax ]; do tcprobe -i $DEVICE -T $titre > $RACINE/$projet/tmp/infos.dvd.$titre 2>&1 titre=$(($titre + 1)) done titre=1 timemax=0 titredef=1 while [ $titre -le $titremax ]; do echo -e "${HEADCOLOR}--->Titre $titre${MAINCOLOR}" echo -n -e "${MAINCOLOR}Données :${SUBCOLOR}" ; cat $RACINE/$projet/tmp/infos.dvd.$titre | grep "DVD title" | awk -F ":" '{print $2}' | awk -F ", title" '{print $1}' time=`cat $RACINE/$projet/tmp/infos.dvd.$titre | grep "time" | awk '{print $5}'` H=`echo $time | cut -d: -f 1` M=`echo $time | cut -d: -f 2` S=`echo $time | cut -d: -f 3` timesec=`bc < Quel titre à ripper [défaut : $titredef] ? " echo -n -e "${INPUTCOLOR}> " read title if [ "$title" = "" ]; then echo "Choix par défaut : titre $titredef..." title=$titredef fi isnum=`echo $title | grep "^[1-9][0-9]*$"` if [ "$isnum" != "" ]; then if [ $title -gt $titremax ]; then echo "Attention, il n'y a que $titremax titre(s) disponible(s) !!!" isnum="" fi else echo "Attention, le titre est un entier supérieur ou égal à 1 !!!" fi done echo -n -e "${MAINCOLOR}" mplayer -dvd $title -dvd-device $DEVICE -vo null -ao null -frames 0 -v > $RACINE/$projet/tmp/infos.dvd 2>&1 angle=`cat $RACINE/$projet/tmp/infos.dvd | grep "angles in this DVD title" | awk '{print $3}'` anglemax=$angle if [ $anglemax -gt 1 ]; then isnum="" echo -e "${HEADCOLOR}Il y a ${SUBCOLOR}$anglemax${HEADCOLOR} angles disponibles dans ce titre... " until [ "$isnum" != "" ]; do echo -n -e "${SUBCOLOR}-------> Quel angle à ripper [défaut : 1] ? " echo -n -e "${INPUTCOLOR}> " read angle if [ "$angle" = "" ]; then echo "Choix par défaut : angle 1..." angle=1 fi isnum=`echo $angle | grep "^[1-9][0-9]*$"` if [ "$isnum" != "" ]; then if [ $angle -gt $anglemax ]; then echo "Attention, il n'y a que $anglemax angle(s) disponible(s) !!!" isnum="" fi else echo "Attention, l'angle est un entier supérieur ou égal à 1 !!!" fi done echo -n -e "${MAINCOLOR}" echo else echo "On rippe le seul angle disponible, le "$angle"..." fi echo -e "${HEADCOLOR}" cat $RACINE/$projet/tmp/infos.dvd | grep "audio format" | awk -F "audio stream:" '{print $2}' | awk -F "aid" '{print $1}' audiomax=`cat $RACINE/$projet/tmp/infos.dvd | grep "audio format" | awk -F "audio stream:" '{print $2}' | awk -F "aid" '{print $1}' | tail -n 1 | awk '{print $1}'` if [ $audiomax -gt 0 ]; then isnum="" until [ "$isnum" != "" ]; do echo -n -e "${SUBCOLOR}-------> Quel piste audio à ripper [défaut : 0] ? " echo -n -e "${INPUTCOLOR}> " read index if [ "$index" = "" ]; then echo "Choix par défaut : piste 0..." index=0 fi isnum=`echo $index | grep "^[0-9][0-9]*$"` if [ "$isnum" != "" ]; then if [ $index -gt $audiomax ]; then echo "Attention, cette piste audio n'existe pas !!!" isnum="" fi else echo "Attention, l'index de la piste audio est un entier supérieur ou égal à 0 !!!" fi done echo -n -e "${MAINCOLOR}" else index=$audiomax echo -e "${MAINCOLOR}On rippe la seule piste audio disponible, la "$index"..." fi pisteaudio=`cat $RACINE/$projet/tmp/infos.dvd | grep "audio format" | grep "audio stream: ${index}" | awk -F "language: " '{print $2}' | awk '{print $1}'` if [ "$pisteaudio" = "" ]; then pisteaudio="inconnu" fi aid=`expr $index \+ 128` echo -n -e "${HEADCOLOR}Langue de la piste choisie : "$pisteaudio echo -e "${MAINCOLOR}" aspect=`cat $RACINE/$projet/tmp/infos.dvd | grep "VIDEO" | awk '{print $5}' | awk -F ")" '{print $1}'` resXdvd=`cat $RACINE/$projet/tmp/infos.dvd | grep "VIDEO" | awk '{print $3}' | awk -F "x" '{print $1}'` resYdvd=`cat $RACINE/$projet/tmp/infos.dvd | grep "VIDEO" | awk '{print $3}' | awk -F "x" '{print $2}'` cat $RACINE/$projet/tmp/infos.dvd | grep "VIDEO" | awk '{print $6}' > $RACINE/$projet/tmp/framerate fps=`sed -e "s/,/./" $RACINE/$projet/tmp/framerate` rm -f $RACINE/$projet/tmp/framerate echo echo -e "${MAINCOLOR} >>>> Notez l'instant où commence le générique de fin puis quittez en pressant ECHAP <<<<" echo nbchap=`cat $RACINE/$projet/tmp/infos.dvd | grep "chapters in this DVD title" | awk '{print $3}'` if [ "$modetest" = "OK" ] ; then if [ $full -gt $nbchap ]; then echo "Le chapitre $full (choisi par l'option --test) n'existe pas, on rippe le dernier ($nbchap) à la place..." full=$nbchap chapgen=$(($nbchap - 1)) elif [ $full -eq $nbchap ]; then chapgen=$(($full - 1)) else chapgen=$full fi else [ $nbchap -gt 1 ] && chapgen=$(($nbchap - 1)) || chapgen=$nbchap fi mplayer -loop 0 -osdlevel 2 -dvd $title -aid $aid -dvd-device $DEVICE -chapter $chapgen -vo $VO -ao $AO > /dev/null 2>&1 nogen=`cat $RACINE/$projet/tmp/infos.dvd.$title | grep time | awk '{print $5}' | awk -F "." '{print $1}'` isformat="" until [ "$isformat" != "" ] do echo -n -e "${SUBCOLOR}-------> Début du générique de fin (hh:mm:ss) [défaut : $nogen] ? " echo -n -e "${INPUTCOLOR}> " read generique if [ "$generique" = "" ] ; then echo "Choix par défaut : $nogen, pas d'encodage spécifique du générique..." generique=$nogen fi isformat=`echo $generique | egrep "^0?[0-4]:[0-5]?[0-9]:[0-5]?[0-9]$"` if [ "$isformat" = "" ] ; then echo "Format hh:mm:ss non respecté !" else genH=`echo $generique | cut -d: -f 1` genM=`echo $generique | cut -d: -f 2` genS=`echo $generique | cut -d: -f 3` credits=`bc < $title $angle $index $pisteaudio $aspect $resXdvd $resYdvd $fps $credits" >> $RACINE/$projet/tmp/log fi # Ripping if [ $etapedeb -le 2 ]; then echo -e "${TABLECOLOR}++++++++RIPPING DU DVD+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" echo -e "${MAINCOLOR}" typeaudio=`cat $RACINE/$projet/tmp/infos.dvd | grep "audio format" | grep "audio stream: ${index}" | awk '{print $7}'` case $typeaudio in mpeg1 ) typeaudio="mp3" ;; # lpcm ) typeaudio="raw" ;; * ) typeaudio="ac3" ;; esac dvdok="notok" while [ "$dvdok" = "notok" ]; do tcprobe -i $DEVICE 2>/dev/null > $RACINE/$projet/tmp/infos.dvd.test testdvd=`ls -l $RACINE/$projet/tmp/infos.dvd.test | awk '{print $5}'` if [ $testdvd -eq 0 ]; then echo echo -e "${SUBCOLOR}Insérez le DVD dans $DEVICE et appuyez sur ENTREE${MAINCOLOR}" read else dvdok="ok" fi done if [ "$modetest" = "OK" ]; then echo -e "${HEADCOLOR}Le titre n°${SUBCOLOR}${title}${HEADCOLOR} (chapitre n°${SUBCOLOR}${nbchap}${HEADCOLOR}) est en cours de copie dans ${SUBCOLOR}$RACINE/$projet/vob/$projet.vob${HEADCOLOR}...${MAINCOLOR}" else echo -e "${HEADCOLOR}Le titre n°${SUBCOLOR}${title}${HEADCOLOR} est en cours de copie dans ${SUBCOLOR}$RACINE/$projet/vob/$projet.vob${HEADCOLOR}...${MAINCOLOR}" fi # tccat -t dvd -T $title,$full,$angle -i $DEVICE 2>/dev/null | tee $RACINE/$projet/vob/$projet.vob | tcextract -a $index -x $typeaudio -t vob | tcdecode -x $typeaudio | tcscan -x pcm -b 80 > $RACINE/$projet/tmp/infos.son tccat -t dvd -T $title,$full,$angle -i $DEVICE 2>/dev/null > $RACINE/$projet/vob/$projet.vob tccat -i $RACINE/$projet/vob/$projet.vob | tcextract -a $index -x $typeaudio -t vob | tcdecode -x $typeaudio | tcscan -x pcm -b 80 > $RACINE/$projet/tmp/infos.son echo echo "ripping dvd" >> $RACINE/$projet/tmp/log fi # ENCODAGE AUDIO---------------------------- if [ $etapedeb -le 3 ]; then echo -e "${TABLECOLOR}++++++++ENCODAGE AUDIO+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" echo -e "${MAINCOLOR}" rescale=`cat $RACINE/$projet/tmp/infos.son | grep "volume" | awk -F "=" '{print $3}'` test=`bc < $gainmax EOF ` if [ "$test" = "1" ]; then # plafonne le gain à la valeur maxi lu dans le ficher config pour éviter des saturations (merci à "zeb_") rescale=$gainmax fi echo -e "${HEADCOLOR}" echo "Normalisation : "$rescale isnum="" while [ "$isnum" = "" ] do echo -e "${MAINCOLOR}" echo -n -e "${SUBCOLOR}-------> Qualité d'encodage audio ogg/vorbis [défaut : 1,0] ? " echo -n -e "${INPUTCOLOR}> " read qualite if [ "$qualite" = "" ] ; then qualite=1,0 echo "Choix par défaut : 1,0" fi isnum=`echo $qualite | egrep "^[0-9]+[\.,]?[0-9]*$"` if [ "$isnum" = "" ] ; then echo "Erreur : la qualité doit être un réel positif..." fi done echo -n -e "${MAINCOLOR}" mkfifo $RACINE/$projet/tmp/pcmpipe.raw nice -19 oggenc -r -C2 -R48000 -B16 -q$qualite -o $RACINE/$projet/audio/son.ogg $RACINE/$projet/tmp/pcmpipe.raw & nice -19 transcode -q 0 -i $RACINE/$projet/vob -a $index -g 0x0 -u 50 -s $rescale,1,1,1 --a52_drc_off -x null,vob -y raw -N 0x1 -m $RACINE/$projet/tmp/pcmpipe.raw -o /dev/null 2>/dev/null rm -f $RACINE/$projet/tmp/pcmpipe.raw sleep 2 echo "encodage audio --> $qualite" >> $RACINE/$projet/tmp/log fi # cropping if [ $etapedeb -le 4 ]; then echo -e "${TABLECOLOR}++++++++DETECTION DU CROPPING++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" echo -e "${MAINCOLOR}" cd $RACINE/$projet/tmp taille1=`ls -l $RACINE/$projet/vob/$projet.vob | awk '{print $5}'` deb=`bc < $RACINE/$projet/tmp/infos.crop 2>&1 larg=`cat $RACINE/$projet/tmp/infos.crop | grep "crop area" | tail -n 1 - | awk -F "=" '{print $2}' | awk -F ")" '{print $1}' | awk -F ":" '{print $1}'` haut=`cat $RACINE/$projet/tmp/infos.crop | grep "crop area" | tail -n 1 - | awk -F "=" '{print $2}' | awk -F ")" '{print $1}' | awk -F ":" '{print $2}'` x0=`cat $RACINE/$projet/tmp/infos.crop | grep "crop area" | tail -n 1 - | awk -F "=" '{print $2}' | awk -F ")" '{print $1}' | awk -F ":" '{print $3}'` y0=`cat $RACINE/$projet/tmp/infos.crop | grep "crop area" | tail -n 1 - | awk -F "=" '{print $2}' | awk -F ")" '{print $1}' | awk -F ":" '{print $4}'` crop=`echo ${larg}:${haut}:${x0}:${y0}` top=$y0 bot=`expr $resYdvd \- $haut \- $top` gauche=$x0 droite=`expr $resXdvd \- $larg \- $gauche` echo -e "${HEADCOLOR}" echo -e "Paramètres de crop détectés: " $crop echo -e "Haut : "${top}" pixels" echo -e "Bas : "${bot}" pixels" echo -e "Droite : "${droite}" pixels" echo -e "Gauche : "${gauche}" pixels" echo echo -e "${MAINCOLOR}" echo ">>>> Vérifiez le cropping, à l'aide du rectangle blanc <<<<" echo mplayer -ao null -vo png -z 0 -sb $deb -frames 5 -vop rectangle=$crop $RACINE/$projet/vob/$projet.vob > /dev/null 2>&1 [ -f "$RACINE/$projet/tmp/00000005.png" ] && ( $visu $RACINE/$projet/tmp/00000005.png > /dev/null 2>&1 & ) || ( $visu $RACINE/$projet/tmp/00000001.png > /dev/null 2>&1 & ) isformat="" while [ "$isformat" = "" ] ; do echo -n -e "${SUBCOLOR}-------> C'est bon (o/n) [défaut : n] ? " echo -n -e "${INPUTCOLOR}> " read verif [ "$verif" = "N" ] && verif=n [ "$verif" = "O" ] && verif=o if [ "$verif" = "" ]; then verif=n echo "Choix par défaut : c'est pas bon..." fi isformat=`echo $verif | grep "^[oOnN]$"` if [ "$isformat" = "" ]; then echo "Mauvaise réponse (o/n) !!!" fi done echo -n -e "${MAINCOLOR}" deb=`bc < $crop $haut $larg" >> $RACINE/$projet/tmp/log fi # resolution, bitrate... if [ $etapedeb -le 5 ]; then cd $RACINE/$projet echo -e "${TABLECOLOR}++++++++DETERMINATION DES PARAMETRES D'ENCODAGE VIDEO++++++++++++++++++++++++++++++++++" echo -e "${HEADCOLOR}" ARi=`bc < 1) 1CD 74 min" echo -e "${SUBCOLOR}-------> 2) 1CD 80 min" echo -e "${SUBCOLOR}-------> 3) 2CD 74 min" echo -e "${SUBCOLOR}-------> 4) 2CD 80 min" echo -e "${SUBCOLOR}-------> 5) Autres" echo -n -e "${INPUTCOLOR} Votre Choix [défaut : 2] ? > " read cd if [ "$cd" = "" ]; then cd=2 echo "Choix par défaut : 1CD 80 min" fi isnum=`echo $cd | grep "^[1-5]$"` if [ "$isnum" = "" ]; then echo "Mauvais choix..." fi done autres=notok case $cd in 1) tailleCD=650 ;; 2) tailleCD=702 ;; 3) tailleCD=1300 mkdir $RACINE/$projet/video/cd1 mkdir $RACINE/$projet/video/cd2 ;; 4) tailleCD=1404 mkdir $RACINE/$projet/video/cd1 mkdir $RACINE/$projet/video/cd2 ;; 5) isnum="" while [ "$isnum" = "" ] do echo -n -e "${SUBCOLOR}-------> Taille de votre support en Mo ? " echo -n -e "${INPUTCOLOR}> " autres=ok read tailleCD isnum=`echo $tailleCD | grep "^[1-9][0-9]*$"` if [ "$isnum" = "" ] ; then echo "Erreur : la taille du support doit être un entier positif..." fi done ;; esac echo -n -e "${MAINCOLOR}" #interleave (+ marge) de 1 % tailledispo=`bc < Critère de qualité visé [défaut : 0.22] ? " echo -n -e "${INPUTCOLOR}> " read CQ if [ "$CQ" = "" ] ; then CQ=0.22 echo "Choix par défaut : 0.22" fi isnum0=`echo $CQ | egrep "^[0-9]+\.?[0-9]*$"` if [ "$isnum0" = "" ]; then echo "Attention, le critère de qualité est un réel positif..." fi done echo -n -e "${MAINCOLOR}" ResY=`bc < Quantité de film à pré-encoder en % [défaut : 5] ? " echo -e -n "${INPUTCOLOR}> " read pcfilm if [ "$pcfilm" = "" ]; then pcfilm=5 echo "Choix par défaut : On encode 5%..." fi isnum=`echo $pcfilm | grep "^[1-9][0-9]*$"` if [ "$isnum" = "" ]; then echo "Veuillez saisir un entier entre 1 et 20..." else if [ $pcfilm -gt 20 ]; then echo "Il est inutile et trop long d'encoder plus de 20% du film..." isnum="" fi fi done echo -n -e "${MAINCOLOR}" sec=`bc </dev/null 2>&1 i=$(($i + 1)) done echo echo -e "${HEADCOLOR}Analyse en cours...${MAINCOLOR}" avimerge -i $RACINE/$projet/tmp/cctemp*.avi -o $RACINE/$projet/tmp/ccheck$projet.avi > $RACINE/$projet/tmp/infocc$projet.merge 2>&1 dureecc=`bc < $RACINE/$projet/tmp/infocc$projet echo echo -e "${MAINCOLOR}CQmax=${SUBCOLOR}0$CC${MAINCOLOR}" echo ResX=`bc <> $RACINE/$projet/tmp/res ResX=`bc < $RACINE/$projet/tmp/res.format printf "%1s %5s %1s %10s %1s %10s %1s %2s %1s %3s %1s \n" \| Choix \| Résolution \| Déformation \| CQvisé \| %Comp. \| cat $RACINE/$projet/tmp/res.format echo " 20) Changer la taille du support, recommencer un test." isnum="" while [ "$isnum" = "" ] do if [ "$resdefaut" != "" ]; then echo -n -e "${INPUTCOLOR} Votre Choix [défaut : $resdefaut] ? > " else echo -n -e "${INPUTCOLOR} Votre Choix ? > " fi read choixres if [ "$resdefaut" != "" ]; then if [ "$choixres" = "" ]; then choixres=$resdefaut echo "Choix par défaut : $resdefaut" fi fi isnum=`echo $choixres | grep "^[1-9][0-9]*$"` [ "$isnum" != "" ] && [ $isnum -gt 20 ] && isnum="" if [ "$isnum" = "" ]; then echo "Mauvais choix..." fi done echo -e "${MAINCOLOR}" scale=`cat $RACINE/$projet/tmp/res | grep "^$choixres" | awk '{print $2}'` ResX=`echo $scale | cut -d: -f 1` ResY=`echo $scale | cut -d: -f 2` [ $choixres -eq 20 ] && satisf="n" [ $choixres -lt 20 ] && satisf="o" preview # fin compressibility check fi done echo "taille visée, résolution, bitrate --> $tailleCD $scale $bitvideo" >> $RACINE/$projet/tmp/log fi #encodage video if [ $etapedeb -le 6 ]; then echo echo -e "${TABLECOLOR}++++++++ENCODAGE VIDEO+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" echo -e "${MAINCOLOR}" cd $RACINE/$projet/tmp [ -f "$RACINE/$projet/tmp/lavc_stats.txt" ] && rm -f $RACINE/$projet/tmp/lavc_stats.txt [ -f "$RACINE/$projet/tmp/divx2pass.log" ] && rm -f $RACINE/$projet/tmp/divx2pass.log CIBLE=$RACINE/$projet/video/${projet}sans-son.avi SOURCE=$RACINE/$projet/vob/$projet.vob fin=`bc <&1 | tee $RACINE/$projet/tmp/suivi1.log #2>/dev/null 1>$RACINE/$projet/tmp/suivi1.log # | (sleep 2 ; pid=`ps r | grep mencoder | awk '{print $1}'` ; nice -19 tail -f --pid=$pid -n 1 $RACINE/$projet/tmp/suivi1.log) bitmax=`cat $RACINE/$projet/tmp/suivi1.log | tail -n 1 | awk '{print $3}' | sed -e "s/,/./"` CQmax=`bc <&1 | tee $RACINE/$projet/tmp/suivi2.log #2>/dev/null 1>$RACINE/$projet/tmp/suivi2.log | (sleep 2 ; pid=`ps r | grep mencoder | awk '{print $1}'` ; nice -19 tail -f --pid=$pid -n 1 $RACINE/$projet/tmp/suivi2.log) else if [ "$lb" = "OK" ]; then echo -e "${SUBCOLOR}Première passe : ${MAINCOLOR}" nice -15 mencoder $SOURCE -nosound -o /dev/null -ovc xvid -xvidencopts $XVIDOPT:bitrate=$bitvideo:pass=1 -vop scale=$scale,crop=$crop,pp=lb -sws 2 2>&1 | tee $RACINE/$projet/tmp/suivi1.log #2>/dev/null 1>$RACINE/$projet/tmp/suivi1.log | (sleep 2 ; pid=`ps r | grep mencoder | awk '{print $1}'` ; nice -19 tail -f --pid=$pid -n 1 $RACINE/$projet/tmp/suivi1.log) bitmax=`cat $RACINE/$projet/tmp/suivi1.log | tail -n 1 | awk '{print $3}' | sed -e "s/,/./"` CQmax=`bc <&1 | tee $RACINE/$projet/tmp/suivi2.log #2>/dev/null 1>$RACINE/$projet/tmp/suivi2.log | (sleep 2 ; pid=`ps r | grep mencoder | awk '{print $1}'` ; nice -19 tail -f --pid=$pid -n 1 $RACINE/$projet/tmp/suivi2.log) else echo -e "${SUBCOLOR}Première passe : ${MAINCOLOR}" nice -15 mencoder $SOURCE -nosound -o /dev/null -ovc xvid -xvidencopts $XVIDOPT:bitrate=$bitvideo:pass=1 -vop scale=$scale,crop=$crop -sws 2 2>&1 | tee $RACINE/$projet/tmp/suivi1.log #2>/dev/null 1>$RACINE/$projet/tmp/suivi1.log | (sleep 2 ; pid=`ps r | grep mencoder | awk '{print $1}'` ; nice -19 tail -f --pid=$pid -n 1 $RACINE/$projet/tmp/suivi1.log) bitmax=`cat $RACINE/$projet/tmp/suivi1.log | tail -n 1 | awk '{print $3}' | sed -e "s/,/./"` CQmax=`bc <&1 | tee $RACINE/$projet/tmp/suivi2.log # 2>/dev/null 1>$RACINE/$projet/tmp/suivi2.log | (sleep 2 ; pid=`ps r | grep mencoder | awk '{print $1}'` ; nice -19 tail -f --pid=$pid -n 1 $RACINE/$projet/tmp/suivi2.log) fi fi else if [ "$fps" = "29.97" ]; then echo "DVD NTSC détecté : options '-vop pp=lb' et '-ofps 24' utilisées" echo -e "${SUBCOLOR}Première passe : ${MAINCOLOR}" nice -15 mencoder $SOURCE -nosound -o /dev/null -ovc lavc -lavcopts $LAVCOPT:vrc_override=$credits,$fin,$quantgen:vqscale=2:vpass=1 -vop scale=$scale,crop=$crop,pp=lb -ofps 24 -sws 2 2>&1 | tee $RACINE/$projet/tmp/suivi1.log # 2>/dev/null 1>$RACINE/$projet/tmp/suivi1.log | (sleep 2 ; pid=`ps r | grep mencoder | awk '{print $1}'` ; nice -19 tail -f --pid=$pid -n 1 $RACINE/$projet/tmp/suivi1.log) bitmax=`cat $RACINE/$projet/tmp/suivi1.log | tail -n 1 | awk '{print $3}' | sed -e "s/,/./"` CQmax=`bc <&1 | tee $RACINE/$projet/tmp/suivi2.log # 2>/dev/null 1>$RACINE/$projet/tmp/suivi2.log | (sleep 2 ; pid=`ps r | grep mencoder | awk '{print $1}'` ; nice -19 tail -f --pid=$pid -n 1 $RACINE/$projet/tmp/suivi2.log) else if [ "$lb" = "OK" ]; then echo -e "${SUBCOLOR}Première passe : ${MAINCOLOR}" nice -15 mencoder $SOURCE -nosound -o /dev/null -ovc lavc -lavcopts $LAVCOPT:vrc_override=$credits,$fin,$quantgen:vqscale=2:vpass=1 -vop scale=$scale,crop=$crop,pp=lb -sws 2 2>&1 | tee $RACINE/$projet/tmp/suivi1.log # 2>/dev/null 1>$RACINE/$projet/tmp/suivi1.log | (sleep 2 ; pid=`ps r | grep mencoder | awk '{print $1}'` ; nice -19 tail -f --pid=$pid -n 1 $RACINE/$projet/tmp/suivi1.log) bitmax=`cat $RACINE/$projet/tmp/suivi1.log | tail -n 1 | awk '{print $3}' | sed -e "s/,/./"` CQmax=`bc <&1 | tee $RACINE/$projet/tmp/suivi2.log # 2>/dev/null 1>$RACINE/$projet/tmp/suivi2.log | (sleep 2 ; pid=`ps r | grep mencoder | awk '{print $1}'` ; nice -19 tail -f --pid=$pid -n 1 $RACINE/$projet/tmp/suivi2.log) else echo -e "${SUBCOLOR}Première passe : ${MAINCOLOR}" nice -15 mencoder $SOURCE -nosound -o /dev/null -ovc lavc -lavcopts $LAVCOPT:vrc_override=$credits,$fin,$quantgen:vqscale=2:vpass=1 -vop scale=$scale,crop=$crop -sws 2 2>&1 | tee $RACINE/$projet/tmp/suivi1.log #2>/dev/null 1>$RACINE/$projet/tmp/suivi1.log #| (sleep 2 ; pid=`ps r | grep mencoder | awk '{print $1}'` ; nice -19 tail -f --pid=$pid -n 1 $RACINE/$projet/tmp/suivi1.log) bitmax=`cat $RACINE/$projet/tmp/suivi1.log | tail -n 1 | awk '{print $3}' | sed -e "s/,/./"` CQmax=`bc <&1 | tee $RACINE/$projet/tmp/suivi2.log #2>/dev/null 1>$RACINE/$projet/tmp/suivi2.log | (sleep 2 ; pid=`ps r | grep mencoder | awk '{print $1}'` ; nice -19 tail -f --pid=$pid -n 1 $RACINE/$projet/tmp/suivi2.log) fi fi fi cat $RACINE/$projet/tmp/suivi1.log $RACINE/$projet/tmp/mitemps $RACINE/$projet/tmp/suivi2.log > $RACINE/$projet/tmp/suivi.log rm -f $RACINE/$projet/tmp/suivi1.log $RACINE/$projet/tmp/mitemps $RACINE/$projet/tmp/suivi2.log echo echo "encodage video" >> $RACINE/$projet/tmp/log if [ "$extinction" = "OK" ]; then echo echo "Le PC va s'éteindre dans 10 secondes............." sleep 10 touch ~/.tuxripextinction echo $RACINE $projet >> ~/.tuxripextinction sudo /sbin/shutdown -h now fi fi # mixage A/V finalisation if [ "$grave" = "OK" ]; then echo -e "${TABLECOLOR}++++++++GRAVURE++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" echo -e "${MAINCOLOR}" tailleSECT=`mkisofs -r -J -q -print-size $RACINE/$projet/video/${projet}.ogm` tailleMO=`expr $tailleSECT \* 2048` cd650=333000 cd700=360000 test1=`expr $tailleSECT "<=" $cd650` test2=`expr $tailleSECT "<=" $cd700` if [ "$test1" = "1" ] ; then disk=650 elif [ "$test2" = "1" ] ; then disk=700 else echo "Fichier à graver trop gros..." exit 0 fi echo "Inserez un CD de $disk Mo et appuyez sur une touche pour démarrer la gravure..." read -s -n 1 mkisofs -r -J $RACINE/$projet/video/${projet}.ogm 2>/dev/null | cdrecord -v -dao speed=$vitesse dev=$graveur -tsize=${tailleSECT}s - fi echo -e "${MAINCOLOR}"