#!/bin/bash
version=0.98
# Copyright 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 ;-)
# merci  jj Varv**** pour l'info lisant automatiquement le mon du DVD :)
# merci  Denis M. pour la correction du bug de dtermination des variables aspect,resX...  ;-).
# Corrections de bugs et support de transcode: CREX
transperl="`pwd`/transperl.pl"
dvdsyntaxe="dvd://"
deint="fd"

#dvdsyntaxe="-dvd "


# 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 langue() {
case $1 in
fr )
p1=" >>>> Pour info, voici le format de votre vido telle qu'elle sera encode <<<<"
p2="-------> Satisfait (o/n) [dfaut : n] ? "
p3="O"
p4="o"
p5="Choix par dfaut : c'est pas bon..."
p6="Mauvaise rponse (o/n) !!!"
p7="++++++++MIXAGE A/V++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
p8="Mixage en cours avec un dcalage de "
p9=" >>>> Vrifiez la synchronisation puis quittez en pressant ECHAP <<<<"
p10="-------> Son en retard (-), en avance (+), ou synchrone (0) ? "
p11="Erreur de frappe..."
p12="++++++++DECOUPAGE+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
p13="++++++++INFORMATIONS++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
p14="Taille du film encod : "
p15="Taille vise : "
p16="-->Le projet "
p16bis=" s'est termine prcdemment grce  l'option --extinction."
p17="-->Toutes les autres options de tuxrip sont ignores."
p18="-->On effectue maintenant la dernire tape : mixage et synchronisation A/V."
p19="Fichier de log vido :"
p20="-->Mode test : Seul le chapitre "
p20bis=" sera ripp..."
p21="-->Mode resume : Un projet existant va tre poursuivi..."
p22="-->Mode xvid : Encodage video en Xvid au lieu de lavc..."
p23="-->Mode config : Le fichier de prfrence va tre gnr..."
p24="-------> Rpertoire de travail [dfaut : /space] ? "
p25="Choix par dfaut"
p26="Ce rpertoire n'existe pas ou ne possde pas les bons droits..."
p27="Rep de travail : "
p28="-------> Device du DVD [dfaut : /dev/dvd] ? "
p29="Ce device n'existe pas..."
p30="device du dvd : "
p31="-------> Dcalage initial A/V pour la synchro en ms [dfaut : 0] ? "
p32="Erreur : le dcalage doit tre un entier..."
p33="-------> Options d'encodage video libavcodec [dfaut "
p34="options libavcodec : "
p35="-------> Options d'encodage video xvid [dfaut "
p36="options xvid : "
p37="-------> Gain maximum utilis pour la normalisation audio [dfaut : 3] ? "
p38="Erreur : le gain maximum doit tre un entier strictement positif..."
p39="gain audio max : "
p40="-------> Driver video (x11, xv, sdl) [dfaut : xv] ? "
p41="Erreur : seuls (x11, xv, sdl) sont dispos"
p42="drivers video : "
p43="-------> Driver audio (oss, alsa9, sdl) [dfaut : oss] ? "
p44="Erreur : seuls (oss, alsa9, sdl) sont dispos"
p45="drivers audio : "
p46="-------> Chaine SCSI du graveur ( dterminer avec cdrecord --scanbus) [dfaut : 0,3,0] ? "
p47="Erreur : saisissez une chaine du type x,y,z ..."
p48="graveur : "
p49="-------> Vitesse de gravure [dfaut : 12] ? "
p50="Erreur : la vitesse de gravure doit tre un entier strictement positif..."
p51="vitesse gravure : "
p52="-------> Visualisateur d'images (gqview, eog, kview, imview, display) [dfaut : gqview] ? "
p53="visualisateur : "
p54="-------> Quantization des gnriques (min-max) [dfaut : 20-20] ? "
p55="Un quantizer est un entier suprieur ou gal  2 !"
p56="Un quantizer est un entier infrieur ou gal  31 !"
p57="Attention : quantizer min > quantizer max !!!"
p58="Un quantizer est un entier compris entre 2 et 31, respecter le format min-max !!!"
p59="quantizer gnriques : "
p60="-->Mode verif-prefs : les parametres sont affichs..."
p61="Rpertoire de travail : "
p62="Device du DVD : "
p63="Dcalage A/V initial : "
p64="Options libavcodec : "
p65="Options xvid : "
p66="Gain audio maxi : "
p67="Driver vido : "
p68="Driver audio : "
p69="Graveur : "
p70="Vitesse de gravure : "
p71="Visualisateur : "
p72="Quantizer gnriques : "
p73="Fichier de prfrences non trouv : relancer tuxrip en mode --config"
p74="-->Mode help : tuxrip peut tre lanc avec les options suivantes :"
p75=": pour gnrer le fichier de prfrences ~/.tuxriprc."
p76=": pour forcer le dsentrelacement d'une source PAL entrelace."
p77=": pour teindre le PC aprs l'encodage vido."
p78=": pour afficher ce contenu ;-)."
p79=": pour reprendre un encodage dj effectu partiellement ou totalement."
p80=": pour ne ripper que le 'n me' chapitre d'un DVD (permet de tester le script rapidement)."
p81=": pour effectuer un test de compressibilit avant l'encodage (permet d'affiner le choix de la rsolution)."
p82=": pour vrifier le contenu du fichier de prfrences."
p83=": pour afficher le numro de version de tuxrip."
p84=": pour encoder en xvid  la place de libavcodec."
p84bis=": pour graver la video  la fin du processus global."
p84ter=": pour dfinir le fichier de langue ~/.tuxriplng."
p84quad=": pour simplifier l'affichage de mencoder."
p85="--help"
p86="--config"
p87="--desentrelace"
p88="--extinction"
p89="--resume"
p90="--test"
p91="--test-comp"
p92="--verif-prefs"
p93="--version"
p94="--xvid"
p95="-->Mode desentrelace : la video sera desentrelace pendant l'encodage..."
p96="-->Mode extinction : le PC sera teint aprs l'encodage video et le mixage A/V sera effectu au prochain dmarrage de tuxrip..."
p97="--grave"
p98="-->Mode grave : la vido sera grave  la fin du processus d'encodage..."
p99="-->Mode test-comp : Un prencodage rapide sera effectu afin de tester la compressibilit du film..."
p100="Option inconnue : "
p100bis=", donc ignore..."
p101="Fichier de prfrences non trouv : relancer tuxrip en mode "
p102="Nom du projet [dfaut :"
p103="Choix par dfaut"
p104="Etape(s) effectue(s) :"
p105="scan du DVD"
p106="Titre : "
p107="Angle : "
p108="Piste audio : "
p109="Langue : "
p110="1ere frame du gnrique : "
p111="rip du DVD"
p112="encodage audio"
p113="Qualit audio : "
p114="cropping auto"
p115="paramtres d'encodage video"
p116="Support : "
p117=" Mo"
p118="Bitrate video : "
p119="Rsolution : "
p120="encodage video"
p121="mixage A/V"
p1220="Dcalage : "
p122=" Ce projet existe dj, on crase ou pas (o/n) [dfaut : n] ? "
p123="Choix par dfaut : On n'crase pas..."
p124="Mauvaise rponse (o/n) !!!"
p125="Mode resume enclench sur un projet inexistant, impossible de poursuivre..."
p126=" On recommence  partir de quelle tape [dfaut :"
p127="Choix par dfaut : On recommence  partir de l'tape"
p128="Erreur : le code correspondant  l'tape est un entier compris entre 1 et"
p129="Impossible !"
p130="++++++++SCAN DU DVD+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
p131="Insrez le DVD dans"
p132="et appuyez sur ENTREE"
p133="Le DVD est en cours d'analyse..."
p134="Titre"
p135="Donnes :"
p136="Dure : "
p137="secondes"
p138="Quel titre  ripper [dfaut :"
p139="Choix par dfaut : titre"
p140="Attention, il n'y a que"
p141="titre(s) disponible(s) !!!"
p142="Attention, le titre est un entier suprieur ou gal  1 !!!"
p143="Il y a"
p144=" angles disponibles dans ce titre... "
p145=" Quel angle  ripper [dfaut : 1] ? "
p146="Choix par dfaut : angle 1..."
p147="Attention, il n'y a que"
p148="angle(s) disponible(s) !!!"
p149="Attention, l'angle est un entier suprieur ou gal  1 !!!"
p150="On rippe le seul angle disponible, le"
p151=" Quel piste audio  ripper [dfaut : 0] ? "
p152="Choix par dfaut : piste 0..."
p153="Attention, cette piste audio n'existe pas !!!"
p154="Attention, l'index de la piste audio est un entier suprieur ou gal  0 !!!"
p155="On rippe la seule piste audio disponible, la"
p156="inconnu"
p157="Langue de la piste choisie : "
p158="Notez l'instant o commence le gnrique de fin puis quittez en pressant ECHAP"
p159="Le chapitre"
p160="(choisi par l'option --test) n'existe pas, on rippe le dernier "
p161=" la place..."
p162=" Dbut du gnrique de fin (hh:mm:ss) [dfaut :"
p163="Choix par dfaut : "
p164="pas d'encodage spcifique du gnrique..."
p165="Format hh:mm:ss non respect !"
p166="++++++++RIPPING DU DVD ET NORMALISATION AUDIO+++++++++++++++++++++++++++++++++++"
p167="Le titre n"
p168="chapitre n"
p169="est en cours de copie dans"
p170="++++++++ENCODAGE AUDIO+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
p171="Normalisation : "
p172=" Qualit d'encodage audio ogg/vorbis [dfaut : 1.0] ? "
p173="Choix par dfaut : 1.0"
p174="Erreur : la qualit doit tre un rel positif..."
p175="++++++++DETECTION DU CROPPING+++++++++++++++++++++++++++++++++++++++++++++++++++"
p176="Paramtres de crop dtects: "
p177="Haut   : "
p178="Bas    : "
p179="Droite : "
p180="Gauche : "
p181=" pixels"
p182="Vrifiez le cropping,  l'aide du rectangle blanc"
p183=" C'est bon (o/n) [dfaut : n] ? "
p184="Choix par dfaut : c'est pas bon..."
p185="++++++++DETERMINATION DES PARAMETRES D'ENCODAGE VIDEO+++++++++++++++++++++++++++"
p186="Format"
p187="Ratio dtect "
p188="Dure dtecte "
p189="Autres"
p190=" Votre Choix [dfaut : 2] ? > "
p191="Choix par dfaut : 1CD 80 min"
p192="Mauvais choix..."
p193=" Taille de votre support en Mo ? "
p194="Erreur : la taille du support doit tre un entier positif..."
p195="Taille de la bande son compresse : "
p196="Taille dispo pour la video : "
p197="Bitrate video : "
p198=" Critre de qualit vis [dfaut : 0.22] ? "
p199="Choix par dfaut : 0.22"
p200="Attention, le critre de qualit est un rel positif..."
p201="Rsolution calcule :"
p202="Ratio d'encodage :"
p203="dformation"
p204="Critre de Qualit effectif : "
p205="++++++++TEST DE COMPRESSIBILITE+++++++++++++++++++++++++++++++++++++++++++++++++"
p206=" Quantit de film  pr-encoder en % [dfaut : 5] ? "
p207="Choix par dfaut : On encode 5%..."
p208="Veuillez saisir un entier entre 1 et 20..."
p209="Il est inutile et trop long d'encoder plus de 20% du film..."
p210="Pr-encodage en cours..."
p211="Progression"
p212="Analyse en cours..."
p213="Changer la taille du support, recommencer un test."
p214=" Votre Choix [dfaut :"
p215=" Votre Choix ? > "
p216="Choix par dfaut :"
p217="Mauvais choix..."
p218="++++++++ENCODAGE VIDEO++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
p219="L'encodage video va dmarrer dans 2 secondes, les 2 passes vont s'enchainer automatiquement..."
p220="DVD NTSC dtect : option '-ofps 23.976' utilise"
p221="A l'issue de la premire passe, on a"
p222="Deuxime passe : "
p223="Premire passe : "
p224="Le PC va s'teindre dans 10 secondes............."
p225="++++++++GRAVURE+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
p226="Fichier  graver trop gros..."
p227="Inserez un CD de"
p228="et saisissez le mot de passe root pour dmarrer la gravure..."
p229="Rsolution choisie : "
p230="Gravure"
p231="CQmax"
p232="--lang"
p233="-->Mode langue : Le fichier de langue va tre gnr..."
p234="Quelle langue souhaitez vous utiliser"
p235="Langue non supporte"
p236="ignor"
p237="Fichier de langue : "
p238="--silence"
p239="-->Mode silence : l'affichage de mencoder sera simplifi pour tre plus lisible..."
p240="Encodage audio en cours..."
p241="Vitesse d'encodage audio :"
p242="--presetvideo"
p243="standard"
p244="preset video 'standard' slectionn"
p245="extreme"
p246="preset video 'extreme' slectionn"
p247="preset video inconnu"
p248=",option ignore"
p249="encodage video standard (rapide et de bonne qualit)."
p250="encodage video extreme (qualit optimale mais lent)."
p251="ATTENTION, le mode"
p252="ne fonctionne qu'avec le codec lavc !"
p253="ATTENTION, le FS de votre rpertoire de travail est FAT. Vous devez relancer tuxrip en mode --fat32."
p254="Mo sont disponibles dans"
p255=", pensez  faire de la place..."
p256="Dure d'encodage video"
p257="Dure d'encodage audio"
p258="Dure d'extraction du DVD"
p259="Vitesse d'extraction du DVD"
p260="Vitesse d'encodage audio"
p261="Vitesse d'encodage video"
p262="Dure de mixage A/V"
p263="Vitesse de mixage A/V"
p264="--purge"
p265="Les projets suivants vont tre dtruits dfinitivement :"
p266="Etes-vous certain (o/n) [defaut : n] ? "
p267="OK, on ne supprime rien..."
p268="Aucun projet n'a t dtect dans "
p269=": pour supprimer tous les projets du repertoire de travail."
p270="--clone"
p271="-->Mode clone : Le DVD va tre copi intgralement dans votre rpertoire de travail"
p272="-------> Point de montage du DVD [dfaut : /mnt/cdrom] ? "
p273="Attention ce point de montage n'est pas list dans /etc/fstab, veuillez choisir le bon..."
p274="Attention, vous semblez ne pas avoir les droits ncessaires au montage du lecteur de DVD (man fstab) !"
p275="Point de montage du DVD : "
p276="Le montage du DVD a chou, vrifiez les droits (man mount, man fstab)."
p277="Le programme vobcopy n'est pas prsent dans votre PATH."
p278="Un backup complet de votre DVD est en cours..."
p279="Nom du projet de clone [dfaut :"
p280="On ne touche pas  cette sauvegarde..."
p281=": pour faire une sauvegarde complte de votre DVD dans votre rpertoire de travail."
p282="Programme(s) manquant(s) : "
p283="--source"
p284="-->Mode source : L'encodage va tre ralis  partir d'une copie d'un DVD ralise grce  l'option --clone."
p285="Aucune sauvegarde de DVD n'a t dtect dans votre rpertoire de travail "
p286="Aucune, je veux sortir..."
p287="Sources disponibles : "
p288="-------> Votre choix [dfaut :"
p289="cdrecord et mkisofs ne sont pas prsents dans votre PATH, mode --grave impossible."
p290="OK on arrte."
p291="Veuillez saisir un entier."
p292="Veuillez saisir un entier compris entre 1 et "
p293=": pour choisir comme source, un rpertoire o t pralablement copi un dvd (avec l'option"
p294=" Ce projet de clone existe dj, on crase ou pas (o/n) [dfaut : n] ? "
p295="On continue (o/n) [dfaut : n] ? "
p296="Options d'encodage : "
p297="--multiaudio"
p298="-->Mode multiaudio : Tuxrip va encoder et mixer plusieurs pistes audio..."
p299="Combien de pistes audio souhaitez-vous encoder [dfaut : 2] ? "
p300="Choix par dfaut : on encode 2 bandes-son..."
p301="Attention, il n'y a que "
p302=" bandes sonores disponibles..."
p303="Veuillez saisir un entier strictement positif."
p304="Veuillez choisir au moins 2 bandes-son..."
p305=" Piste audio n"
p306="  ripper ? "
p307="Ce projet a t cre en mode multiaudio, souhaitez-vous continuer en mode multiaudio (o/n) [dfaut : o] ? "
p308="On continue en multiaudio..."
p309="Quelle piste audio conserve-t-on ?"
p310="Piste audio inexistante !"
p311="Ce projet a t cre SANS le mode multiaudio, il est donc impossible de poursuivre..."
p312="--split"
p313="-->Mode split : tuxrip va dcouper les vob en fichiers de 1 Go..."
p314="Le programme split est manquant, impossible de poursuivre..."
p315=": pour forcer le dcoupage des vob en fichiers de 1 Go."
p316="Pour le moment, il est impossible de faire un test de compressibilit sur une partition fat32 ou en mode --split"
p317="Relancer tuxrip sans l'option "
p318="Ce projet a t cre en mode --split (ou sur une partition fat32), on le poursuit donc dans ce mode..."
p319="--incolore"
p320="-->Mode incolore : Tuxrip ne va utiliser aucune couleur distinctive pour son interface..."
p321=": tuxrip ne va utiliser aucune couleur distinctive pour son interface..."
p322=": pour raliser des encodages avec plusieurs bandes-sons."
p323="--sous-titres"
p324="-->Mode sous-titres : Tuxrip va ripper les sous-titres de votre choix..."
p325=" Combien de sous-titres souhaitez-vous extraire [dfaut : 1] ? "
p326="Choix par dfaut : on extrait 1 sous-titre..."
p327=" sous-titres disponibles..."
p328=" sous-titre n"
p329="Attention, ce sous-titre n'existe pas !!!"
p330="Attention, l'index du sous-titre est un entier suprieur ou gal  0 !!!"
p331="Ce DVD n'a pas de sous-titres..."
p332="Langue du sous-titre choisi : "
p333="Extraction des sous-titres en cours..."
p334="Un fichier de sous-titres existe dj"
p335="on crase ou pas (o/n) [dfaut : n] ? "
p336="++++++++SOUS-TITRES+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
p337="Choix par dfaut : on conserve ces sous-titres..."
p338="Taille des sous-titres : "
p339="Souhaitez-vous compresser les sous-titres (o/n) [dfaut : n] ? "
p340="Choix par dfaut : on ne compresse pas les sous-titres..."
p341="Dure d'extraction des sous-titres"
p342="Vitesse d'extraction des sous-titres"
p343="OK, on conserve ces sous-titres..."
p344="Ce projet a t cre en mode --sous-titres."
p345="Souhaitez-vous ractiver le mode sous-titres pour finir (o/n) [dfaut : o] ? "
p346="Les sous-titres seront pris en compte dans la suite..."
p347="Les sous-titres seront ignors dans la suite."
p348="-------> Seuil pour la dtection des bandes noires [dfaut : 24] ? "
p349="Attention, le seuil est un entier compris entre 0 et 255"
p350="Attention, le seuil est un nombre entier !"
p351="Seuil des bandes noires (cropping) : "
p352=": pour extraire des sous-titres."
p353="Mplayer n'a pas t compil avec le support du driver"
p354=", veuillez en choisir un autre."
p355="<Pressez ENTREE pour commencer la vrification de synchronisation>"
p356="-------> Container Audio/Video utilis (ogm/matroska) [dfaut : matroska] ? "
p357="Attention, seuls ogm et matroska sont disponibles..."
p358="Container : "
p359="--list-preset"
p360="Voici les diffrents presets accessibles via l'option --preset-video :"
p361=": pour afficher les options des diffrents presets video disponibles."
p362="-------> Mthode de resize (fast bilinear, bilinear, bicubic, lanczos) [dfaut : bicubic] ?  : "
p363="Resize : "
p364="--xvidtrans"
p365="-->Mode xvidtrans : La video sera code avec transcode au lieu de mencoder et les paramtres avancs Xvid seront rgls avec xvid4conf..."
p366="Appuyez sur ENTREE pour lancer xvid4conf..."
p367="xvid4conf non dtect, tlcharger le ici http://zebra.fh-weingarten.de/~transcode/xvid4conf/ "
p368=": pour encoder avec transcode en Xvid avec toutes les options disponibles grce  xvid4conf."
p369="Mplayer a dtect un ratio de "
p370="tandis que transcode a dtect "
p371="Quel est le vritable ratio de ce DVD [dfaut : 2 ] ? "
p372="Mauvaise rponse (1/2) !" 
p373="On continue avec du"
p374="Vous pouvez maintenant retirer le DVD du lecteur..."
p375="--debug"
p376="-->Mode debug : tous les messages des diffrentes commandes seront affichs..."
p377=": pour deboguer en affichant tous les messages des diffrentes commandes."
p378="transperl.pl n'a pas t trouv dans `pwd`." ;;

en )
p1=" >>>> This is the format of the video when it will be encoded <<<<"
p2="-------> Satisfied (y/n) [default : n] ? "
p3="Y"
p4="y"
p5="Default choice : not good..."
p6="Bad answer (y/n) !!!"
p7="++++++++A/V MULTIPLEXING++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
p8="Mixing A/V with a synch correction of "
p9=" >>>> Check audio sync then quit by pressing ESCAPE <<<<"
p10="-------> Sound late (-), ahead (+), or synchronous (0) ? "
p11="Key error..."
p12="++++++++SPLITTING+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
p13="++++++++INFORMATION++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
p14="Size of the encoded movie : "
p15="Target size : "
p16="-->The project : "
p16bis=" has been previously terminated with the --shutdown option."
p17="-->All tuxrip options are void."
p18="-->We now perform the last step : mixing and A/V synchronisation."
p19="Video log file :"
p20="-->Test mode : Only the chapter "
p20bis=" will be ripped..."
p21="-->Resume mode : An existing project is resumed..."
p22="-->Xvid mode : Video encoding with xvid instead of lavc..."
p23="-->Config mode : The preference file will be generated..."
p24="-------> Working directory [default : /space] ? "
p25="Default choice"
p26="That directory does not exist..."
p27="Working dir : "
p28="-------> DVD device [default : /dev/dvd] ? "
p29="That device does not exist..."
p30="dvd device : "
p31="-------> Initial A/V synch shift in ms [default : 0] ? "
p32="Error : the synch shift has to be an integer..."
p33="-------> libavcodec options [default "
p34="libavcodec options : "
p35="-------> xvid options [default "
p36="video options : "
p37="-------> Maximum gain for audio normalisation [default : 3] ? "
p38="Error : the maximum gain has to be an integer strictly higher than zero..."
p39="max audio gain : "
p40="-------> Video driver (x11, xv, sdl) [default : xv] ? "
p41="Error : only (x11, xv, sdl) are available"
p42="video driver : "
p43="-------> Audio driver (oss, alsa9, sdl) [default : oss] ? "
p44="Error : only (oss, alsa9, sdl) are available"
p45="audio driver : "
p46="-------> Position of the CD writer in the SCSI bus (use cdrecord --scanbus) [default : 0,3,0] ? "
p47="Error : enter a value like x,y,z ..."
p48="CD writer : "
p49="-------> Writing speed [default : 12] ? "
p50="Error : the writing speed has to be an integer strictly higher than zero..."
p51="writing speed : "
p52="-------> Image visualizer (gqview, eog, kview, imview, display) [default : gqview] ? "
p53="visualizer : "
p54="-------> Credits quantizers values (min-max) [default : 20-20] ? "
p55="A quantizer is an integer higher or equal to 2 !"
p56="A quantizer is an integer lower or equal to 31 !"
p57="Careful : quantizer min > quantizer max !!!"
p58="A quantizer is an integer comprised between 2 and 31, respect the format min-max !!!"
p59="credits quantizers : "
p60="-->Check-prefs mode : settings are displayed..."
p61="Working directory : "
p62="DVD device : "
p63="Initial A/V synch shift : "
p64="libavcodec options : "
p65="xvid options : "
p66="Maxi audio gain : "
p67="Video driver : "
p68="Audio driver : "
p69="CD-writer : "
p70="Writing speed : "
p71="Visualizer : "
p72="Credits quantizers : "
p73="Preferences file not found : run tuxrip in --config mode"
p74="Help mode : tuxrip can be run with these options :"
p75=": generates the preferences file ~/.tuxriprc."
p76=": force the deinterlacing for an interlaced PAL source."
p77=": shutdowns the PC after finishing the video encoding."
p78=": displays that help ;-)."
p79=": resumes encoding at any step completely or partially completed."
p80=": only rips the chapter #n (allows quick testing)."
p81=": performs a compressibility check before encoding (allows better resolution choice)."
p82=": displays the preferences."
p83=": displays the version number of tuxrip."
p84=": uses xvid instead of libavcodec for video encoding."
p84bis=": burns the video on CD after encoding."
p84ter=": generates the language file ~/.tuxriplng."
p84quad=": simplifies the display of mencoder."
p85="--help"
p86="--config"
p87="--deinterlace"
p88="--shutdown"
p89="--resume"
p90="--test"
p91="--comp-check"
p92="--verif-prefs"
p93="--version"
p94="--xvid"
p95="-->Deinterlace mode : video will be deinterlaced when encoded..."
p96="-->Shutdown mode : the PC will be shutdown after video encoding, the A/V mixing will be done when tuxrip will be relaunched..."
p97="--burn"
p98="-->Burn mode : the video will be written on CD after encoding..."
p99="-->Comp-check : A quick preencoding will be done to check the compressibilty of the movie..."
p100="Unknown option : "
p100bis=", will be ignored..."
p101="Preferences file not found : launch tuxrip "
p102="Name of the project [default :"
p103="Default choice"
p104="Step(s) already done :"
p105="DVD scanning"
p106="Title : "
p107="Angle : "
p108="Audio stream : "
p109="Language : "
p110="1st frame of the credits : "
p111="DVD ripping"
p112="audio encoding"
p113="Audio quality : "
p114="auto cropping"
p115="video encoding parameters"
p116="Media size : "
p117=" MB"
p118="Video bitrate : "
p119="Resolution : "
p120="video encoding"
p121="A/V mixing"
p1220="Sync shift : "
p122=" This project already exists, overwrite (y/n) [default : n] ? "
p123="Default choice : we do not overwrite..."
p124="Bad answer (y/n) !!!"
p125="Inexisting project, resuming is impossible, cancel..."
p126=" Resuming from which step [default :"
p127="Default choice : Resuming from step"
p128="Error : step number should be an integer comprised between 1 and"
p129="Impossible !"
p130="++++++++DVD SCANNING+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
p131="Insert a DVD in"
p132="and press ENTER"
p133="DVD is being analysed..."
p134="Title"
p135="Data :"
p136="Duration : "
p137="seconds"
p138="Which title to rip [default :"
p139="Default choice : title"
p140="Attention, there are only"
p141="title(s) available !!!"
p142="Attention, the title is an integer superior or equal to 1 !!!"
p143="There are"
p144=" angles available in that title... "
p145=" Which angle to rip [default : 1] ? "
p146="Default choice : angle 1..."
p147="Attention, there are only"
p148="angle(s) available !!!"
p149="Attention, the angle is an integer superior or equal to 1 !!!"
p150="The only available angle will be ripped, number"
p151=" Which audio stream to rip [default : 0] ? "
p152="Default choice : stream number 0..."
p153="Attention, that audio stream does not exist !!!"
p154="Attention, the audio stream index is an integer superior or equal to 0 !!!"
p155="The only audio stream will be ripped, number"
p156="unknown"
p157="Language of the selected audio stream : "
p158="Note the beginning of the ending credits and quit by pressing ESC"
p159="The chapter"
p160="(selected with --test option) does not exist, the last one will be ripped"
p161="instead..."
p162=" Beginning of the ending credits (hh:mm:ss) [default :"
p163="Default choice : "
p164="no particular encoding of credits..."
p165="Format hh:mm:ss is not respected !"
p166="++++++++DVD RIPPING AND AUDIO NORMALISATION++++++++++++++++++++++++++++++++++++++++++++"
p167="Title number "
p168="chapter number"
p169="is being copied in"
p170="++++++++AUDIO ENCODING+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
p171="Normalisation : "
p172=" Audio quality of encoding in ogg/vorbis format [default : 1.0] ? "
p173="Default choice : 1.0"
p174="Error : the quality has to be a positive real number..."
p175="++++++++DETECTION CROPPING+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
p176="Detected cropping parameters : "
p177="Top    : "
p178="Bottom : "
p179="Right  : "
p180="Left   : "
p181=" pixels"
p182="Check cropping is correctly displayed with the white rectangle"
p183=" Correct (y/n) [default : n] ? "
p184="Default choice : not correct..."
p185="++++++++VIDEO ENCODING PARAMETERS++++++++++++++++++++++++++++++++++++++++++++++++++++++"
p186="Format"
p187="Detected ratio "
p188="Detected duration "
p189="Other choices"
p190=" Your Choice [default : 2] ? > "
p191="Default choice : 1CD 80 min"
p192="Incorrect choice..."
p193=" Media size in MB ? "
p194="Error : media size should be a positive integer value..."
p195="Size of the compressed audio stream : "
p196="Available size for video : "
p197="Video bitrate : "
p198=" Targeted Quality Factor [default : 0.22] ? "
p199="Default choice : 0.22"
p200="Attention, the quality factor should be a positive real value..."
p201="Calculated resolution :"
p202="Encoding ratio :"
p203="deformation"
p204="Effective Quality Factor : "
p205="++++++++COMPRESSIBILITY CHECK++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
p206=" Amount of movie to pre-encode in % [default : 5] ? "
p207="Default choice : 5% will be encoded..."
p208="Please enter an integer comprised between 1 and 20..."
p209="It is not necessary and too long to encode more than 20% of the movie..."
p210="Pre-encoding in progress..."
p211="Progress"
p212="Analyse in progress..."
p213="Change media size or perform the test again."
p214=" Your choice [default :"
p215=" Your Choice ? > "
p216="Default choice :"
p217="Bad choice..."
p218="++++++++VIDEO ENCODING+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
p219="The video encoding will start in 2 seconds, the 2 passes will be performed automatically..."
p220="Detected NTSC format : using option '-ofps 23.976'"
p221="After first pass, we have"
p222="Second pass : "
p223="First pass : "
p224="The PC is going to shutdown in 10 seconds............."
p225="++++++++CD WRITING++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
p226="The file to write is too big..."
p227="Insert a"
p228="CD and enter the root password to start burning..."
p229="Your choice : "
p230="CD burning"
p231="QFmax"
p232="--lang"
p233="-->Language mode : The language file will be generated..."
p234="Which language do you want to use"
p235="Non supported language"
p236="ignored"
p237="Language file : "
p238="--silence"
p239="-->Silence mode : for more readibility, the display output of mencoder is simplified..."
p240="Audio encoding in progress..."
p241="Audio encoding speed :"
p242="--presetvideo"
p243="standard"
p244="preset video 'standard' selected"
p245="extreme"
p246="preset video 'extreme' selected"
p247="unknown preset video"
p248=", ignored option"
p249="standard video encoding (fast and good quality)."
p250="extreme video encoding (optimal quality but slow)."
p251="PLEASE NOTE, the"
p252="mode works only with the lavc codec !"
p253="PLEASE NOTE, the FS of your working directory is FAT. You need to change it to be able to handle files bigger than 2Go !!!"
p254="Mo are available in"
p255=", you need to free some space..."
p256="Video encoding duration"
p257="Audio encoding duration"
p258="DVD ripping duration"
p259="DVD ripping speed"
p260="Audio encoding speed"
p261="Video encoding speed"
p262="A/V mixing duration"
p263="A/V mixing speed"
p264="--purge"
p265="These projects will be definitely deleted :"
p266="Are you sure (y/n) [default : n] ? "
p267="OK, nothing is deleted..."
p268="No project has been found in "
p269=": to delete all projects in the working directory."
p270="--clone"
p271="-->Clone mode : The DVD will be entirely extracted in your working directory."
p272="-------> Mount point of the DVD drive [default : /mnt/cdrom] ? "
p273="This mount point is not present in /etc/fstab, please choose a correct one..."
p274="Please note : you do not seem to have the necessary rights to mount the DVD drive (man fstab) !"
p275="Mount point of the DVD : "
p276="The DVD could not be mounted, please check your permissions (man mount, man fstab)."
p277="The vobcopy program is not present in your PATH."
p278="An entire backup of your DVD is in progress..."
p279=" Name of the clone project [default : "
p280="This backup is not modified..."
p281=": makes a backup of the whole DVD in your working directory."
p282="Missing program(s) : "
p283="--source"
p284="-->Source mode : The encoding will be done from a DVD backup made with the --clone option."
p285="No DVD backup has been found in your working directory "
p286="None, I want to get out..."
p287="Available sources : "
p288="-------> Your choice [default :"
p289="cdrecord and mkisofs are not present in your PATH, cannot use the --burn mode."
p290="OK we stop."
p291="Please enter an integer."
p292="Please enter an integer from 1 to "
p293=": to choose as a source a directory where a DVD has been copied (with the option"
p294=" This cloning project already exists, overwrite (y/n) [default : n] ? "
p295="Shall we continue (y/n) [default : n] ? "
p296="Encoding options : "
p297="--multiaudio"
p298="-->Multiaudio mode : Tuxrip will encode and mix several audio tracks..."
p299="How many audio tracks do you want to encode [default : 2] ? "
p300="Default choice : 2 audio tracks will be encoded..."
p301="Please note, there are only "
p302=" available soundtracks..."
p303="Please enter an strictly positive integer number."
p304="Please choose at least 2 audio tracks..."
p305=" Audio track nb"
p306=" to rip ? "
p307="This project was created with the multiaudio mode, do you want to continue in multiaudio mode (y/n) [dfaut : y] ? "
p308="We continue with multiaudio..."
p309="Which audio track do we keep ?"
p310="Non-existent audio track !"
p311="This project was created WITHOUT the multiaudio mode, it is not possible to continue..."
p312="--split"
p313="--> Split mode : tuxrip will split vob files into 1 GB files..."
p314="The split program is missing, impossible to continue..."
p315=": to force the vob files to be split into 1 GB files."
p316="It is not possible to make a compressibility check on a fat32 partition or using the --split mode"
p317="Run tuxrip again without the option "
p318="This project was created with the --split mode (or on a fat32 partition), thus we continue using that mode..."
p319="--no-colors"
p320="--> No-colors mode : tuxrip will not use any colors (for the user interface)..."
p321=": tuxrip will not use any colors (for the user interface)."
p322=": in order to encode and mix several audio tracks."
p323="--subtitles"
p324="-->Subtitles mode : Tuxrip will extract selected subtitles..."
p325=" How many subtitles do you want to extract [default : 1] ? "
p326="Default choice : one subtitle will be extracted..."
p327=" available subtitles..."
p328=" subtitle number"
p329="Attention, this subtitle does not exist !!!"
p330="Attention, a subtitle index number should be an integer superior or equal to 0 !!!"
p331="This DVD title has no subtitle..."
p332="Language of the selected subtitle : "
p333="Subtitles are currently extracted..."
p334="A subtitle file already exists"
p335="overwrite (y/n) [default : n] ? "
p336="++++++++SUBTITLES++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
p337="Default choice : we keep these subtitles..."
p338="Subtitles size : "
p339="Do you want to compress the subtitles (y/n) [default : n] ? "
p340="Default choice : subtitles will not be compressed..."
p341="Subtitles extraction duration"
p342="Subtitles extraction speed"
p343="OK, we keep these subtitles..."
p344="This project has been created using the subtitles mode."
p345="Do you want to resume the subtitles mode to finish up (y/n) [default : y] ? "
p346="Subtitles will be used..."
p347="Subtitles will be ignored."
p348="-------> Black bars detection threshold [default : 24] ? "
p349="Attention, the threshold value must be an integer comprised between 0 and 255"
p350="Attention, the threshold value is an integer !"
p351="Black bars threshold (cropping) : "
p352=": to extract subtitles."
p353="Mplayer was not compiled with the support of this driver"
p354=", please choose another one."
p355="<Press ENTER to start synchronisation check>"
p356="-------> Audio/Video container to use (ogm/matroska) [default : matroska] ? "
p357="Attention, only ogm and matroska are available..."
p358="Container : "
p359="--list-preset"
p360="Here are the available presets using the --preset-video option :"
p361=": to display the various presets available."
p362="-------> Rescale algorithm (fast bilinear, bilinear, bicubic, lanczos) [default : bicubic] ?  : "
p363="Rescale : "
p364="--xvidtrans"
p365="-->Xvidtrans mode : Video will be coded with transcode instead of mencoder with Xvid settings tweaked with xvid4conf..."
p366="Press ENTER to launch xvid4conf"
p367="xvid4conf not detected, download it here http://zebra.fh-weingarten.de/~transcode/xvid4conf/ "
p368=": in order to use transcode/Xvid with xvid4conf."
p369="Mplayer detected aspect ratio : "
p370="whereas transcode : "
p371="Which one is the true aspect ratio [default : 2 ] ? "
p372="Bad answer (1/2) !" 
p373="Let's go with "
p374="You can now eject the DVD from ${DEVICE}..."
p375="--debug"
p376="-->Debug mode : all output messages of commands will be displayed..."
p377=": in order to debug, displaying all output messages."
p378="transperl.pl was not found in `pwd`.";;

sp)
p1=" >>>> Este sera el formato de video con el cual sera comprimido <<<<"
p2="-------> Estas de acuerdo (s/n) [defecto : n] ? "
p3="S"
p4="s"
p5="Opcion por defecto: no es buena..."
p6="Respuesta invalida (s/n) !!!"
p7="++++++++A/V MULTIPLEXANDO+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
p8="Mezclando A/V con correccion de sincronia de "
p9=" >>>> Chequea la sincronia del audio, despues sal pulsando ESCAPE <<<<"
p10="-------> Retardo sonido (-), ahead (+), o sincronia (0) ? "
p11="Error de tecla..."
p12="++++++++PARTIENDO++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
p13="++++++++INFORMACION+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
p14="Tamao de la pelicula codificada : "
p15="Tamao destino : "
p16="-->El proyecto: "
p16bis=" ha sido finalizado previamente con la opcion --shutdown."
p17="-->Todas la opciones de tuxrip son vacias."
p18="-->Vamos a hacer el ultimo paso: mezclar y sincronia A/V."
p19="Fichero log de Video :"
p20="-->Modo Test: Solo el capitulo "
p20bis=" sera ripeado..."
p21="-->Modo Resume : Un proyecto existente sera continuado..."
p22="-->Modo Xvid : Codificacion de Video con xvid en vez de lavc..."
p23="-->Modo Configuracion : Se creara un fichero de preferencia..."
p24="-------> Directorio de trabajo [default : /space] ? "
p25="Opcion por Defecto"
p26="Ese directorio no existe..."
p27="Directorio de trabajo : "
p28="-------> Dispositivo DVD [default : /dev/dvd] ? "
p29="Ese dispostivo no existe..."
p30="dispositivo dvd : "
p31="-------> Sincronia inicial  A/V en [default : 0] ? "
p32="Error : la sincronia tiene de tener un integer..."
p33="-------> opciones libavcodec  [default "
p34="opciones libavcodec : "
p35="-------> opciones xvid [default "
p36="opciones video : "
p37="-------> Aumento del volumen del audio [default : 3] ? "
p38="Error : EL aumento de volumen tiene de tener un integer estrictamente superior a cero..."
p39="aumento de volumen : "
p40="-------> Controlador de Video (x11, xv, sdl) [default : xv] ? "
p41="Error : solo (x11, xv, sdl) es disponible"
p42="controlador de video : "
p43="-------> Controlador de Audio  (oss, alsa9, sdl) [default : oss] ? "
p44="Error : solo (oss, alsa9, sdl) es disponible"
p45="controlador audio : "
p46="-------> Position de la grabadora de CD en el bus SCSI  (usa cdrecord --scanbus) [default : 0,3,0] ? "
p47="Error : aade un valor como x,y,z ..."
p48="Grabadora writer : "
p49="-------> Velocidad de grabacion [default : 12] ? "
p50="Error : la velocida de grabacion tiene de tener un valor estrictamente superior a zero..."
p51="velocidad de escritura : "
p52="-------> Visualizador de imagen (gqview, eog, kview, imview, display) [default : gqview] ? "
p53="visualizador : "
p54="-------> Valores de los quantizers de los creditos (min-max) [default : 20-20] ? "
p55="Un quantizer es un integer alto o igual a 2 !"
p56="Un quantizer es un integer bajo o igual a 31 !"
p57="Cuidado : quantizer min > quantizer max !!!"
p58="Un quantizer es un integer entre 2 y 31, respeta el formato min-max !!!"
p59="credits quantizers : "
p60="-->Modo Check-prefs : valores seran enseados..."
p61="Directorio de trabajo : "
p62="Dispositivo DVD : "
p63="Initial A/V synch shift : "
p64="opciones libavcodec : "
p65="opciones xvid : "
p66="Aumento maximo de audio : "
p67="Controlador de Video : "
p68="Controlador de Audio : "
p69="Grabadora de CD : "
p70="Velocidad de escritura : "
p71="Visualizador : "
p72="Quantizers credits : "
p73="Fichero de preferencias no encontrado : ejecuta tuxrip en modo --config "
p74="Modo ayuda : tuxrip puede arrancar con estas opciones :"
p75=": genera el fichero de preferencias ~/.tuxriprc."
p76=": fuerza el desentrelazado para una fuente entrelazada PAL."
p77=": apaga el PC despues de codificar."
p78=": Te ensea esta ayuda ;-)."
p79=": resume la codificacion a cualquier paso completa o parcialmente completa."
p80=": solo ripea el capitulo #n (te da un testeo rapido)."
p81=": hace un chequeo de compresibilidad antes de codificar (da mejor resolucion)."
p82=": ves las preferencias."
p83=": ves el numero de la version de tuxrip."
p84=": usea xvid en vez de libavcodec para codificacion del video."
p84bis=": graba el video despues de la codificacion."
p84ter=": genera el fichero de idioma ~/.tuxriplng."
p84quad=": simplifica la pantalla de mencoder."
p85="--help"
p86="--config"
p87="--deinterlace"
p88="--shutdown"
p89="--resume"
p90="--test"
p91="--comp-check"
p92="--verif-prefs"
p93="--version"
p94="--xvid"
p95="-->Modo Desentrelazado : video sera desentrelazado mientras codifica..."
p96="-->Modo apagado : el PC sera apagado despues de la codificacion del video, la mezcla de A/V estara completa cuando tuxrip sea ejecutado otra vez..."
p97="--burn"
p98="-->Modo de grabacion: el video sera grabado una vez acabada la codificacion..."
p99="-->Comp-check : Una precodificacion rapida para chequear la compresibilidad de la pelicula..."
p100="Opcion desconocida : "
p100bis=", sera ignorado..."
p101="Fichero de Preferencias no encontrado : ejecuta tuxrip "
p102="Nombre del proyecto [default :"
p103="Opcion defecto"
p104="Paso(s) ya estan :"
p105="Escaneando DVD"
p106="Titulo : "
p107="Angulo : "
p108="Pista Audio : "
p109="Idioma : "
p110="1er fotograma de los creditos : "
p111="Ripeando DVD"
p112="codificacion audio"
p113="Calidad Audio  : "
p114="auto cropping"
p115="parametros codificacion video "
p116="Tamao final : "
p117=" MB"
p118="Bitrate : "
p119="Resolucion : "
p120="codificacion video"
p121="A/V mixing"
p1220="Sync shift : "
p122=" Este proyecto ya existe, sobreescribir? (s/n) [defecto : n] ? "
p123="Opcion defecto : we do not overwrite..."
p124="Mala respuesta (s/n) !!!"
p125="Proyecto inexistente, resumir es imposible, cancelar..."
p126=" Que paso quieres resumir [default :"
p127="Opcion defecto : Resumiendo del paso "
p128="Error : numero de paso tiene de ser entre 1 y"
p129="Imposible !"
p130="++++++++ESCANEO DE DVD+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
p131="Inserta un DVD en"
p132="y pulsa ENTER"
p133="DVD esta siendo analizado..."
p134="Titulo"
p135="Data :"
p136="Duracion : "
p137="segundos"
p138="Que titulo a ripear [default :"
p139="Opcion por defecto : title"
p140="Atencion, aqui hay solo"
p141="Titulo(s) disponible(s) !!!"
p142="Atencion, el titulo tiene de tener un integer superior o igual a 1 !!!"
p143="Aqui hay"
p144=" angulos disponibles en que titulo... "
p145=" Que angulos quieres ripear [default : 1] ? "
p146="Opcion por defecto : angulo 1..."
p147="Atencion, aqwui hay solamente"
p148="angulo(s) disponible(s) !!!"
p149="Atencion, el angulo es integer superior o igual a 1 !!!"
p150="El unico angulo disponible sera ripeado, numero"
p151=" Que pista de audio quiers ripear [default : 0] ? "
p152="Opcion por defecto : pista numero 0..."
p153="Atencion, esa pista de audio no existe !!!"
p154="Atencion, el indice de la pista de audio es an integer superior o igual a 0 !!!"
p155="La unica pista de audio sera extraida, numero"
p156="desconocido"
p157="Idioma de la pista de audio seleccionada : "
p158="Nota el comienzo y el final de los creditos y sal pulsando ESC"
p159="El capitulo"
p160="(seleccionado con la opcion --test ) no existe, el ultimo sera ripeado"
p161="en cambio.."
p162=" Comienzo del final de los creditos (hh:mm:ss) [default :"
p163="Opcion por defecto : "
p164="no codificacion particular de los creditos..."
p165="Formato hh:mm:ss no es respeteado !"
p166="++++++++RIPEANDO DVD & NORMALIZACION DE AUDIO++++++++++++++++++++++++++++++++++++++++++++"
p167="Numero de titulo "
p168="numero capitulo"
p169="es copiado en"
p170="++++++++CODIFICACION DE AUDIO+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
p171="Normalizacion : "
p172=" Calidad de la codificacion del en formato ogg/vorbis format [default : 1.0] ? "
p173="Opcion por defecto : 1.0"
p174="Error : la calidad tiene de ser un numero real positivo..."
p175="++++++++DETECTANDO CROPPING+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
p176="Detectado parametros de croppings : "
p177="Tapa   : "
p178="Final  : "
p179="Derecha : "
p180="Izquierda: "
p181=" pixeles"
p182="Chequea si el cropping esta corectamente visualizado con el rectangulo"
p183=" Correcto (s/n) [defecto : n] ? "
p184="opcion defecto : no correcta..."
p185="++++++++PARAMETROS DE CODIFICACION DE VIDEO++++++++++++++++++++++++++++++++++++++++++++++++++++++"
p186="Formato"
p187="Ratio detecta"
p188="Duracion detectada"
p189="Otras opciones"
p190=" Tu opcion [defectot : 2] ? > "
p191="Opcion defecto : 1CD 80 min"
p192="Opcion incorrecta..."
p193=" Tamao en MB ? "
p194="Error : tamao del medio tiene de ser un valor intenger positivo..."
p195="Tamao de la pista de audio comprimida : "
p196="Tamao disponible para el video : "
p197="Video bitrate : "
p198=" Factor de calidad [default : 0.22] ? "
p199="opcion defecto : 0.22"
p200="Atencion, la calidad del factor tiene de ser un valor real..."
p201="Resolucion calculada :"
p202="Ratio codificacion :"
p203="deformacion"
p204="Factor de Calidad efectivo : "
p205="++++++++CHEQUEO DE COMPRESIBILIDAD++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
p206=" Que % quieres pre-codificar % [defecto : 5] ? "
p207="opcion defecto : 5% sera codificado..."
p208="Por favor introduce un integer entre 1 y 20..."
p209="No es necesario y demasiado largo codificar mas del 20%..."
p210="Pre-codificado en progreso..."
p211="Progreso"
p212="Analisis en progreso..."
p213="Cambia tamao del medio o mejora el test otra vez."
p214=" Tu seleccion [defecto :"
p215=" Tu seleccion ? > "
p216="Seleccion defecto :"
p217="Mala opcion..."
p218="++++++++CODIFICACION DE VIDEO+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
p219="La codificacion de video comenzara en 2 segundoss, los dos pasos seran creados automaticamente..."
p220="Detectado formato NTSC : usando opcion '-ofps 23.976'"
p221="Despues del 1er paso tenemos"
p222="Segundo paso : "
p223="Primer paso : "
p224="El Pc se apagara en 10 segundos............."
p225="++++++++GRABACION DE CD++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
p226="El fichero a escribir es demasiado grande..."
p227="Inserta un"
p228="CD e introduce el password de root para comenzar a grabar..."
p229="Tu seleccion : "
p230="Grabacion CD"
p231="QFmax"
p232="--lang"
p233="-->Modo idioma : El fichero de idioma sera creado..."
p234="Que idioma quieres usar"
p235="idioma no soportado"
p236="ignorado"
p237="Fichero idioma : "
p238="--silence"
p239="-->Modo silencio : para mejor lectura, la salida de esta simplificada..."
p240="Codificacion de Audio en progreso..."
p241="Velocidad codificacion de audio:"
p242="--presetvideo"
p243="estandar"
p244="preset video 'standard' seleccionado"
p245="extremo"
p246="preset video 'extreme' seleccionado"
p247="preset de video desconocido"
p248=", opcion ignorada"
p249="codificacion video standard video (rapido y buena calidad)."
p250="codificacion de video extrema (calidad optima pero lento)."
p251="POR FAVOR APUNTA, el"
p252="modo solo funciona con el codec lavc !"
p253="POR FAVOR APUNTA, el FS de tu directorio de trabajo es FAT. Necesitas cambiarlo para manejar fichero mas grandes de 2Go !!!"
p254="Mo esta disponible en"
p255=", necesitas algo de espacio en el disco duro..."
p256="Duracion de la codificacion de video"
p257="Duracion de la codificacion del Audio"
p258="Duracion del ripeo del DVD"
p259="Duracion de la velocidad ripeando DVD"
p260="Velocidad codificacion Audio"
p261="Velocidad codificacion Video"
p262="Duracion A/V mixing"
p263="Velocidad mezclando A/V"
p264="--purge"
p265="Estos proyectos seran borrados definitivamente:"
p266="Estas seguro (s/n) [default : n] ? "
p267="OK, nno se borro nada..."
p268="No se encontro proyectos "
p269=": a borrar todos los proyectos en el directorio de trabajo."
p270="--clone"
p271="-->Modo Clon: EL DVD sera entraido enteramente en tu directorio de trabajo."
p272="-------> Punto de montaje de la unidad de DVD [defecto : /mnt/cdrom] ? "
p273="Este punto de montaje no esta presente en /etc/fstab, escoje uno correcto..."
p274="Apunta : parace que no tienes los permisos necesarios para montar el DVD (man fstab) !"
p275="Punto de montjae del DVD : "
p276="El DVD no se puede montar, chequea tus permiso (man mount, man fstab)."
p277="El programa vobcopy no esta presente en tu PATH."
p278="Backup entero del DVD en proceso..."
p279=" Nombre del proyecto del clon [defecto : "
p280="Este no esta modificado..."
p281=": Hace un backup entero en el directorio ."
p282="Faltan programas(s) : "
p283="--source"
p284="-->Modo fuente : La codificacion sera creada de un DVD backup con la opcion --clone."
p285="No se encontro DVD backup en directorio de trabajo "
p286="Nada, saldr..."
p287="Fuentes disponibles : "
p288="-------> Tu opcion [default :"
p289="cdrecord y mkisofs no estan presentes en tu PATH, no se puede usar la opcion --burn."
p290="OK pararemos."
p291="Por favor inserta un integer."
p292="Por favor inserta un integer de 1 a "
p293=": a escojer directorio fuente donde se halla copiado el DVD (con la opcion"
p294=" Este proyecto de clonancion ya existe, sobreescribir (s/n) [defecto : n] ? "
p295="Continuamos (s/n) [defecto : n] ? "
p296="Opciones de codificacion : "
p297="--multiaudio"
p298="-->Modo Multiaudio  : Tuxrip codificara y mezclara varias pistas de audio..."
p299="Cuantas pista de audio quieres codificar [defecto : 2] ? "
p300="Opcion defecto : 2 pistas de audio seran codificadas..."
p301="Por favor anota, solo hay  "
p302=" pistas disponibles..."
p303="Por favos introduce un numero estrictamente positivo integer."
p304="Escoge como minimo 2 pistas de audio..."
p305=" Pista de audio Audio nb"
p306=" a ripear? "
p307="Este proyecto fue creado con el modo multiaudio, quieres continuar en modo multiaudio (s/n) [defecto : s] ? "
p308="Continuaremos en modo multiaudio..."
p309="Que pista de audio te quieres quedar?"
p310="Pisa de audio no existente!"
p311="Este proyecto fue creado SIN modo multiaudio, no es posible continuar..."
p312="--split"
p313="--> Modo partir : tuxrip partira los ficheros VOb en ficheros del tamao de 1 Giga..."
p314="El programa de particion no esta, imposible continuar..."
p315=": a forzar los ficheros vob para partirlos en tamao de 1 giga."
p316="No es posible hacer un chequeo de compresibilidad en particiones FAT32 o usando la opcion --split "
p317="Ejecuta tuxrip otra vez sin la opcion "
p318="Este proyecto fue creado con la opcion --split (o en una particion fat32), continuaremos usando ese modo..."
p319="--no-colors"
p320="--> Modo sin-colores : tuxrip no usara nigun color (para el interfaz del usuario)..."
p321=": tuxrip no usara nigun color (para el interfaz del usuario)..."
p322=": en orden para codificar y mezclar diferentes pistas de audio."
p323="--subtitulos"
p324="-->Modo Subtitulos : Tuxrip extraera los subtitulos seleccionados..."
p325=" Cuantos subtitulos quiers extraer? [defecto : 1] ? "
p326="Opcion por defecto : un subtitulo ser extraido..."
p327=" subtitulos disponibles..."
p328=" numero subtitulos"
p329="Atencion, este subtitulo no existe !!!"
p330="Atencion, numero de indice del subtitulo tiene de ser integer superior o igual a 0 !!!"
p331="Este DVD  no tiene subtitulos..."
p332="Idioma del subtitulo seleccionado : "
p333="Subtitulos extraidos actualmente..."
p334="El fichero de subtitulo ya existe"
p335="sobreescribir (s/n) [defecto : n] ? "
p336="++++++++SUBTITULOS++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
p337="Opcion por defecto: guardaremos estos subtitulos..."
p338="Tamao subtitulos : "
p339="Quieres comprimir los subtitulos?(s/n) [defecto : n] ? "
p340="Opcion defecto: subtitulos no sern comprimidos..."
p341="Duracion de la extraccion de subtitulos"
p342="Velocidad de la extracion de los subtitulos"
p343="OK, guardaremos estos subtitulos..."
p344="Este proyecto ha sido creado usando el modo ?subtitulos."
p345="Quieres continuar el modo subtitutlos para finalizar la tarea (s/n) [defecto : s] ? "
p346="Subtitulos que seran usados..."
p347="Subtitulos que seran ignorados."
p348="-------> Black bars detection threshold [default : 24] ? "
p349="Attention, the threshold value must be an integer comprised between 0 and 255"
p350="Attention, the threshold value is an integer !"
p351="Black bars threshold (cropping) : "
p352=": to extract subtitles."
p353="Mplayer was not compiled with the support of this driver"
p354=", please choose another one."
p355="<Press ENTER to start synchronisation check>"
p356="-------> Audio/Video container to use (ogm/matroska) [default : matroska] ? "
p357="Attention, only ogm and matroska are available..."
p358="Container : "
p359="--list-preset"
p360="Here are the available presets using the --preset-video option :"
p361=": to display the various presets available."
p362="-------> Rescale algorithm (fast bilinear, bilinear, bicubic, lanczos) [default : bicubic] ?  : "
p363="Rescale : "
p364="--xvidtrans"
p365="-->Xvidtrans mode : Video will be coded with transcode instead of mencoder with Xvid settings tweaked with xvid4conf..."
p366="Press ENTER to launch xvid4conf"
p367="xvid4conf not detected, download it here http://zebra.fh-weingarten.de/~transcode/xvid4conf/ "
p368=": in order to use transcode/Xvid with xvid4conf."
p369="Mplayer detected aspect ratio : "
p370="whereas transcode : "
p371="Which one is the true aspect ratio [default : 2 ] ? "
p372="Bad answer (1/2) !" 
p373="Let's go with "
p374="You can now eject the DVD from ${DEVICE}..."
p375="--debug"
p376="-->Debug mode : all output messages of commands will be displayed..."
p377=": in order to debug, displaying all output messages."
p378="transperl.pl was not found in `pwd`.";;

esac
}

#--------------------------------------------------------------LOCALISATION-----------------------------------------------------------------------

if [ -f ~/.tuxriplng ]; then
   lng=`cat ~/.tuxriplng`
   case $lng in
      "en") rep="ok" ;;
      "fr") rep="ok" ;;
      "sp") rep="ok" ;;
       *) echo "Language not supported"
           rm -f ~/.tuxriplng
           exit  ;;
   esac
   deflng="ok"
else
   rep="notok"
   while [ "$rep" = "notok" ]; do
      echo "Language file not detected, which language do you want to use (en/fr/sp) ?"
      read lng
      case $lng in
         "en") rep="ok" ;;
         "fr") rep="ok" ;;
         "sp") rep="ok" ;;
         *) echo "Language not supported" ;;
      esac
   done
   touch ~/.tuxriplng
   echo $lng > ~/.tuxriplng
   deflng="notok"
fi

langue $lng

#--------------------------------------------------------------------------------------------------------------------------------------------------------------
function preview () {
         if [ $choixres -lt 16 ]; then
            if [ "$fat32" = "OK" ];then
               taille1=`ls -l $RACINE/$projet/vob/${projet}-1.vob | awk '{print $5}'`
            else
               taille1=`ls -l $RACINE/$projet/vob/$projet.vob | awk '{print $5}'`
            fi
            cd $RACINE/$projet/tmp
            deb=`bc <<EOF
                    scale=0
                    $taille1 * 0.90 / 1
EOF`
            echo
            echo $p1
            [ -f "$RACINE/$projet/tmp/00000001.png" ] && rm -f $RACINE/$projet/tmp/00000001.png
            [ -f "$RACINE/$projet/tmp/00000002.png" ] && rm -f $RACINE/$projet/tmp/00000002.png
            [ -f "$RACINE/$projet/tmp/00000003.png" ] && rm -f $RACINE/$projet/tmp/00000003.png
            [ -f "$RACINE/$projet/tmp/00000004.png" ] && rm -f $RACINE/$projet/tmp/00000004.png
            [ -f "$RACINE/$projet/tmp/00000005.png" ] && rm -f $RACINE/$projet/tmp/00000005.png
            if [ "$fat32" = "OK" ];then
                if [ "$debug" = "OK" ]; then    
                   mplayer -ao null -vo png -z 0 -sb $deb -frames 5 -vf crop=$crop,scale=$scale $RACINE/$projet/vob/${projet}-1.vob
                else
                   mplayer -ao null -vo png -z 0 -sb $deb -frames 5 -vf crop=$crop,scale=$scale $RACINE/$projet/vob/${projet}-1.vob  > /dev/null 2>&1
                fi   
            else
                if [ "$debug" = "OK" ]; then
                   mplayer -ao null -vo png -z 0 -sb $deb -frames 5 -vf crop=$crop,scale=$scale $RACINE/$projet/vob/$projet.vob
                else
                   mplayer -ao null -vo png -z 0 -sb $deb -frames 5 -vf crop=$crop,scale=$scale $RACINE/$projet/vob/$projet.vob  > /dev/null 2>&1
                fi
            fi
            if [ -f "$RACINE/$projet/tmp/00000005.png" ]; then
               mv -f $RACINE/$projet/tmp/00000005.png $RACINE/$projet/tmp/preview.png
               rm -f $RACINE/$projet/tmp/000*.png
               if [ "$debug" = "OK" ]; then
                  $visu $RACINE/$projet/tmp/preview.png &
               else
                  $visu $RACINE/$projet/tmp/preview.png > /dev/null 2>&1 & 
               fi
            elif [ -f "$RACINE/$projet/tmp/00000004.png" ]; then
               mv -f $RACINE/$projet/tmp/00000004.png $RACINE/$projet/tmp/preview.png
               rm -f $RACINE/$projet/tmp/000*.png
               if [ "$debug" = "OK" ]; then
                  $visu $RACINE/$projet/tmp/preview.png &
               else
                  $visu $RACINE/$projet/tmp/preview.png > /dev/null 2>&1 &
               fi
            elif [ -f "$RACINE/$projet/tmp/00000003.png" ]; then
               mv -f $RACINE/$projet/tmp/00000003.png $RACINE/$projet/tmp/preview.png
               rm -f $RACINE/$projet/tmp/000*.png
               if [ "$debug" = "OK" ]; then
                  $visu $RACINE/$projet/tmp/preview.png &
               else
                  $visu $RACINE/$projet/tmp/preview.png > /dev/null 2>&1 &
               fi
            elif [ -f "$RACINE/$projet/tmp/00000002.png" ]; then
               mv -f $RACINE/$projet/tmp/00000002.png $RACINE/$projet/tmp/preview.png
               rm -f $RACINE/$projet/tmp/000*.png
               if [ "$debug" = "OK" ]; then
                  $visu $RACINE/$projet/tmp/preview.png &
               else
                  $visu $RACINE/$projet/tmp/preview.png > /dev/null 2>&1 &
               fi
            elif [ -f "$RACINE/$projet/tmp/00000001.png" ]; then
               mv -f $RACINE/$projet/tmp/00000001.png $RACINE/$projet/tmp/preview.png
               rm -f $RACINE/$projet/tmp/000*.png
               if [ "$debug" = "OK" ]; then
                  $visu $RACINE/$projet/tmp/preview.png &
               else
                  $visu $RACINE/$projet/tmp/preview.png > /dev/null 2>&1 &
               fi
            fi
#            [ -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
            echo
            isformat=""
            while [ "$isformat" = "" ]; do
               echo -e -n "${SUBCOLOR}$p2"
               echo -e -n "${INPUTCOLOR}> "
               read satisf
               [ "$satisf" = "N" ] && satisf=n
               [ "$satisf" = "$p3" ] && satisf=$p4
               if [ "$satisf" = "" ]; then
                  satisf=n
                  echo "$p5"
               fi
               if [ "$lng" = "fr" ]; then
                  isformat=`echo $satisf | grep "^[oOnN]$"`
               elif [ "$lng" = "en" ]; then
                  isformat=`echo $satisf | grep "^[yYnN]$"`
               elif [ "$lng" = "sp" ]; then
                  isformat=`echo $satisf | grep "^[sSnN]$"`
               fi
               if [ "$isformat" = "" ]; then
                  echo "$p6"
               fi
            done
         fi
         echo -e "${MAINCOLOR}"
}
#------------------------------------------------------------ dbut de la fonction finalisation -----------------------------------------------------------
function finalisation () {
if [ $etapedeb -le 7 ]; then
   echo
   echo -e "${TABLECOLOR}$p7${MAINCOLOR}"
   echo
   pas=300
   decal=$decalinit
   epsi=0
   test="notok"
   t1=`date +'%s'`
   i=0
   until [ "$test" = "ok" ]
   do
      echo -e "${HEADCOLOR}$p8$decal ms${MAINCOLOR}"
      if [ "$contain" = "ogm" ]; then
         if [ "$multiaudio" != "OK" ];then
            $merge -o $RACINE/$projet/video/${projet}.$extvideo $RACINE/$projet/video/${projet}sans-son.avi -s $decal $RACINE/$projet/audio/son.ogg 2>$RACINE/$projet/tmp/logmux
            i=$(($i+1))
         else
            case $nbaudio in
               2) $merge -o $RACINE/$projet/video/${projet}.$extvideo $RACINE/$projet/video/${projet}sans-son.avi -s $decal -c LANGUAGE=${pisteaudio[1]} $RACINE/$projet/audio/son1.ogg -s $decal -c LANGUAGE=${pisteaudio[2]} $RACINE/$projet/audio/son2.ogg 2>$RACINE/$projet/tmp/logmux ;;
               3) $merge -o $RACINE/$projet/video/${projet}.$extvideo $RACINE/$projet/video/${projet}sans-son.avi -s $decal -c LANGUAGE=${pisteaudio[1]} $RACINE/$projet/audio/son1.ogg -s $decal -c LANGUAGE=${pisteaudio[2]} $RACINE/$projet/audio/son2.ogg -s $decal -c LANGUAGE=${pisteaudio[3]} $RACINE/$projet/audio/son3.ogg 2>$RACINE/$projet/tmp/logmux ;;
               4) $merge -o $RACINE/$projet/video/${projet}.$extvideo $RACINE/$projet/video/${projet}sans-son.avi -s $decal -c LANGUAGE=${pisteaudio[1]} $RACINE/$projet/audio/son1.ogg -s $decal -c LANGUAGE=${pisteaudio[2]} $RACINE/$projet/audio/son2.ogg -s $decal -c LANGUAGE=${pisteaudio[3]} $RACINE/$projet/audio/son3.ogg -s $decal -c LANGUAGE=${pisteaudio[4]} $RACINE/$projet/audio/son4.ogg 2>$RACINE/$projet/tmp/logmux ;;
               5) $merge -o $RACINE/$projet/video/${projet}.$extvideo $RACINE/$projet/video/${projet}sans-son.avi -s $decal -c LANGUAGE=${pisteaudio[1]} $RACINE/$projet/audio/son1.ogg -s $decal -c LANGUAGE=${pisteaudio[2]} $RACINE/$projet/audio/son2.ogg -s $decal -c LANGUAGE=${pisteaudio[3]} $RACINE/$projet/audio/son3.ogg -s $decal -c LANGUAGE=${pisteaudio[4]} $RACINE/$projet/audio/son4.ogg -s $decal -c LANGUAGE=${pisteaudio[5]} $RACINE/$projet/audio/son5.ogg 2>$RACINE/$projet/tmp/logmux ;;
               6) $merge -o $RACINE/$projet/video/${projet}.$extvideo $RACINE/$projet/video/${projet}sans-son.avi -s $decal -c LANGUAGE=${pisteaudio[1]} $RACINE/$projet/audio/son1.ogg -s $decal -c LANGUAGE=${pisteaudio[2]} $RACINE/$projet/audio/son2.ogg -s $decal -c LANGUAGE=${pisteaudio[3]} $RACINE/$projet/audio/son3.ogg -s $decal -c LANGUAGE=${pisteaudio[4]} $RACINE/$projet/audio/son4.ogg -s $decal -c LANGUAGE=${pisteaudio[5]} $RACINE/$projet/audio/son5.ogg -s $decal -c LANGUAGE=${pisteaudio[6]} $RACINE/$projet/audio/son6.ogg 2>$RACINE/$projet/tmp/logmux ;;
               *) echo "ERROR MUX"
                  exit ;;
            esac
            i=$(($i+1))
         fi
      elif [ "$contain" = "matroska" ]; then
         if [ "$multiaudio" != "OK" ];then
            if [ $i -eq 0 ]; then
               ID=`$merge --identify $RACINE/$projet/audio/son.ogg | grep "Track ID" | awk -F ":" '{print $1}' | awk '{print $3}'`
               audiolang=`mkvmerge --list-languages | grep -w ${pisteaudio} | head -n 1 | awk -F "|" '{print $2}' | awk '{print $1}'`
               [ "$audiolang" = "" ] && audiolang="und"
            fi
            if [ "$sub" = "OK" ]; then
               nomsub2=`cat $RACINE/$projet/sub/nom | sed -e "s/\.sub/\.idx/"`
               $merge -o $RACINE/$projet/video/${projet}.$extvideo --chapters $RACINE/$projet/tmp/$projet-chapitrage $RACINE/$projet/video/${projet}sans-son.avi -y $ID:$decal --language $ID:$audiolang  $RACINE/$projet/audio/son.ogg $RACINE/$projet/sub/$nomsub2 2>$RACINE/$projet/tmp/logmux  
            else
               $merge -o $RACINE/$projet/video/${projet}.$extvideo --chapters $RACINE/$projet/tmp/$projet-chapitrage $RACINE/$projet/video/${projet}sans-son.avi -y $ID:$decal --language $ID:$audiolang  $RACINE/$projet/audio/son.ogg 2>$RACINE/$projet/tmp/logmux
            fi
            i=$(($i+1))
         else
            if [ $i -eq 0 ]; then
               j=1
               while [ $j -le $nbaudio ]; do
                  ID[$j]=`$merge --identify $RACINE/$projet/audio/son${j}.ogg | grep "Track ID" | awk -F ":" '{print $1}' | awk '{print $3}'`
                  audiolang[$j]=`$merge --list-languages | grep -w ${pisteaudio[$j]} | head -n 1 | awk -F "|" '{print $2}' | awk '{print $1}'`
                  [ "${audiolang[$j]}" = "" ] && audiolang[$j]="und"
                  j=$(($j+1))
               done
            fi
            if [ "$sub" = "OK" ]; then
               nomsub2=`cat $RACINE/$projet/sub/nom | sed -e "s/\.sub/\.idx/"`
               case $nbaudio in
                  2) $merge -o $RACINE/$projet/video/${projet}.$extvideo --chapters $RACINE/$projet/tmp/$projet-chapitrage $RACINE/$projet/video/${projet}sans-son.avi -y ${ID[1]}:$decal --language ${ID[1]}:${audiolang[1]} $RACINE/$projet/audio/son1.ogg -y ${ID[2]}:$decal --language ${ID[2]}:${audiolang[2]} $RACINE/$projet/audio/son2.ogg $RACINE/$projet/sub/$nomsub2 2>$RACINE/$projet/tmp/logmux ;;
                  3) $merge -o $RACINE/$projet/video/${projet}.$extvideo --chapters $RACINE/$projet/tmp/$projet-chapitrage $RACINE/$projet/video/${projet}sans-son.avi -y ${ID[1]}:$decal --language ${ID[1]}:${audiolang[1]} $RACINE/$projet/audio/son1.ogg -y ${ID[2]}:$decal --language ${ID[2]}:${audiolang[2]} $RACINE/$projet/audio/son2.ogg -y ${ID[3]}:$decal --language ${ID[3]}:${audiolang[3]} $RACINE/$projet/audio/son3.ogg $RACINE/$projet/sub/$nomsub2 2>$RACINE/$projet/tmp/logmux ;;
                  4) $merge -o $RACINE/$projet/video/${projet}.$extvideo --chapters $RACINE/$projet/tmp/$projet-chapitrage $RACINE/$projet/video/${projet}sans-son.avi -y ${ID[1]}:$decal --language ${ID[1]}:${audiolang[1]} $RACINE/$projet/audio/son1.ogg -y ${ID[2]}:$decal --language ${ID[2]}:${audiolang[2]} $RACINE/$projet/audio/son2.ogg -y ${ID[3]}:$decal --language ${ID[3]}:${audiolang[3]} $RACINE/$projet/audio/son3.ogg -y ${ID[4]}:$decal --language ${ID[4]}:${audiolang[4]} $RACINE/$projet/audio/son4.ogg $RACINE/$projet/sub/$nomsub2 2>$RACINE/$projet/tmp/logmux ;;
                  5) $merge -o $RACINE/$projet/video/${projet}.$extvideo --chapters $RACINE/$projet/tmp/$projet-chapitrage $RACINE/$projet/video/${projet}sans-son.avi -y ${ID[1]}:$decal --language ${ID[1]}:${audiolang[1]} $RACINE/$projet/audio/son1.ogg -y ${ID[2]}:$decal --language ${ID[2]}:${audiolang[2]} $RACINE/$projet/audio/son2.ogg -y ${ID[3]}:$decal --language ${ID[3]}:${audiolang[3]} $RACINE/$projet/audio/son3.ogg -y ${ID[4]}:$decal --language ${ID[4]}:${audiolang[4]} $RACINE/$projet/audio/son4.ogg -y ${ID[5]}:$decal --language ${ID[5]}:${audiolang[5]} $RACINE/$projet/audio/son5.ogg $RACINE/$projet/sub/$nomsub2 2>$RACINE/$projet/tmp/logmux ;;
                  6) $merge -o $RACINE/$projet/video/${projet}.$extvideo --chapters $RACINE/$projet/tmp/$projet-chapitrage $RACINE/$projet/video/${projet}sans-son.avi -y ${ID[1]}:$decal --language ${ID[1]}:${audiolang[1]} $RACINE/$projet/audio/son1.ogg -y ${ID[2]}:$decal --language ${ID[2]}:${audiolang[2]} $RACINE/$projet/audio/son2.ogg -y ${ID[3]}:$decal --language ${ID[3]}:${audiolang[3]} $RACINE/$projet/audio/son3.ogg -y ${ID[4]}:$decal --language ${ID[4]}:${audiolang[4]} $RACINE/$projet/audio/son4.ogg -y ${ID[5]}:$decal --language ${ID[5]}:${audiolang[5]} $RACINE/$projet/audio/son5.ogg -y ${ID[6]}:$decal --language ${ID[6]}:${audiolang[6]} $RACINE/$projet/audio/son6.ogg $RACINE/$projet/sub/$nomsub2 2>$RACINE/$projet/tmp/logmux ;;
                  *) echo "ERROR MUX"
                     exit ;;
               esac
            else
               case $nbaudio in
                  2) $merge -o $RACINE/$projet/video/${projet}.$extvideo --chapters $RACINE/$projet/tmp/$projet-chapitrage $RACINE/$projet/video/${projet}sans-son.avi -y ${ID[1]}:$decal --language ${ID[1]}:${audiolang[1]} $RACINE/$projet/audio/son1.ogg -y ${ID[2]}:$decal --language ${ID[2]}:${audiolang[2]} $RACINE/$projet/audio/son2.ogg 2>$RACINE/$projet/tmp/logmux ;;
                  3) $merge -o $RACINE/$projet/video/${projet}.$extvideo --chapters $RACINE/$projet/tmp/$projet-chapitrage $RACINE/$projet/video/${projet}sans-son.avi -y ${ID[1]}:$decal --language ${ID[1]}:${audiolang[1]} $RACINE/$projet/audio/son1.ogg -y ${ID[2]}:$decal --language ${ID[2]}:${audiolang[2]} $RACINE/$projet/audio/son2.ogg -y ${ID[3]}:$decal --language ${ID[3]}:${audiolang[3]} $RACINE/$projet/audio/son3.ogg 2>$RACINE/$projet/tmp/logmux ;;
                  4) $merge -o $RACINE/$projet/video/${projet}.$extvideo --chapters $RACINE/$projet/tmp/$projet-chapitrage $RACINE/$projet/video/${projet}sans-son.avi -y ${ID[1]}:$decal --language ${ID[1]}:${audiolang[1]} $RACINE/$projet/audio/son1.ogg -y ${ID[2]}:$decal --language ${ID[2]}:${audiolang[2]} $RACINE/$projet/audio/son2.ogg -y ${ID[3]}:$decal --language ${ID[3]}:${audiolang[3]} $RACINE/$projet/audio/son3.ogg -y ${ID[4]}:$decal --language ${ID[4]}:${audiolang[4]} $RACINE/$projet/audio/son4.ogg 2>$RACINE/$projet/tmp/logmux ;;
                  5) $merge -o $RACINE/$projet/video/${projet}.$extvideo --chapters $RACINE/$projet/tmp/$projet-chapitrage $RACINE/$projet/video/${projet}sans-son.avi -y ${ID[1]}:$decal --language ${ID[1]}:${audiolang[1]} $RACINE/$projet/audio/son1.ogg -y ${ID[2]}:$decal --language ${ID[2]}:${audiolang[2]} $RACINE/$projet/audio/son2.ogg -y ${ID[3]}:$decal --language ${ID[3]}:${audiolang[3]} $RACINE/$projet/audio/son3.ogg -y ${ID[4]}:$decal --language ${ID[4]}:${audiolang[4]} $RACINE/$projet/audio/son4.ogg -y ${ID[5]}:$decal --language ${ID[5]}:${audiolang[5]} $RACINE/$projet/audio/son5.ogg 2>$RACINE/$projet/tmp/logmux ;;
                  6) $merge -o $RACINE/$projet/video/${projet}.$extvideo --chapters $RACINE/$projet/tmp/$projet-chapitrage $RACINE/$projet/video/${projet}sans-son.avi -y ${ID[1]}:$decal --language ${ID[1]}:${audiolang[1]} $RACINE/$projet/audio/son1.ogg -y ${ID[2]}:$decal --language ${ID[2]}:${audiolang[2]} $RACINE/$projet/audio/son2.ogg -y ${ID[3]}:$decal --language ${ID[3]}:${audiolang[3]} $RACINE/$projet/audio/son3.ogg -y ${ID[4]}:$decal --language ${ID[4]}:${audiolang[4]} $RACINE/$projet/audio/son4.ogg -y ${ID[5]}:$decal --language ${ID[5]}:${audiolang[5]} $RACINE/$projet/audio/son5.ogg -y ${ID[6]}:$decal --language ${ID[6]}:${audiolang[6]} $RACINE/$projet/audio/son6.ogg 2>$RACINE/$projet/tmp/logmux ;;
                  *) echo "ERROR MUX"
                     exit ;;
               esac
            fi
            i=$(($i+1))
         fi
      fi
      if [ $i -eq 1 ]; then
         echo
         echo -e "${MAINCOLOR}$p355"
         read
      fi
      echo -e "${MAINCOLOR}$p9"
      sleep 1
      if [ "$debug" = "OK" ]; then
         mplayer -loop 0 -osdlevel 2 -vo $VO -ao $AO $RACINE/$projet/video/${projet}.$extvideo
      else
         mplayer -loop 0 -osdlevel 2 -vo $VO -ao $AO $RACINE/$projet/video/${projet}.$extvideo > /dev/null 2>&1
      fi
      rep="notok"
      until [ "$rep" = "ok" ]
      do
         echo -e -n "${SUBCOLOR}$p10"
         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 "$p11"
              rep="notok" ;;
         esac
      done
      depasse=`bc <<EOF
      scale=0
      $epsi * $epsiold
EOF`
      if [ "$depasse" = "-1" ] ; then
         pas=`bc <<EOF
         scale=0
         $pas / 2
EOF`
      fi
      if [ "$test" != "ok" ] ; then
         decal=`bc <<EOF
         scale=0
         $decal + $pas * $epsi
EOF`
      fi
   done
   duree=`cat $RACINE/$projet/tmp/infos.son | grep "length" | awk -F "=" '{print $3}' | awk '{print $1}'`
   t2=`date +'%s'`
   nbhrs=`bc <<EOF
          scale=0
          ($t2 - $t1) / 3600
EOF`
   nbmin=`bc <<EOF
          scale=0
          ($t2 - $t1) / 60 - $nbhrs * 60
EOF`
   nbsec=`bc <<EOF
          scale=0
          ($t2 - $t1) - $nbmin * 60 - $nbhrs * 3600
EOF`
   vitsynchro=`bc <<EOF
          scale=2
          $duree / ($t2 - $t1) * $fps
EOF`
   echo -n -e "${MAINCOLOR}"
   echo "$p262 : ${nbhrs}hrs ${nbmin}min ${nbsec}sec" > $RACINE/$projet/tmp/mixtime
   echo "$p263 : $vitsynchro fps" > $RACINE/$projet/tmp/mixspeed
   echo "mixage A/V -->  $decal" >> $RACINE/$projet/tmp/log
fi
taillefilm=`bc <<EOF
   scale=6
   $(ls -l $RACINE/$projet/video/${projet}.$extvideo | awk '{print $5}') / 1024 / 1024
EOF`
case $tailleCD in
   1300 ) echo -e "${TABLECOLOR}$p12"
            echo -e "${MAINCOLOR}"
            if [ "$contain" = "ogm" ]; then
               ogmsplit $RACINE/$projet/video/${projet}.$extvideo -s 650
            elif [ "$contain" = "matroska" ]; then
               $merge --split 650m $RACINE/$projet/video/${projet}.$extvideo -o $RACINE/$projet/video/${projet}.$extvideo
            fi
            mv $RACINE/$projet/video/${projet}-*1.$extvideo $RACINE/$projet/video/cd1/${projet}-cd1.$extvideo
            mv $RACINE/$projet/video/${projet}-*2.$extvideo $RACINE/$projet/video/cd2/${projet}-cd2.$extvideo;;

   1404 ) echo -e "${TABLECOLOR}$p12"
             echo -e "${MAINCOLOR}"
             if [ "$contain" = "ogm" ]; then
                ogmsplit $RACINE/$projet/video/${projet}.$extvideo -s 702
             elif [ "$contain" = "matroska" ]; then
                $merge --split 702m $RACINE/$projet/video/${projet}.$extvideo -o $RACINE/$projet/video/${projet}.$extvideo
             fi
             mv $RACINE/$projet/video/${projet}-*1.$extvideo $RACINE/$projet/video/cd1/${projet}-cd1.$extvideo
             mv $RACINE/$projet/video/${projet}-*2.$extvideo $RACINE/$projet/video/cd2/${projet}-cd2.$extvideo ;;
esac

echo -e "${TABLECOLOR}$p13${MAINCOLOR}"
echo -e "${HEADCOLOR}"
cat $RACINE/$projet/tmp/riptime
cat $RACINE/$projet/tmp/audiotime
cat $RACINE/$projet/tmp/videotime
cat $RACINE/$projet/tmp/mixtime
cat $RACINE/$projet/tmp/ripspeed
cat $RACINE/$projet/tmp/audiospeed
cat $RACINE/$projet/tmp/videospeed
cat $RACINE/$projet/tmp/mixspeed
echo -e "${HEADCOLOR}$p14${taillefilm}$p117"
echo -e "${HEADCOLOR}$p15${tailleCD}$p117"
echo -e "${MAINCOLOR}"
}
#-------------------------------------------------------------- fin de la fonction finalisation -----------------------------------------------------------


# Dbut --- Reprise aprs extinction
if [ -r ~/.tuxripextinction ]; then
#on lit les variables ncssaires dans le log, le txriprc et le tuxripextinction
   RACINE=`cat ~/.tuxripextinction | awk '{print $1}'`
   projet=`cat ~/.tuxripextinction | awk '{print $2}'`
   decalinit=`cat ~/.tuxriprc | grep ^"3\." | awk '{print $2}'`
   VO=`cat ~/.tuxriprc | grep ^"7\." | awk '{print $4}'`
   AO=`cat ~/.tuxriprc | grep ^"8\." | awk '{print $4}'`
   tailleCD=`cat $RACINE/$projet/tmp/log | grep bitrate | awk '{print $6}'`
   fps=`cat $RACINE/$projet/tmp/log | grep scan | awk '{print $12}'`
   contain=`cat ~/.tuxriprc | grep ^"15\." | awk '{print $2}'`
   if [ "$contain" = "ogm" ]; then
      extvideo="ogm"
      LISTE_APPLIS="ogmmerge ogmsplit"
      sortie="notok"
      for i in $LISTE_APPLIS;
      do
        which $i > /dev/null 2>&1
        if [ "$?" = "1" ]; then
           [ "$sortie" = "notok" ] && echo -e "${MAINCOLOR}$p282"
           echo -e "${HEADCOLOR} ${i}${MAINCOLOR}"
           sortie="ok"
        fi;
      done
      if [ "$sortie" = "ok" ]; then
         echo
         exit -1
      fi
      merge=`which ogmmerge`
   elif [ "$contain" = "matroska" ]; then
      extvideo="mkv"
      LISTE_APPLIS="mkvmerge"
      sortie="notok"
      for i in $LISTE_APPLIS;
      do
        which $i > /dev/null 2>&1
        if [ "$?" = "1" ]; then
           [ "$sortie" = "notok" ] && echo -e "${MAINCOLOR}$p282"
           echo -e "${HEADCOLOR} ${i}${MAINCOLOR}"
           sortie="ok"
        fi;
      done
      if [ "$sortie" = "ok" ]; then
         echo
         exit -1
      fi
      merge=`which mkvmerge`
   fi

   echo "$p16$RACINE/$projet$p16bis"
   echo "$p17"
   echo "$p18"
# on finit le projet : affichage,mixage
   echo
   echo -e "${HEADCOLOR}$p19${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 aprs extinction

# Flags ---------------------
full=-1
resume=""
xvid=""
grave=""
extinction=""
lb=""
modetest=""
testcomp=""
source=""
multiaudio=""
fat32=""
xvid4=""
debug=""
while [ $1 ]; do
   case $1 in
      "$p375")  debug="OK"
                echo "$p376"
                shift;;
      "$p364" ) xvid4="OK"
                existe=`which xvid4conf 2>/dev/null`
                if [ "$existe" = "" ]; then
                   echo "$p367"
                   exit
                fi
                existe=`which $transperl 2>/dev/null`
                if [ "$existe" = "" ]; then
                   echo "$p378"
                   exit
                fi
                echo "$p365"
                shift;;
      "$p319" ) COLOROFF=""    # standart color
                HEADCOLOR=""  # green
                MAINCOLOR=""  # white
                SUBCOLOR=""   # blue
                TABLECOLOR="" # red
                INPUTCOLOR=""
                echo "$p320"
                shift ;;
      "$p93" ) exit 0 ;;
      "$p238" ) silence="OK"
                     shift
                     echo "$p239" ;;
      "$p232" ) if [ "$deflng" = "ok" ]; then
                       rm -f ~/.tuxriplng
                       echo "$p233"
                       echo "$p17"
                       rep="notok"
                       while [ "$rep" = "notok" ]; do
                          echo "$p234 (en/fr/sp) ?"
                          read lng
                          case $lng in
                            "en") rep="ok" ;;
                            "fr") rep="ok" ;;
                            "sp") rep="ok" ;;
                               *) echo "$p235" ;;
                          esac
                       done
                       touch ~/.tuxriplng
                       echo $lng > ~/.tuxriplng
                       exit
                    else
                      shift
                      echo "$p232 $p236"
                    fi ;;
      "$p90" ) modetest="OK"
                  shift
                  full=$1
                  isnum=`echo $full | grep "^[1-9][0-9]*$"`
                  if [ "$isnum" = "" ]; then
                     full=1
                  else
                     shift
                  fi
                 echo "$p20$full$p20bis" ;;
      "$p89" ) resume="OK"
                     echo "$p21"
                     shift;;
      "$p94" ) xvid="OK"
                 echo "$p22"
                 shift;;
      "$p86" ) [ -r ~/.tuxriprc ] && rm -f ~/.tuxriprc
                    touch ~/.tuxriprc
                     echo "$p17"
                    echo "$p23"
#repertoire de travail
                    exist=notok
                    until [ "$exist" = "OK" ]
                    do
                       echo -n -e "${SUBCOLOR}$p24"
                       echo -n -e "${INPUTCOLOR}> "
                       read RACINE
                       if [ "$RACINE" = "" ] ; then
                          RACINE="/space"
                          echo "$p25 : /space"
                       fi
                       if [ -d "$RACINE" ]; then
                          exist=OK
                          FS=`df -P -T -m $RACINE | grep /dev | awk '{print $2}'`
                          free=`df -P -T -m $RACINE | grep /dev | awk '{print $5}'`
                          if [ $free -le 8000 ]; then
                             echo -e "${MAINCOLOR}$free$p254 $RACINE$p255"
                          fi
                       else
                          echo -e  "${HEADCOLOR}$p26"
                       fi
                    done
                    #echo "$p27" $RACINE >> ~/.tuxriprc
                    echo "1." $RACINE >> ~/.tuxriprc
#device
                    exist=notok
                    until [ "$exist" = "OK" ]
                    do
                       echo -n -e "${SUBCOLOR}$p28"
                       echo -n -e "${INPUTCOLOR}> "
                       read DEVICE
                       if [ "$DEVICE" = "" ] ; then
                          DEVICE="/dev/dvd"
                          echo "$p25 : /dev/dvd"
                       fi
                       if [ -r "$DEVICE" ]; then
                          exist=OK
                       else
                          echo -e  "${HEADCOLOR}$p29"
                       fi
                    done
                    #echo "$p30" $DEVICE >> ~/.tuxriprc
                    echo "2." $DEVICE >> ~/.tuxriprc
# decalage initial de synchronisation en ms
                    isnum=""
                    while [ "$isnum" = "" ]
                    do
                       echo -n -e "${SUBCOLOR}$p31"
                       echo -n -e "${INPUTCOLOR}> "
                       read decalinit
                       if [ "$decalinit" = "" ] ; then
                          decalinit=0
                          echo "$p25 : 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 "$p32"
                          fi
                       fi
                    done
                    #echo "synchro init : " $decalinit >> ~/.tuxriprc
                    echo "3." $decalinit >> ~/.tuxriprc
# options libavcodec
                    echo -n -e "${SUBCOLOR}$p33: 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 "$p25..."
                    fi
                    #echo "$p34" $LAVCOPT >> ~/.tuxriprc
                    echo "4." $LAVCOPT >> ~/.tuxriprc
# options xvid
                    echo -n -e "${SUBCOLOR}$p35: me_quality=6:trellis:gmc:max_bframes=2:hq_ac:vhq=4:chroma_me:chroma_opt:psnr] ? "
                    echo -n -e "${INPUTCOLOR}> "
                    read XVIDOPT
                    if [ "$XVIDOPT" = "" ] ; then
                        XVIDOPT="me_quality=6:trellis:gmc:max_bframes=2:hq_ac:vhq=4:chroma_me:chroma_opt:psnr"
                        echo "$p25..."
                    fi
                    #echo "$p36" $XVIDOPT >> ~/.tuxriprc
                    echo "5." $XVIDOPT >> ~/.tuxriprc
# normalisation maxi
                    isnum=""
                    while [ "$isnum" = "" ]
                    do
                       echo -n -e "${SUBCOLOR}$p37"
                       echo -n -e "${INPUTCOLOR}> "
                       read gainmax
                       if [ "$gainmax" = "" ] ; then
                           gainmax=3
                           echo "$p25 : 3"
                       fi
                       isnum=`echo $gainmax | grep "^[1-9]$"`
                       if [ "$isnum" = "" ] ; then
                          echo "$p38"
                       fi
                    done
                    #echo "$p39" $gainmax >> ~/.tuxriprc
                    echo "6." $gainmax >> ~/.tuxriprc
# drivers video mplayer
                    verif="notok"
                    while [ "$verif" = "notok" ];
                    do
                       echo -n -e "${SUBCOLOR}$p40"
                       echo -n -e "${INPUTCOLOR}> "
                       read VO
                       case $VO in
                          x11 | xv | sdl )    exist=`mplayer -vo help 2>/dev/null | grep -w "$VO"`
                                              if [ "$exist" = "" ]; then
                                                 echo "$p353 ${VO}$p354"
                                              else
                                                 verif="OK"
                                              fi;;
                          "" ) verif="OK"
                               VO="xv"
                               echo "$p25 : xv" ;;
                          * )  echo "$p41"
                               verif="notok" ;;
                       esac
                    done
                    #echo "$p42" $VO >> ~/.tuxriprc
                    echo "7." $VO >> ~/.tuxriprc
# drivers audio mplayer
                    verif="notok"
                    while [ "$verif" = "notok" ];
                    do
                       echo -n -e "${SUBCOLOR}$p43"
                       echo -n -e "${INPUTCOLOR}> "
                       read AO
                       case $AO in
                          oss | alsa9 | sdl ) exist=`mplayer -ao help 2>/dev/null | grep -w "$AO"`
                                              if [ "$exist" = "" ]; then
                                                 echo "$p353 ${AO}$p354"
                                              else
                                                 verif="OK"
                                              fi;;
                          "" ) verif="OK"
                               AO="oss"
                               echo "$p25 : oss" ;;
                          * )  echo "$p44"
                               verif="notok" ;;
                       esac
                    done
                    #echo "$p45" $AO >> ~/.tuxriprc
                    echo "8." $AO >> ~/.tuxriprc
# Chaine SCSI du graveur
                    isformat=""
                    while [ "$isformat" = "" ]
                    do
                       echo -n -e "${SUBCOLOR}$p46"
                       echo -n -e "${INPUTCOLOR}> "
                       read graveur
                       if [ "$graveur" = "" ]; then
                           graveur="0,3,0"
                           echo "$p25 : 0,3,0"
                       fi
                       isformat=`echo $graveur | grep "^[0-9],[0-9],[0-9]$"`
                       if [ "$isformat" = "" ] ; then
                          echo "$p47"
                       fi
                    done
                    #echo "$p48" $graveur >> ~/.tuxriprc
                    echo "9." $graveur >> ~/.tuxriprc
# Vitesse de gravure
                    isnum=""
                    while [ "$isnum" = "" ]
                    do
                       echo -n -e "${SUBCOLOR}$p49"
                       echo -n -e "${INPUTCOLOR}> "
                       read vitesse
                       if [ "$vitesse" = "" ] ; then
                           vitesse=12
                          echo "$p25 : 12X"
                       fi
                       isnum=`echo $vitesse | grep "^[1-9][0-9]*$"`
                       if [ "$isnum" = "" ] ; then
                          echo "$p50"
                       fi
                    done
                    #echo "$p51" $vitesse >> ~/.tuxriprc
                    echo "10." $vitesse >> ~/.tuxriprc
# visualisateur d'images
                    test="notok"
                    until [ "$test" = "ok" ]
                    do
                       echo -n -e "${SUBCOLOR}$p52"
                       echo -n -e "${INPUTCOLOR}> "
                       read visu
                       if [ "$visu" = "" ] ; then
                           visu="gqview"
                           echo "$p25 : gqview"
                       fi
                       case $visu in
                          gqview | eog | kview | imview | display ) test="ok" ;;
                          * ) test="notok";;
                       esac
                    done
                    #echo "$p53" $visu >> ~/.tuxriprc
                    echo "11." $visu >> ~/.tuxriprc
# quantizer min/max des gnriques
                    format=""
                    until [ "$format" = "ok" ]
                    do
                       echo -n -e "${SUBCOLOR}$p54"
                       echo -n -e "${INPUTCOLOR}> "
                       read quantgen
                       if [ "$quantgen" = "" ]; then
                           quantgen="20-20"
                           echo "$p25 : 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 "$p55"
                                format="notok"
                             fi ;
                          else
                             echo "$p56"
                             format="notok"
                          fi
                          if [ $max -le 31 ] ; then
                             if [ $max -ge 2 ] ; then
                                fmax="ok"
                             else
                                echo "$p55"
                                format="notok"
                             fi ;
                          else
                             echo "$p56"
                             format="notok"
                          fi
                          if [ "$fmin" = "ok" ] && [ "$fmax" = "ok" ] ; then
                             if [ $min -le $max ] ; then
                                format="ok"
                             else
                                echo "$p57"
                                format="notok"
                             fi
                          fi
                       else
                          echo "$p58"
                          format="notok"
                       fi
                    done
                    #echo "$p59" $quantgen >> ~/.tuxriprc
                    echo "12." $quantgen >> ~/.tuxriprc
# point de montage
                    exist=notok
                    until [ "$exist" = "OK" ]
                    do
                       echo -n -e "${SUBCOLOR}$p272"
                       echo -n -e "${INPUTCOLOR}> "
                       read MNTDVD
                       if [ "$MNTDVD" = "" ] ; then
                          MNTDVD="/mnt/cdrom"
                          echo "$p25 : /mnt/cdrom"
                       fi
                       if [ -x "$MNTDVD" ]; then
                          exist=`cat /etc/fstab | grep $MNTDVD`
                          if [ "$exist" = "" ]; then
                             echo "$p273"
                          else
                             root=`whoami`
                             if [ "$root" = "root" ]; then
                                exist="OK"
                             else
                                droit=`cat /etc/fstab | grep $MNTDVD | grep user`
                                if [ "$droit" = "" ]; then
                                   supermount=`cat /etc/fstab | grep $MNTDVD | grep -w supermount`
                                   if [ "$supermount" = "" ]; then
                                      echo "$p274"
                                   else
                                      exist="OK"
                                   fi
                                else
                                   exist="OK"
                                fi
                             fi
                          fi
                       else
                          echo -e  "${HEADCOLOR}$p26"
                       fi
                    done
                    echo "13." $MNTDVD >> ~/.tuxriprc
# seuil cropping
                    isnum=""
                    while [ "$isnum" = "" ]
                    do
                       echo -n -e "${SUBCOLOR}$p348"
                       echo -n -e "${INPUTCOLOR}> "
                       read seuil
                       if [ "$seuil" = "" ] ; then
                          seuil=24
                          echo "$p25 : 24"
                       fi
                       isnum=`echo $seuil | grep "^[0-9][0-9]*$"`
                       if [ "$isnum" = "" ] ; then
                         echo "$p350"
                       else
                         if [ $seuil -lt 0 ] || [ $seuil -gt 255 ]; then
                            isnum=""
                            echo "$p349"
                         fi
                       fi
                    done
                    echo "14." $seuil >> ~/.tuxriprc
# container
                    verif="notok"
                    while [ "$verif" = "notok" ];
                    do
                       echo -n -e "${SUBCOLOR}$p356"
                       echo -n -e "${INPUTCOLOR}> "
                       read contain
                       case $contain in
                          ogm | matroska ) #exist=`mplayer -ao help 2>/dev/null | grep -w "$AO"`
                                            #  if [ "$exist" = "" ]; then
                                            #     echo "$p353 ${AO}$p354"
                                            #  else
                                                 verif="OK";;
                                             # fi;;
                          "" ) verif="OK"
                               contain="matroska"
                               echo "$p25 : matroska" ;;
                          * )  echo "$p357"
                               verif="notok" ;;
                       esac
                    done
                    echo "15." $contain >> ~/.tuxriprc
# resize
                    verif="notok"
                    while [ "$verif" = "notok" ];
                    do
                       echo -n -e "${SUBCOLOR}$p362"
                       echo -n -e "${INPUTCOLOR}> "
                       read resize
                       case $resize in
                          "fast bilinear" ) sws=0
                                            verif="OK";;
                          "bilinear"      ) sws=1
                                            verif="OK";;
                          "bicubic"       ) sws=2
                                            verif="OK";;
                          "lanczos"       ) sws=9
                                            verif="OK";;
                          ""              ) sws=2
                                            verif="OK"
                                            echo "$p25 : bicubic" ;;
                          * )  echo "$p192"
                               verif="notok" ;;
                       esac
                    done
                    echo "16." $sws >> ~/.tuxriprc
                    echo -e "$MAINCOLOR"
                    exit ;;

      "$p264")  echo "$p17"
                if [ -r ~/.tuxriprc ] ; then
                   RACINE=`cat ~/.tuxriprc | grep ^"1\." | awk '{print $2}'`
                else
                   echo "$p101 $p86"
                   exit
                fi
                yena="notok"
                for directory in $(find $RACINE -type d 2>/dev/null); do
                   if [ -d $directory/tmp ] && [ -d $directory/video ] && [ -d $directory/vob ] && [ -d $directory/audio ]; then
                      yena="OK"
                   fi
                done
                if [ "$yena" = "OK" ]; then
                   echo "$p265"
                   for directory in $(find $RACINE -type d 2>/dev/null); do
                      if [ -d $directory/tmp ] && [ -d $directory/video ] && [ -d $directory/vob ] && [ -d $directory/audio ]; then
                         echo -e "${HEADCOLOR}$directory${MAINCOLOR}"
                      fi
                   done
                else
                   echo "$p268$RACINE"
                   exit
                fi
                valide="notok"
                while [ "$valide" = "notok" ]; do
                   echo "$p266"
                   read rep
                   [ "$rep" = "" ] && rep=n
                   [ "$rep" = "N" ] && rep=n
                   [ "$rep" = "$p3" ] && rep=$p4
                   case $rep in
                     "$p4" ) for directory in $(find $RACINE -type d 2>/dev/null); do
                                if [ -d $directory/tmp ] && [ -d $directory/video ] && [ -d $directory/vob ] && [ -d $directory/audio ]; then
                                   rm -rf $directory
                                fi
                             done
                             valide="OK";;
                     "n"   ) echo $p267
                             valide="OK";;
                     *     ) echo "$p124";;
                   esac
                done
                exit;;


      "$p92"             )  if [ -r ~/.tuxriprc ] ; then
                              echo "$p17"
                              echo "$p60"
                              RACINE=`cat ~/.tuxriprc | grep ^"1\." | awk '{print $2}'`
                              DEVICE=`cat ~/.tuxriprc | grep ^"2\." | awk '{print $2}'`
                              decalinit=`cat ~/.tuxriprc | grep ^"3\." | awk '{print $2}'`
                              LAVCOPT=`cat ~/.tuxriprc | grep ^"4\." | awk '{print $2}'`
                              XVIDOPT=`cat ~/.tuxriprc | grep ^"5\." | awk '{print $2}'`
                              gainmax=`cat ~/.tuxriprc | grep ^"6\." | awk '{print $2}'`
                              VO=`cat ~/.tuxriprc | grep ^"7\." | awk '{print $2}'`
                              AO=`cat ~/.tuxriprc | grep ^"8\." | awk '{print $2}'`
                              graveur=`cat ~/.tuxriprc | grep ^"9\." | awk '{print $2}'`
                              vitesse=`cat ~/.tuxriprc | grep ^"10\." | awk '{print $2}'`
                              visu=`cat ~/.tuxriprc | grep ^"11\." | awk '{print $2}'`
                              quantgen=`cat ~/.tuxriprc | grep ^"12\." | awk '{print $2}'`
                              MNTDVD=`cat ~/.tuxriprc | grep ^"13\." | awk '{print $2}'`
                              seuil=`cat ~/.tuxriprc | grep ^"14\." | awk '{print $2}'`
                              contain=`cat ~/.tuxriprc | grep ^"15\." | awk '{print $2}'`
                              sws=`cat ~/.tuxriprc | grep ^"16\." | awk '{print $2}'`
                              lng=`cat ~/.tuxriplng`
                              echo
                              echo -e "${HEADCOLOR}$p61${SUBCOLOR}"$RACINE
                              echo -e "${HEADCOLOR}$p62${SUBCOLOR}"$DEVICE
                              echo -e "${HEADCOLOR}$p63${SUBCOLOR}"$decalinit"${HEADCOLOR} ms"
                              echo -e "${HEADCOLOR}$p64${SUBCOLOR}"$LAVCOPT
                              echo -e "${HEADCOLOR}$p65${SUBCOLOR}"$XVIDOPT
                              echo -e "${HEADCOLOR}$p66${SUBCOLOR}"$gainmax
                              echo -e "${HEADCOLOR}$p67${SUBCOLOR}"$VO
                              echo -e "${HEADCOLOR}$p68${SUBCOLOR}"$AO
                              echo -e "${HEADCOLOR}$p69${SUBCOLOR}"$graveur
                              echo -e "${HEADCOLOR}$p70${SUBCOLOR}"$vitesse"${HEADCOLOR}X"
                              echo -e "${HEADCOLOR}$p71${SUBCOLOR}"$visu
                              echo -e "${HEADCOLOR}$p72${SUBCOLOR}"$quantgen
                              echo -e "${HEADCOLOR}$p275${SUBCOLOR}"$MNTDVD
                              echo -e "${HEADCOLOR}$p351${SUBCOLOR}"$seuil
                              echo -e "${HEADCOLOR}$p358${SUBCOLOR}"$contain
                              echo -e -n "${HEADCOLOR}$p363${SUBCOLOR}"$sws
                              case $sws in
                                 0 ) echo " (fast bilinear)";;
                                 1 ) echo " (bilinear)";;
                                 2 ) echo " (bicubic)";;
                                 9 ) echo " (lanczos)";;
                              esac
                              echo -e "${HEADCOLOR}$p237${SUBCOLOR}"$lng
                           else
                              echo "$p73"
                           fi
                           echo -e "${MAINCOLOR}"
                           exit;;
      "$p85" ) echo "$p17"
                 echo -e "${SUBCOLOR}$p74${MAINCOLOR}"
                 echo " $p86 $p75"
                 echo " $p87 $p76"
                 echo " $p88 $p77"
                 echo " $p85 $p78"
                 echo " $p89 $p79"
                 echo " $p90 n $p80"
                 echo " $p91 $p81"
                 echo " $p92 $p82"
                 echo " $p93 $p83"
                 echo " $p94 $p84"
                 echo " $p97 $p84bis"
                 echo " $p232 $p84ter"
                 echo " $p238 $p84quad"
                 echo " $p242 $p243 : $p249"
                 echo " $p242 $p245 : $p250"
                 echo " $p359 $p361"
                 echo " $p264 $p269"
                 echo " $p270 $p281"
                 echo " $p283 $p293 $p270)."
                 echo " $p312 $p315"
                 echo " $p319 $p321"
                 echo " $p297 $p322"
                 echo " $p323 $p352"
                 echo " $p364 $p368"
                 echo " $p375 $p377"
                 shift
                 exit;;
      "$p87" ) echo "$p95"
                             lb="OK"
                             shift;;
      "$p88" ) echo "$p96"
                         extinction="OK"
                         shift;;

       "$p97" ) echo "$p98"
                existe1=`which cdrecord 2>/dev/null`
                existe2=`which mkisofs 2>/dev/null`
                if [ "$existe1" != "" ] && [ "$existe2" != "" ]; then
                   grave="OK"
                else
                   echo "$p289"
                   exit
                fi
                shift;;
       "$p91" ) echo "$p99"
                          testcomp="OK"
                          shift;;
       "$p242" )  shift
                  echo "$p251 $p242 $p252"
                  preset=$1
                  case $preset in
                     "$p243" ) LAVCOPT="vcodec=mpeg4:vqmin=2:vqmax=20:vmax_b_frames=0:vhq:keyint=250:vme=4:v4mv"
                              echo "-->$p244"
                              preset="OK"
                              shift ;;

                     "$p245" ) LAVCOPT="vcodec=mpeg4:vqmin=2:vqmax=20:keyint=250:mbd=2:mv0:trell:cbp:vmax_b_frames=1:v4mv:vb_strategy=0:vlelim=0:vcelim=7:cmp=2:subcmp=2:precmp=2:predia=1:dia=1:vme=4"
                              echo "-->$p246"
                              preset="OK"
                              shift ;;

                     "old-extreme" ) LAVCOPT="vcodec=mpeg4:vqmin=2:vqmax=20:vmax_b_frames=1:vhq:qpel:trell:keyint=250:vme=4:v4mv"
                              echo "-->preset old-extreme :"
                              echo $LAVCOPT
                              preset="OK"
                              shift ;;
                     "1" ) LAVCOPT="vcodec=mpeg4:vqmin=2:vqmax=20:keyint=250:mbd=2:mv0:trell:cbp:vmax_b_frames=1:v4mv:vb_strategy=0:vlelim=0:vcelim=7:cmp=2:subcmp=2:precmp=2:predia=1:dia=1:vme=4:qpel"
                              echo "-->preset 1 :"
                              echo $LAVCOPT
                              preset="OK"
                              shift ;;

                     *      ) echo "$p247 '$preset'$p248" ;;
                  esac ;;


       "$p359"  )echo "$p17"
                 echo
                 echo -e "${SUBCOLOR}-->$p360${MAINCOLOR}"

                 LAVCOPT1="vcodec=mpeg4:vqmin=2:vqmax=20:vmax_b_frames=0:vhq:keyint=250:vme=4:v4mv"
                 echo -e "*preset ${INPUTCOLOR}standard${MAINCOLOR} : ${LAVCOPT1}"
                 echo
                  LAVCOPT1="vcodec=mpeg4:vqmin=2:vqmax=20:keyint=250:mbd=2:mv0:trell:cbp:vmax_b_frames=1:v4mv:vb_strategy=0:vlelim=0:vcelim=7:cmp=2:subcmp=2:precmp=2:predia=1:dia=1:vme=4"
                 echo -e "*preset ${INPUTCOLOR}extreme${MAINCOLOR} : ${LAVCOPT1}"
                 echo

                 LAVCOPT1="vcodec=mpeg4:vqmin=2:vqmax=20:vmax_b_frames=1:vhq:qpel:trell:keyint=250:vme=4:v4mv"
                 echo -e "*preset ${INPUTCOLOR}old-extreme${MAINCOLOR} : ${LAVCOPT1}"
                 echo

LAVCOPT1="vcodec=mpeg4:vqmin=2:vqmax=20:keyint=250:mbd=2:mv0:trell:cbp:vmax_b_frames=1:v4mv:vb_strategy=0:vlelim=0:vcelim=7:cmp=2:subcmp=2:precmp=2:predia=1:dia=1:vme=4:qpel"
                 echo -e "*preset ${INPUTCOLOR}1${MAINCOLOR} : ${LAVCOPT1}"
                 echo

                 shift
                 exit;;

       "$p270" ) echo "$p17"
                 echo -n "$p271 "
                 if [ -r ~/.tuxriprc ] ; then
                    RACINE=`cat ~/.tuxriprc | grep ^"1\." | awk '{print $2}'`
                    echo "($RACINE/clone/)."
                    DEVICE=`cat ~/.tuxriprc | grep ^"2\." | awk '{print $2}'`
                    FS=`df -P -T -m $RACINE | grep /dev | awk '{print $2}'`
                    free=`df -P -T -m $RACINE | grep /dev | awk '{print $5}'`
                    if [ $free -le 9400 ]; then
                       echo -e "${HEADCOLOR}$free$p254 $RACINE$p255${MAINCOLOR}"
                       exit
                    fi
                    MNTDVD=`cat ~/.tuxriprc | grep ^"13\." | awk '{print $2}'`
                    monte=`cat /etc/mtab | grep $MNTDVD`
                    if [ "$monte" = "" ]; then
                       mount $MNTDVD 2>$RACINE/errmount
                       if [ "$RACINE/errmount" != "" ]; then
                          monte=`cat /etc/mtab | grep $MNTDVD`
                          if [ "$monte" = "" ]; then
                             echo "$p276"
                             exit
                          fi
                       fi
                    fi
                    [ -r $RACINE/errmount ] && rm -f $RACINE/errmount
                    copyvob=`which vobcopy 2>/dev/null`
                    if [ "$copyvob" = "" ]; then
                       echo "$p277"
                    else
                       nomclone=$( dd if=$DEVICE ibs=1 skip=32808 count=32 2>/dev/null | sed "s/\ //g" )
                       [ "$nomclone" = "" ] && nomclone="DVD"
                       echo
                       if [ -d $RACINE/clone ]; then
                          echo > /dev/null
                       else
                          mkdir $RACINE/clone
                       fi
                       vide="notok"
                       until [ "$vide" = "OK" ]; do
                          echo -n -e "${SUBCOLOR}-------> $p279 $nomclone ] ?${MAINCOLOR}"
                          echo -n -e "${INPUTCOLOR}> "
                          read projclone
                          if [ "$projclone" = "" ]; then
                             projclone=$nomclone
                             echo "$p103 : $nomclone"
                          fi
                          if [ -d $RACINE/clone/$projclone ];then
                             isformat=""
                             while [ "$isformat" = "" ]; do
                                echo -n -e  "${SUBCOLOR}------->$p294"
                                echo -n -e "${INPUTCOLOR}> "
                                read verif
                                [ "$verif" = "N" ] && verif=n
                                [ "$verif" = "$p3" ] && verif=$p4
                                if [ "$verif" = "" ]; then
                                  verif=n
                                  echo "$p123"
                                fi
                                if [ "$lng" = "fr" ]; then
                                  isformat=`echo $verif | grep "^[oOnN]$"`
                                elif [ "$lng" = "en" ]; then
                                  isformat=`echo $verif | grep "^[yYnN]$"`
                                elif [ "$lng" = "sp" ]; then
                                  isformat=`echo $verif | grep "^[sSnN]$"`
                                fi
                                if [ "$isformat" = "" ]; then
                                  echo "$p124"
                                fi
                                echo -n -e "${MAINCOLOR}"
                                if [ "$verif" = "$p4" ]; then
                                   rm -rf $RACINE/clone/$projclone
                                   vide="OK"
                                else
                                   echo
                                fi
                             done
                          else
                             echo -e "${MAINCOLOR}"
                             vide="OK"
                          fi
                       done
                       $copyvob -m -o $RACINE/clone -t $projclone
                       monte=`cat /etc/mtab | grep $MNTDVD | grep supermount`
                       [ "$monte" = "" ] && umount $MNTDVD
                    fi
                    exit
                 else
                    echo "$p101 $p86"
                    exit
                 fi;;

      "$p283" ) echo "$p284"
                RACINE=`cat ~/.tuxriprc | grep ^"1\." | awk '{print $2}'`
                [ -r $RACINE/clone/trouve ] && rm -f $RACINE/clone/trouve
                if [ -d $RACINE/clone ]; then
                   yena="notok"
                   for directory in $(find $RACINE/clone -type d 2>/dev/null); do
                      if [ -d $directory/VIDEO_TS/ ]; then
                         yena="OK"
                         touch $RACINE/clone/trouve
                      fi
                   done
                   if [ "$yena" = "OK" ]; then
                      echo "$p287"
                      i=0
                      for directory in $(find $RACINE/clone -type d 2>/dev/null); do
                         if [ -d $directory/VIDEO_TS/ ]; then
                            i=$(($i+1))
                            echo -e "${HEADCOLOR}$i. $directory${MAINCOLOR}"
                            echo "$i. $directory" >> $RACINE/clone/trouve
                         fi
                      done
                      nbclone=$i
                      i=$(($i+1))
                      echo "$i. $p286"
                      isnum=""
                      until [ "$isnum" != "" ]; do
                         echo -e -n "${SUBCOLOR}$p288 $i ] ?${INPUTCOLOR} >"
                         read rep
                         if [ "$rep" = "" ];then
                            rep=$i
                            echo -e -n "$p25 : "
                         fi
                         isnum=`echo $rep | grep "^[0-9][0-9]*$"`
                         if [ "$isnum" = "" ];then
                            echo -e "${MAINCOLOR}$p291"
                         else
                            if [ $rep -eq $i ];then
                               echo "$p290"
                               exit
                            elif [ $rep -lt $i ] && [ $rep -ge 1 ]; then
                               DEVICE=`cat $RACINE/clone/trouve | grep ^"$rep\." | awk '{print $2}'`
                               echo $DEVICE
                               rm -f $RACINE/clone/trouve
                               source="OK"
                            else
                               echo -e "${MAINCOLOR}$p292$i."
                               isnum=""
                            fi
                         fi
                      done
                      echo -e "${MAINCOLOR}"
                   else
                      echo "$p285 ($RACINE/clone)."
                      exit
                   fi
                else
                   echo "$p285 ($RACINE/clone)."
                   exit
                fi
                shift;;

      "$p297" ) multiaudio="OK"
                shift
                echo "$p298" ;;
      "$p312" ) echo "$p313"
                existe1=`which split 2>/dev/null`
                if [ "$existe1" != "" ]; then
                      fat32="OK"
                else
                      echo "$p314"
                      exit
                fi
                shift;;

      "$p323" ) echo "$p324"
                sub="OK"
                shift;;

      * ) echo "$p100$1$p100bis"
          shift;;
   esac
done

#-------------- Tests des dpendances par philou_a7------------------
[ -r ~/.tuxriprc ] && visu=`cat ~/.tuxriprc | grep ^"11\." | awk '{print $2}'`
LISTE_APPLIS="mplayer mencoder transcode tcprobe avimerge tccat tcextract tcdecode tcscan oggenc grep egrep awk sed bc expr $visu split dvdxchap"
sortie="notok"
for i in $LISTE_APPLIS;
do
 which $i > /dev/null 2>&1
 if [ "$?" = "1" ]; then
  [ "$sortie" = "notok" ] && echo -e "${MAINCOLOR}$p282"
  echo -e "${HEADCOLOR} ${i}${MAINCOLOR}"
  sortie="ok"
 fi;
done
if [ "$sortie" = "ok" ]; then
   echo
   exit -1
fi
#-------------- fin Tests des dpendances ------------------

# LECTURE FICHIER DE PREFS et contrle---------------------------
if [ -r ~/.tuxriprc ] ; then
   RACINE=`cat ~/.tuxriprc | grep ^"1\." | awk '{print $2}'`
   FS=`df -P -T -m $RACINE | grep /dev | awk '{print $2}'`
   case $FS in
      "vfat" | "msdos" | "umsdos" | "fat" )   existe1=`which split 2>/dev/null`
                                              if [ "$existe1" != "" ]; then
                                                 fat32="OK"
                                              else
                                                 echo "$p314"
                                                 exit
                                              fi;;
   esac
   if [ "$source" != "OK" ] ;then
      DEVICE=`cat ~/.tuxriprc | grep ^"2\." | awk '{print $2}'`
   fi
   decalinit=`cat ~/.tuxriprc | grep ^"3\." | awk '{print $2}'`
   if [ "$preset" != "OK" ]; then
      LAVCOPT=`cat ~/.tuxriprc | grep ^"4\." | awk '{print $2}'`
   fi
   XVIDOPT=`cat ~/.tuxriprc | grep ^"5\." | awk '{print $2}'`
   gainmax=`cat ~/.tuxriprc | grep ^"6\." | awk '{print $2}'`
   VO=`cat ~/.tuxriprc | grep ^"7\." | awk '{print $2}'`
   AO=`cat ~/.tuxriprc | grep ^"8\." | awk '{print $2}'`
   graveur=`cat ~/.tuxriprc | grep ^"9\." | awk '{print $2}'`
   vitesse=`cat ~/.tuxriprc | grep ^"10\." | awk '{print $2}'`
   visu=`cat ~/.tuxriprc | grep ^"11\." | awk '{print $2}'`
   quantgen=`cat ~/.tuxriprc | grep ^"12\." | awk '{print $2}'`
   MNTDVD=`cat ~/.tuxriprc | grep ^"13\." | awk '{print $2}'`
   seuil=`cat ~/.tuxriprc | grep ^"14\." | awk '{print $2}'`
   contain=`cat ~/.tuxriprc | grep ^"15\." | awk '{print $2}'`
   sws=`cat ~/.tuxriprc | grep ^"16\." | awk '{print $2}'`
   if [ "$contain" = "ogm" ]; then
      extvideo="ogm"
      LISTE_APPLIS="ogmmerge ogmsplit"
      sortie="notok"
      for i in $LISTE_APPLIS;
      do
        which $i > /dev/null 2>&1
        if [ "$?" = "1" ]; then
           [ "$sortie" = "notok" ] && echo -e "${MAINCOLOR}$p282"
           echo -e "${HEADCOLOR} ${i}${MAINCOLOR}"
           sortie="ok"
        fi;
      done
      if [ "$sortie" = "ok" ]; then
         echo
         exit -1
      fi
      merge=`which ogmmerge`
   elif [ "$contain" = "matroska" ]; then
      extvideo="mkv"
      LISTE_APPLIS="mkvmerge"
      sortie="notok"
      for i in $LISTE_APPLIS;
      do
        which $i > /dev/null 2>&1
        if [ "$?" = "1" ]; then
           [ "$sortie" = "notok" ] && echo -e "${MAINCOLOR}$p282"
           echo -e "${HEADCOLOR} ${i}${MAINCOLOR}"
           sortie="ok"
        fi;
      done
      if [ "$sortie" = "ok" ]; then
         echo
         exit -1
      fi
      merge=`which mkvmerge`
   fi
else
   echo "$p101 $p86"
   exit
fi
# CREATION DU PROJET-------------------------------
verif=n
#----------------verif DVD present-
if [ "$resume" != "OK" ]; then
   dvdok="notok"
   while [ "$dvdok" = "notok" ]; do
      testdvd=`tcprobe -i $DEVICE 2>/dev/null`
      [ "$debug" = "OK" ] && tcprobe -i $DEVICE
      if [ "$testdvd" = "" ]; then
         echo -e "${SUBCOLOR}$p131 $DEVICE $p132${MAINCOLOR}"
         read
      else
         dvdok="ok"
      fi
   done
fi
# OK DVD present---
while [ "$verif" = "n" ]
do
   [ "$resume" != "OK" ] && projetdef=$( dd if=$DEVICE ibs=1 skip=32808 count=32 2>/dev/null | sed "s/\ //g" ) || projetdef="DVD"
   [ "$projetdef" = "" ] && projetdef="DVD"
   echo -n -e "${SUBCOLOR}-------> $p102 $projetdef ] ?"
   echo -n -e "${INPUTCOLOR}> "
   read projet
   if [ "$projet" = "" ] ; then
      projet=$projetdef
      echo "$p103 : $projet"
   fi
   echo -e "${MAINCOLOR}"
   if [ -d $RACINE/$projet ] ; then
       if [ "$resume" = "OK" ]; then
          if [ -e "$RACINE/$projet/vob/${projet}-1.vob" ];then
              echo -e "${TABLECOLOR}$p318${MAINCOLOR}"
              echo
              fat32="OK"
          fi
          if [ -e $RACINE/$projet/sub/nom ] && [ "$sub" != "OK" ]; then
             echo -e "${MAINCOLOR}$p344"
             isformat=""
             while [ "$isformat" = "" ]; do
                echo -n -e  "${SUBCOLOR}------->$p345"
                echo -n -e "${INPUTCOLOR}> "
                read stok
                [ "$stok" = "N" ] && stok=n
                [ "$stok" = "$p3" ] && stok=$p4
                if [ "$stok" = "" ]; then
                    stok=$p4
                    echo -n "$p25 : "
                fi
                 if [ "$lng" = "fr" ]; then
                     isformat=`echo $stok | grep "^[oOnN]$"`
                 elif [ "$lng" = "en" ]; then
                     isformat=`echo $stok | grep "^[yYnN]$"`
                 elif [ "$lng" = "sp" ]; then
                     isformat=`echo $stok | grep "^[sSnN]$"`
                 fi
                 if [ "$isformat" = "" ]; then
                     echo "$p124"
                 fi
             done
             if [ "$stok" = "$p4" ]; then
                sub="OK"
                echo -e "$p346${MAINCOLOR}"
                echo
             else
                echo -e "$p347${MAINCOLOR}"
                echo
             fi
          fi
          onestou=`awk 'END {print NR}' $RACINE/$projet/tmp/log`
          echo "$p104"
          case $onestou in
             1) echo -e "${SUBCOLOR}-->1)$p105"
                 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}$p106"$title
                 echo -e "${HEADCOLOR}$p107"$angle
                 echo -e "${HEADCOLOR}$p108"$index
                 echo -e "${HEADCOLOR}$p109"$pisteaudio
                 echo -e "${HEADCOLOR}AR : "$aspect
                 echo -e "${HEADCOLOR}ResXdvd : "$resXdvd
                 echo -e "${HEADCOLOR}ResYdvd : "$resYdvd
                 echo -e "${HEADCOLOR}Framerate : "$fps
                 echo -e "${HEADCOLOR}$p110"$credits ;;

             2) echo -e "${SUBCOLOR}-->1)$p105"
                 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}$p106"$title
                 echo -e "${HEADCOLOR}$p107"$angle
                 echo -e "${HEADCOLOR}$p108"$index
                 echo -e "${HEADCOLOR}$p109"$pisteaudio
                 echo -e "${HEADCOLOR}AR : "$aspect
                 echo -e "${HEADCOLOR}ResXdvd : "$resXdvd
                 echo -e "${HEADCOLOR}ResYdvd : "$resYdvd
                 echo -e "${HEADCOLOR}Framerate : "$fps
                 echo -e "${HEADCOLOR}$p110"$credits
                 echo -e "${SUBCOLOR}-->2)$p111" ;;

             3) echo -e "${SUBCOLOR}-->1)$p105"
                 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}$p106"$title
                 echo -e "${HEADCOLOR}$p107"$angle
                 echo -e "${HEADCOLOR}$p108"$index
                 echo -e "${HEADCOLOR}$p109"$pisteaudio
                 echo -e "${HEADCOLOR}AR : "$aspect
                 echo -e "${HEADCOLOR}ResXdvd : "$resXdvd
                 echo -e "${HEADCOLOR}ResYdvd : "$resYdvd
                 echo -e "${HEADCOLOR}Framerate : "$fps
                 echo -e "${HEADCOLOR}$p110"$credits
                 echo -e "${SUBCOLOR}-->2)$p111"
                 echo -e "${SUBCOLOR}-->3)$p112"
                 qualite=`cat $RACINE/$projet/tmp/log | grep audio | awk '{print $4}'`
                 echo -e "${HEADCOLOR}$p113"$qualite ;;

             4) echo -e "${SUBCOLOR}-->1)$p105"
                 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}$p106"$title
                 echo -e "${HEADCOLOR}$p107"$angle
                 echo -e "${HEADCOLOR}$p108"$index
                 echo -e "${HEADCOLOR}$p109"$pisteaudio
                 echo -e "${HEADCOLOR}AR : "$aspect
                 echo -e "${HEADCOLOR}ResXdvd : "$resXdvd
                 echo -e "${HEADCOLOR}ResYdvd : "$resYdvd
                 echo -e "${HEADCOLOR}Framerate : "$fps
                 echo -e "${HEADCOLOR}$p110"$credits
                 echo -e "${SUBCOLOR}-->2)$p111"
                 echo -e "${SUBCOLOR}-->3)$p112"
                 qualite=`cat $RACINE/$projet/tmp/log | grep audio | awk '{print $4}'`
                 echo -e "${HEADCOLOR}$p113"$qualite
                 echo -e "${SUBCOLOR}-->4)$p114"
                 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)$p105"
                 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}$p106"$title
                 echo -e "${HEADCOLOR}$p107"$angle
                 echo -e "${HEADCOLOR}$p108"$index
                 echo -e "${HEADCOLOR}$p109"$pisteaudio
                 echo -e "${HEADCOLOR}AR : "$aspect
                 echo -e "${HEADCOLOR}ResXdvd : "$resXdvd
                 echo -e "${HEADCOLOR}ResYdvd : "$resYdvd
                 echo -e "${HEADCOLOR}Framerate : "$fps
                 echo -e "${HEADCOLOR}$p110"$credits
                 echo -e "${SUBCOLOR}-->2)$p111"
                 echo -e "${SUBCOLOR}-->3)$p112"
                 qualite=`cat $RACINE/$projet/tmp/log | grep audio | awk '{print $4}'`
                 echo -e "${HEADCOLOR}$p113"$qualite
                 echo -e "${SUBCOLOR}-->4)$p114"
                 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)$p115"
                 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}$p116"$tailleCD"$p117"
                 echo -e "${HEADCOLOR}$p118"$bitvideo" kbps"
                 echo -e "${HEADCOLOR}$p119"$scale ;;

             6) echo -e "${SUBCOLOR}-->1)$p105"
                 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}$p106"$title
                 echo -e "${HEADCOLOR}$p107"$angle
                 echo -e "${HEADCOLOR}$p108"$index
                 echo -e "${HEADCOLOR}$p109"$pisteaudio
                 echo -e "${HEADCOLOR}AR : "$aspect
                 echo -e "${HEADCOLOR}ResXdvd : "$resXdvd
                 echo -e "${HEADCOLOR}ResYdvd : "$resYdvd
                 echo -e "${HEADCOLOR}Framerate : "$fps
                 echo -e "${HEADCOLOR}$p110"$credits
                 echo -e "${SUBCOLOR}-->2)$p111"
                 echo -e "${SUBCOLOR}-->3)$p112"
                 qualite=`cat $RACINE/$projet/tmp/log | grep audio | awk '{print $4}'`
                 echo -e "${HEADCOLOR}$p113"$qualite
                 echo -e "${SUBCOLOR}-->4)$p114"
                 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)$p115"
                 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}$p116"$tailleCD"$p117"
                 echo -e "${HEADCOLOR}$p118"$bitvideo" kbps"
                 echo -e "${HEADCOLOR}$p119"$scale
                 echo -e "${SUBCOLOR}-->6)$p120";;

             7) echo -e "${SUBCOLOR}-->1)$p105"
                 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}$p106"$title
                 echo -e "${HEADCOLOR}$p107"$angle
                 echo -e "${HEADCOLOR}$p108"$index
                 echo -e "${HEADCOLOR}$p109"$pisteaudio
                 echo -e "${HEADCOLOR}AR : "$aspect
                 echo -e "${HEADCOLOR}ResXdvd : "$resXdvd
                 echo -e "${HEADCOLOR}ResYdvd : "$resYdvd
                 echo -e "${HEADCOLOR}Framerate : "$fps
                 echo -e "${HEADCOLOR}$p110"$credits
                 echo -e "${SUBCOLOR}-->2)$p111"
                 echo -e "${SUBCOLOR}-->3)$p112"
                 qualite=`cat $RACINE/$projet/tmp/log | grep audio | awk '{print $4}'`
                 echo -e "${HEADCOLOR}$p113"$qualite
                 echo -e "${SUBCOLOR}-->4)$p114"
                 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)$p115"
                 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}$p116"$tailleCD"$p117"
                 echo -e "${HEADCOLOR}$p118"$bitvideo" kbps"
                 echo -e "${HEADCOLOR}$p119"$scale
                 echo -e "${SUBCOLOR}-->6)$p120"
                 echo -e "${SUBCOLOR}-->7)$p121"
                 decalinit=`cat $RACINE/$projet/tmp/log | grep mixage | awk '{print $4}'`
                 echo -e "${HEADCOLOR}$p1220"$decalinit "ms"
                 [ "$grave" = "OK" ] && echo -e "${SUBCOLOR}-->8)$p230"
                  ;;
          esac
#         if [ "$sub" = "OK" ];then
#            if [ -e $RACINE/$projet/sub/log ]; then
#               nbsub=`cat $RACINE/$projet/sub/log | grep ^"1\." | awk '{print $2}'`
#                 i=1
#                 while [ $i -le $nbsub ]; do
#                    indexsub[$i]=`cat $RACINE/$projet/sub/log | grep ^"$(($i+1))\." | awk '{print $2}'`
#                  pistesub[$i]=`cat $RACINE/$projet/sub/log | grep ^"$(($i+$nbsub+1))\." | awk '{print $2}'`
#                  i=$(($i+1))
#                 done
#               ifo="VTS_0${title}_0.IFO"
#            fi
#         fi
          verif=o
          if [ "$multiaudio" = "" ]; then
             if [ "$index" = "multi" ] && [ "$pisteaudio" = "multi" ]; then
                nbaudio=`cat $RACINE/$projet/tmp/multiaudio | grep ^"1\." | awk '{print $2}'`
                i=1
                while [ $i -le $nbaudio ]; do
                   index[$i]=`cat $RACINE/$projet/tmp/multiaudio | grep ^"$(($i+1))\." | awk '{print $2}'`
                   pisteaudio[$i]=`cat $RACINE/$projet/tmp/multiaudio | grep ^"$(($i+$nbaudio+1))\." | awk '{print $2}'`
                   i=$(($i+1))
                done
                echo
                isformat=""
                while [ "$isformat" = "" ]; do
                   echo -n -e  "${SUBCOLOR}------->$p307"
                   echo -n -e "${INPUTCOLOR}> "
                   read verife
                   [ "$verife" = "N" ] && verife=n
                   [ "$verife" = "$p3" ] && verife=$p4
                   if [ "$verife" = "" ]; then
                      verife=$p4
                      echo -n "$p25 : "
                   fi
                   if [ "$lng" = "fr" ]; then
                     isformat=`echo $verife | grep "^[oOnN]$"`
                   elif [ "$lng" = "en" ]; then
                     isformat=`echo $verife | grep "^[yYnN]$"`
                   elif [ "$lng" = "sp" ]; then
                     isformat=`echo $verife | grep "^[sSnN]$"`
                   fi
                   if [ "$isformat" = "" ]; then
                      echo "$p124"
                   fi
                   echo -n -e "${MAINCOLOR}"
                done
                if [ "$verife" = "$p4" ]; then
                   multiaudio="OK"
                   echo "$p308"
                else
                   i=1
                   echo
                   while [ $i -le $nbaudio ]; do
                      echo "$p305$i : ${index[$i]} (${pisteaudio[$i]})"
                      i=$(($i+1))
                   done
                   isnume=""
                   while [ "$isnume" = "" ]; do
                      echo -n -e  "${SUBCOLOR}------->$p309"
                      echo -n -e "${INPUTCOLOR}> "
                      read piste
                      [ "$piste" = "" ] && piste=1
                      isnume=`echo $piste | grep "^[1-9][0-9]*$"`
                      if [ "$isnume" != "" ];then
                          if [ $piste -gt $nbaudio ];then
                             isnume=""
                             echo "$p310"
                          fi
                      else
                          echo "$p124"
                      fi
                      echo -n -e "${MAINCOLOR}"
                   done
                   index=${index[$piste]}
                   pisteaudio=${pisteaudio[$piste]}
                   [ -e $RACINE/$projet/audio/son$piste.ogg ] && cp -f $RACINE/$projet/audio/son$piste.ogg $RACINE/$projet/audio/son.ogg
                   [ -e $RACINE/$projet/tmp/infos$piste.son ] && cp -f $RACINE/$projet/tmp/infos$piste.son $RACINE/$projet/tmp/infos.son
                fi
             fi
          else
             if [ "$index" = "multi" ] && [ "$pisteaudio" = "multi" ]; then
                nbaudio=`cat $RACINE/$projet/tmp/multiaudio | grep ^"1\." | awk '{print $2}'`
                i=1
                while [ $i -le $nbaudio ]; do
                   index[$i]=`cat $RACINE/$projet/tmp/multiaudio | grep ^"$(($i+1))\." | awk '{print $2}'`
                   pisteaudio[$i]=`cat $RACINE/$projet/tmp/multiaudio | grep ^"$(($i+$nbaudio+1))\." | awk '{print $2}'`
                   i=$(($i+1))
                done
             else
                echo "$p311"
                exit
             fi
          fi
      else
         isformat=""
         while [ "$isformat" = "" ]; do
            echo -n -e  "${SUBCOLOR}------->$p122"
            echo -n -e "${INPUTCOLOR}> "
            read verif
            [ "$verif" = "N" ] && verif=n
            [ "$verif" = "$p3" ] && verif=$p4
            if [ "$verif" = "" ]; then
               verif=n
               echo "$p337"
            fi
            if [ "$lng" = "fr" ]; then
                  isformat=`echo $verif | grep "^[oOnN]$"`
            elif [ "$lng" = "en" ]; then
                  isformat=`echo $verif | grep "^[yYnN]$"`
            elif [ "$lng" = "sp" ]; then
                  isformat=`echo $verif | grep "^[sSnN]$"`
            fi
            if [ "$isformat" = "" ]; then
               echo "$p124"
            fi
            echo -n -e "${MAINCOLOR}"
            [ "$verif" = "$p4" ] && rm -rf $RACINE/$projet || echo
         done
      fi
   else
      if [ "$resume" = "OK" ]; then
         echo "$p125"
         exit
      else
         verif=o
      fi
   fi
done

if [ "$resume" = "OK" ]; then
   limite=`expr $onestou \+ 1`
   [ $limite -eq 8 ] && limite=7
   if [ $limite -eq 7 ] && [ "$grave" = "OK" ]; then
      limite=8
   fi
   etapedeb=10
   while [ $etapedeb -gt $limite ]
   do
      echo
      echo -n -e  "${SUBCOLOR}------->$p126 $limite] ? "
      echo -n -e "${INPUTCOLOR}> "
      read etapedeb
      if [ "$etapedeb" = "" ] ; then
         echo "$p127 $limite..."
         etapedeb=$limite
      fi
      isnum=`echo $etapedeb | grep "^[1-9][0-9]*$"`
      if [ "$isnum" = "" ] ; then
         echo "$p128 $limite..."
         etapedeb=10
      else
         [ $etapedeb -gt $limite ] && echo "$p129"
      fi
   done
#   echo $etapedeb
   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 ;;
            8 ) awk 'NR == 1 , NR == 7 {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}$p130"
   echo -e "${MAINCOLOR}"

   dvdok="notok"
   while [ "$dvdok" = "notok" ]; do
      tcprobe -i $DEVICE 2>/dev/null > $RACINE/$projet/tmp/infos.dvd.test
      [ "$debug" = "OK" ] && tcprobe -i $DEVICE 
      testdvd=`ls -l $RACINE/$projet/tmp/infos.dvd.test | awk '{print $5}'`
      if [ $testdvd -eq 0 ]; then
         echo
         echo -e "${SUBCOLOR}$p131 $DEVICE $p132${MAINCOLOR}"
         rm -f $RACINE/$projet/tmp/infos.dvd.test
         read
      else
         dvdok="ok"
      fi
   done
   echo -e "${HEADCOLOR}$p133${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}--->$p134 $titre${MAINCOLOR}"
      echo -n -e  "${MAINCOLOR}$p135${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 <<EOF
           scale=0
           ( ( $H * 3600 ) + ( $M * 60 ) + $S ) / 1
EOF
`
      if [ $timesec -gt $timemax ]; then
         timemax=$timesec
         titredef=$titre
      fi
      echo -e "${MAINCOLOR}$p136${SUBCOLOR}$time ($timesec $p137)"
      echo -n -e "${MAINCOLOR}Aspect ratio : ${SUBCOLOR}" ; cat $RACINE/$projet/tmp/infos.dvd.$titre | grep "aspect ratio" | awk '{print $3}'
      titre=$(($titre + 1))
   done
   echo -e "${MAINCOLOR}"
   isnum=""
   until [ "$isnum" != "" ]
   do
      echo -n -e "${SUBCOLOR}-------> $p138 $titredef] ? "
      echo -n -e "${INPUTCOLOR}> "
      read title
      if [ "$title" = "" ]; then
         echo "$p139 $titredef..."
         title=$titredef
      fi
      isnum=`echo $title | grep "^[1-9][0-9]*$"`
      if [ "$isnum" != "" ]; then
         if [ $title -gt $titremax ]; then
            echo "$p140 $titremax $p141"
            isnum=""
         fi
      else
         echo "$p142"
      fi
   done
   echo -n -e "${MAINCOLOR}"

   mplayer $dvdsyntaxe$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}$p143 ${SUBCOLOR}$anglemax${HEADCOLOR}$p144"
      until [ "$isnum" != "" ]; do
         echo -n -e "${SUBCOLOR}------->$p145"
         echo -n -e "${INPUTCOLOR}> "
         read angle
         if [ "$angle" = "" ]; then
            echo "$p146"
            angle=1
         fi
         isnum=`echo $angle | grep "^[1-9][0-9]*$"`
         if [ "$isnum" != "" ]; then
            if [ $angle -gt $anglemax ]; then
               echo "$p147 $anglemax $p148"
               isnum=""
            fi
         else
            echo "$p149"
         fi
      done
      echo -n -e "${MAINCOLOR}"
      echo
   else
      echo "$p150 "$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
      if [ "$multiaudio" != "OK" ];then
         isnum=""
         until [ "$isnum" != "" ]; do
            echo -n -e "${SUBCOLOR}------->$p151"
            echo -n -e "${INPUTCOLOR}> "
            read index
            if [ "$index" = "" ]; then
               echo "$p152"
               index=0
            fi
            isnum=`echo $index | grep "^[0-9][0-9]*$"`
            if [ "$isnum" != "" ]; then
               if [ $index -gt $audiomax ]; then
                  echo "$p153"
                  isnum=""
               fi
            else
               echo "$p154"
            fi
         done
         echo -n -e "${MAINCOLOR}"
      else
         isnum=""
         nbaudiomax=$(($audiomax+1))
         until [ "$isnum" != "" ]; do
            echo -n -e "${SUBCOLOR}------->$p299"
            echo -n -e "${INPUTCOLOR}> "
            read nbaudio
            if [ "$nbaudio" = "" ]; then
               echo "$p300"
               nbaudio=2
            fi
            isnum=`echo $nbaudio | grep "^[0-9][0-9]*$"`
            if [ "$isnum" != "" ]; then
               if [ $nbaudio -gt $nbaudiomax ]; then
                  echo "$p301$nbaudiomax$p302"
                  isnum=""
               fi
               if [ $nbaudio -le 1 ]; then
                  echo "$p304"
                  isnum=""
               fi
            else
               echo "$p303"
            fi
         done
         i=1
         while [ $i -le $nbaudio ]; do
            isnum=""
            until [ "$isnum" != "" ]; do
               echo -n -e "${SUBCOLOR}------->$p305${HEADCOLOR}$i${SUBCOLOR}$p306"
               echo -n -e "${INPUTCOLOR}> "
               read index[$i]
               isnum=`echo ${index[$i]} | grep "^[0-9][0-9]*$"`
               if [ "$isnum" != "" ]; then
                  if [ ${index[$i]} -gt $audiomax ]; then
                     echo "$p153"
                     isnum=""
                  fi
               else
                  echo "$p154"
               fi
            done
            echo -n -e "${MAINCOLOR}"
            i=$(($i+1))
         done
      fi
   else
      index=$audiomax
      echo -e "${MAINCOLOR}$p155 "$index"..."
   fi
   if [ "$multiaudio" != "OK" ];then
      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="$p156"
      fi
      aid=`expr $index \+ 128`
      echo -n -e "${HEADCOLOR}$p157"$pisteaudio
      echo -e "${MAINCOLOR}"
   else
     i=1
     while [ $i -le $nbaudio ]; do
         pisteaudio[$i]=`cat $RACINE/$projet/tmp/infos.dvd | grep "audio format" | grep "audio stream: ${index[$i]}" | awk -F "language: " '{print $2}' | awk '{print $1}'`
         if [ "${pisteaudio[$i]}" = "" ]; then
            pisteaudio[$i]="$p156"
         fi
         aid[$i]=`expr ${index[$i]} \+ 128`
         echo -n -e "${HEADCOLOR}$p157"${pisteaudio[$i]}
         echo -e "${MAINCOLOR}"
         i=$(($i+1))
      done
   fi

#aspect ratio et controle de la cohrence des valeurs trouves par transcode et mplayer
   aspect=`cat $RACINE/$projet/tmp/infos.dvd | grep "^VIDEO" | awk '{print $5}' | awk -F ")" '{print $1}'`
   aspecttr=`cat $RACINE/$projet/tmp/infos.dvd.$title | grep "aspect ratio" | awk '{print $3}'`
   case $aspecttr in
      "16:9"  ) aspecttr=3 ;;
      "4:3"   ) aspecttr=2;;
      "1:1"   ) aspecttr=1;;
      "2.21:1") aspecttr=4;;
   esac
   case $aspect in
      "1") a1="1:1";;
      "2") a1="4:3";;
      "3") a1="16:9";;
      "4") a1="2.21:1";;
   esac
   case $aspecttr in
      "1") a2="1:1";;
      "2") a2="4:3";;
      "3") a2="16:9";;
      "4") a2="2.21:1";;
   esac
   if [ "$aspect" != "$aspecttr" ]; then
      echo "$p369$a1 $p370$a2 !!!"
      continue="ok"
      while [ "$continue" = "ok" ]; do
         echo "1) $a1"
         echo "2) $a2"
         echo "$p371"
         read repo
         continue="notok"
         case $repo in
           "" ) aspect=$aspecttr 
                echo "$p373 ${a2}...";;
           "2") aspect=$aspecttr 
                echo "$p373 ${a2}...";;
           "1") aspect=$aspect   
                echo "$p373 ${a1}...";;   
            * ) echo "$p372"
                continue=ok;;
         esac
      done
   fi      
#      
   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`
   [ "$fps" = "29.970" ] && fps="29.97"
   rm -f $RACINE/$projet/tmp/framerate

   echo
   echo -e "${MAINCOLOR} >>>> $p158 <<<<"
   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 "$p159 $full $p160($nbchap) $p161"
   #       full=$nbchap
    #  else
     #    nbchap=$full
    #  fi
  # fi
   if [ "$modetest" = "OK" ] ; then
      if [ $full -gt $nbchap ]; then
          echo "$p159 $full $p160($nbchap) $p161"
          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
   if [ "$multiaudio" != "OK" ]; then
      if [ "$debug" = "OK" ]; then
         mplayer -loop 0 -osdlevel 2 $dvdsyntaxe$title -aid $aid -dvd-device $DEVICE -chapter $chapgen -vo $VO -ao $AO
      else
         mplayer -loop 0 -osdlevel 2 $dvdsyntaxe$title -aid $aid -dvd-device $DEVICE -chapter $chapgen -vo $VO -ao $AO > /dev/null 2>&1
      fi
   else
      if [ "$debug" = "OK" ]; then
         mplayer -loop 0 -osdlevel 2 $dvdsyntaxe$title -aid ${aid[1]} -dvd-device $DEVICE -chapter $chapgen -vo $VO -ao $AO
      else
         mplayer -loop 0 -osdlevel 2 $dvdsyntaxe$title -aid ${aid[1]} -dvd-device $DEVICE -chapter $chapgen -vo $VO -ao $AO > /dev/null 2>&1
      fi
   fi
   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}------->$p162 $nogen] ? "
      echo -n -e "${INPUTCOLOR}> "
      read generique
      if [ "$generique" = "" ] ; then
         echo "$p163 $nogen, $p164"
         generique=$nogen
      fi
      isformat=`echo $generique | egrep "^0?[0-4]:[0-5]?[0-9]:[0-5]?[0-9]$"`
      if [ "$isformat" = "" ] ; then
         echo "$p165"
      else
         genH=`echo $generique | cut -d: -f 1`
         genM=`echo $generique | cut -d: -f 2`
         genS=`echo $generique | cut -d: -f 3`
         credits=`bc <<EOF
           scale=0
           ( ( $genH * 3600 ) + ( $genM * 60 ) + $genS ) * $fps / 1
EOF
`
      fi
   done
   dvdxchap -t $title $DEVICE 2>/dev/null > $RACINE/$projet/tmp/$projet-chapitrage
   echo
   if [ "$multiaudio" != "OK" ];then
      echo "scan dvd (titre,angle,index,langue,AR,ResX,ResY,fps,credits) -->  $title $angle $index $pisteaudio $aspect $resXdvd $resYdvd $fps $credits" >> $RACINE/$projet/tmp/log
   else
      echo "scan dvd (titre,angle,index,langue,AR,ResX,ResY,fps,credits) -->  $title $angle multi multi $aspect $resXdvd $resYdvd $fps $credits" >> $RACINE/$projet/tmp/log
      touch $RACINE/$projet/tmp/multiaudio
      echo "1. $nbaudio" >> $RACINE/$projet/tmp/multiaudio
      i=1
      while [ $i -le $nbaudio ]; do
         echo "$(($i+1)). ${index[$i]}" >> $RACINE/$projet/tmp/multiaudio
         i=$(($i+1))
      done
      i=1
      while [ $i -le $nbaudio ]; do
         echo "$(($i+$nbaudio+1)). ${pisteaudio[$i]}" >> $RACINE/$projet/tmp/multiaudio
         i=$(($i+1))
      done
   fi
fi

# Ripping

if [ $etapedeb -le 2 ]; then
   echo -e "${TABLECOLOR}$p166"
   echo -e "${MAINCOLOR}"
   free=`df -P -T -m $RACINE | grep /dev | awk '{print $5}'`
   if [ $free -le 8000 ]; then
     echo "$free$p254 $RACINE$p255"
     isformat=""
     until [ "$isformat" != "" ]; do
        echo -n -e "${SUBCOLOR}------->$p295"
        echo -n -e "${INPUTCOLOR}> "
        read verif
        [ "$verif" = "N" ] && verif=n
        [ "$verif" = "$p3" ] && verif=$p4
        if [ "$verif" = "" ]; then
           verif=n
        fi
        if [ "$lng" = "fr" ]; then
           isformat=`echo $verif | grep "^[oOnN]$"`
        elif [ "$lng" = "en" ]; then
           isformat=`echo $verif | grep "^[yYnN]$"`
        elif [ "$lng" = "sp" ]; then
           isformat=`echo $verif | grep "^[sSnN]$"`
        fi
        if [ "$isformat" = "" ]; then
           echo "$p124"
        fi
        echo -n -e "${MAINCOLOR}"
        if [ "$verif" = "$p4" ]; then
           echo > /dev/null
        elif [ "$verif" = "n" ]; then
           exit
        fi
     done
   fi
   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" ;;
      dts ) typeaudio="dts" ;;
      * ) typeaudio="ac3" ;;
   esac
   dvdok="notok"
   while [ "$dvdok" = "notok" ]; do
      tcprobe -i $DEVICE 2>/dev/null > $RACINE/$projet/tmp/infos.dvd.test
      [ "$debug" = "OK" ] && tcprobe -i $DEVICE
      testdvd=`ls -l $RACINE/$projet/tmp/infos.dvd.test | awk '{print $5}'`
      if [ $testdvd -eq 0 ]; then
         echo
         echo -e "${SUBCOLOR}$p131 $DEVICE $p132${MAINCOLOR}"
         read
      else
         dvdok="ok"
      fi
   done
   if [ "$fat32" = "OK" ]; then
      if [ "$modetest" = "OK" ]; then
         echo -e "${HEADCOLOR}$p167${SUBCOLOR}${title}${HEADCOLOR} ($p168${SUBCOLOR}${full}${HEADCOLOR}) $p169 ${SUBCOLOR}$RACINE/$projet/vob/${projet}-*.vob${HEADCOLOR}...${MAINCOLOR}"
      else
         echo -e "${HEADCOLOR}$p167${SUBCOLOR}${title}${HEADCOLOR} $p169 ${SUBCOLOR}$RACINE/$projet/vob/${projet}-*.vob${HEADCOLOR}...${MAINCOLOR}"
      fi
   else
      if [ "$modetest" = "OK" ]; then
         echo -e "${HEADCOLOR}$p167${SUBCOLOR}${title}${HEADCOLOR} ($p168${SUBCOLOR}${full}${HEADCOLOR}) $p169 ${SUBCOLOR}$RACINE/$projet/vob/$projet.vob${HEADCOLOR}...${MAINCOLOR}"
      else
         echo -e "${HEADCOLOR}$p167${SUBCOLOR}${title}${HEADCOLOR} $p169 ${SUBCOLOR}$RACINE/$projet/vob/$projet.vob${HEADCOLOR}...${MAINCOLOR}"
      fi
   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
   t1=`date +'%s'`
   if [ "$fat32" = "OK" ]; then
      cd $RACINE/$projet/vob
      tccat -t dvd -T $title,$full,$angle -i $DEVICE 2>/dev/null | split -b 1024m - $projet
      [ -e $RACINE/$projet/vob/${projet}aa ] && mv -f $RACINE/$projet/vob/${projet}aa $RACINE/$projet/vob/${projet}-1.vob
      [ -e $RACINE/$projet/vob/${projet}ab ] && mv -f $RACINE/$projet/vob/${projet}ab $RACINE/$projet/vob/${projet}-2.vob
      [ -e $RACINE/$projet/vob/${projet}ac ] && mv -f $RACINE/$projet/vob/${projet}ac $RACINE/$projet/vob/${projet}-3.vob
      [ -e $RACINE/$projet/vob/${projet}ad ] && mv -f $RACINE/$projet/vob/${projet}ad $RACINE/$projet/vob/${projet}-4.vob
      [ -e $RACINE/$projet/vob/${projet}ae ] && mv -f $RACINE/$projet/vob/${projet}ae $RACINE/$projet/vob/${projet}-5.vob
      [ -e $RACINE/$projet/vob/${projet}af ] && mv -f $RACINE/$projet/vob/${projet}af $RACINE/$projet/vob/${projet}-6.vob
      [ -e $RACINE/$projet/vob/${projet}ag ] && mv -f $RACINE/$projet/vob/${projet}ag $RACINE/$projet/vob/${projet}-7.vob
      [ -e $RACINE/$projet/vob/${projet}ah ] && mv -f $RACINE/$projet/vob/${projet}ah $RACINE/$projet/vob/${projet}-8.vob
      [ -e $RACINE/$projet/vob/${projet}ai ] && mv -f $RACINE/$projet/vob/${projet}ai $RACINE/$projet/vob/${projet}-9.vob
   else
      if [ "$debug" = "OK" ]; then
         tccat -t dvd -T $title,$full,$angle -i $DEVICE > $RACINE/$projet/vob/$projet.vob
      else
         tccat -t dvd -T $title,$full,$angle -i $DEVICE 2>/dev/null > $RACINE/$projet/vob/$projet.vob
      fi
   fi
   if [ "$multiaudio" != "OK" ];then
          tccat -i $RACINE/$projet/vob/ | tcextract -a $index -x $typeaudio -t vob | tcdecode -x $typeaudio | tcscan -x pcm -b 80 > $RACINE/$projet/tmp/infos.son
   else
      i=1
      while [ $i -le $nbaudio ]; do
         tccat -i $RACINE/$projet/vob/ | tcextract -a ${index[$i]} -x $typeaudio -t vob | tcdecode -x $typeaudio | tcscan -x pcm -b 80 > $RACINE/$projet/tmp/infos$i.son
#        tccat -i $RACINE/$projet/vob/$projet.vob | tcextract -a ${index[$i]} -x $typeaudio -t vob | tcdecode -x $typeaudio | tcscan -x pcm -b 80 > $RACINE/$projet/tmp/infos$i.son
         i=$(($i+1))
      done
      cp -f $RACINE/$projet/tmp/infos1.son $RACINE/$projet/tmp/infos.son
   fi

   duree=`cat $RACINE/$projet/tmp/infos.son | grep "length" | awk -F "=" '{print $3}' | awk '{print $1}'`
   t2=`date +'%s'`
   nbhrs=`bc <<EOF
          scale=0
          ($t2 - $t1) / 3600
EOF`
   nbmin=`bc <<EOF
          scale=0
          ($t2 - $t1) / 60 - $nbhrs * 60
EOF`
   nbsec=`bc <<EOF
          scale=0
          ($t2 - $t1) - $nbmin * 60 - $nbhrs * 3600
EOF`
   vitrip=`bc <<EOF
          scale=2
          $duree / ($t2 - $t1) * $fps
EOF`
   echo "$p258 : ${nbhrs}hrs ${nbmin}min ${nbsec}sec" | tee $RACINE/$projet/tmp/riptime
   echo "$p259 : $vitrip fps" | tee $RACINE/$projet/tmp/ripspeed
   echo
   echo "ripping dvd" >> $RACINE/$projet/tmp/log
   if [ "$sub" != "OK" ]; then
      if [ "$source" != "OK" ]; then
         echo "$p374"
         echo
      fi
   fi
fi

# SOUS-TITRES
   if [ "$sub" = "OK" ]; then
      echo -e "${TABLECOLOR}$p336${MAINCOLOR}"
      [ ! -d $RACINE/$projet/sub ] && mkdir $RACINE/$projet/sub
      cd $RACINE/$projet/sub
      if [ -e $RACINE/$projet/sub/nom ]; then
         echo
         echo "$p334 :"
         cat $RACINE/$projet/sub/nom
         isformat=""
         while [ "$isformat" = "" ]; do
            echo -n -e  "${SUBCOLOR}------->$p335"
            echo -n -e "${INPUTCOLOR}> "
            read verif
            [ "$verif" = "N" ] && verif=n
            [ "$verif" = "$p3" ] && verif=$p4
            if [ "$verif" = "" ]; then
               verif=n
               echo "$p123"
#              echo "$p343"
            fi
            if [ "$lng" = "fr" ]; then
                  isformat=`echo $verif | grep "^[oOnN]$"`
            elif [ "$lng" = "en" ]; then
                  isformat=`echo $verif | grep "^[yYnN]$"`
            elif [ "$lng" = "sp" ]; then
                  isformat=`echo $verif | grep "^[sSnN]$"`
            fi
            if [ "$isformat" = "" ]; then
               echo "$p124"
            fi
            echo -n -e "${MAINCOLOR}"
            if [ "$verif" = "$p4" ]; then
               rm -f $RACINE/$projet/sub/* 2>/dev/null
               ecrase="OK"
            fi
            if [ "$verif" = "n" ]; then
               ecrase="notok"
               echo "$p343"
               echo
            fi
         done
      else
         ecrase="OK"
      fi
      if [ "$ecrase" = "OK" ]; then
         echo -e "${HEADCOLOR}"
         cat $RACINE/$projet/tmp/infos.dvd | grep "subtitle (" | awk '{print " " $6 " sub " $7 " " $8}'
         nbsubmax=`cat $RACINE/$projet/tmp/infos.dvd | grep "number of subtitles" | awk -F ":" '{print $2}'`
         if [ $nbsubmax -gt 0 ]; then
            isnum=""
            until [ "$isnum" != "" ]; do
               echo -n -e "${SUBCOLOR}------->$p325"
               echo -n -e "${INPUTCOLOR}> "
               read nbsub
               if [ "$nbsub" = "" ]; then
                  echo "$p326"
                  nbsub=1
               fi
               isnum=`echo $nbsub | grep "^[0-9][0-9]*$"`
               if [ "$isnum" != "" ]; then
                  if [ $nbsub -gt $nbsubmax ]; then
                     echo "$p301$nbsubmax$p327"
                     isnum=""
                  fi
               else
                  echo "$p303"
               fi
            done
            i=1
            while [ $i -le $nbsub ]; do
               isnum=""
               until [ "$isnum" != "" ]; do
                  echo -n -e "${SUBCOLOR}------->$p328${HEADCOLOR}$i${SUBCOLOR}$p306"
                  echo -n -e "${INPUTCOLOR}> "
                  read indexsub[$i]
                  isnum=`echo ${indexsub[$i]} | grep "^[0-9][0-9]*$"`
                  if [ "$isnum" != "" ]; then
                     if [ ${indexsub[$i]} -gt $nbsubmax ]; then
                        echo "$p329"
                        isnum=""
                     fi
                  else
                     echo "$p330"
                  fi
               done
               echo -n -e "${MAINCOLOR}"
               i=$(($i+1))
            done
            i=1
            while [ $i -le $nbsub ]; do
               pistesub[$i]=`cat $RACINE/$projet/tmp/infos.dvd  | grep "subtitle (" | grep ": ${indexsub[$i]} " | awk '{print $8}'`
               if [ "${pistesub[$i]}" = "" ]; then
                  pistesub[$i]="$p156"
               fi
               subaid[$i]=`expr ${indexsub[$i]} \+ 128`
               echo -n -e "${HEADCOLOR}$p332"${pistesub[$i]}
               echo -e "${MAINCOLOR}"
               i=$(($i+1))
            done
            [ -e $RACINE/$projet/sub/ ] && rm -f $RACINE/$projet/sub/* 2>/dev/null
            touch $RACINE/$projet/sub/log
            echo "1. $nbsub" >> $RACINE/$projet/sub/log
            i=1
            while [ $i -le $nbsub ]; do
               echo "$(($i+1)). ${indexsub[$i]}" >> $RACINE/$projet/sub/log
               i=$(($i+1))
            done
            i=1
            while [ $i -le $nbsub ]; do
               echo "$(($i+$nbsub+1)). ${pistesub[$i]}" >> $RACINE/$projet/sub/log
               i=$(($i+1))
            done
            
            dvdok="notok"
            while [ "$dvdok" = "notok" ]; do
               tcprobe -i $DEVICE 2>/dev/null > $RACINE/$projet/tmp/infos.dvd.test
               [ "$debug" = "OK" ] && tcprobe -i $DEVICE
               testdvd=`ls -l $RACINE/$projet/tmp/infos.dvd.test | awk '{print $5}'`
               if [ $testdvd -eq 0 ]; then
                  echo
                  echo -e "${SUBCOLOR}$p131 $DEVICE $p132${MAINCOLOR}"
                  read
               else
                  dvdok="ok"
               fi
            done
            echo -e "$p333${MAINCOLOR}"
            i=1
            echo "subs.sub" > $RACINE/$projet/sub/nom
            t1=`date +'%s'`
            while [ $i -le $nbsub ]; do
               k=$(($i-1))
               echo "Position : $k , IndexVob : ${indexsub[$i]} , Langue : ${pistesub[$i]}"
               if [ "$debug" = "OK" ]; then
                  mencoder -dvd-device $DEVICE $dvdsyntaxe$title -o /dev/null -nosound -ovc copy -vobsubout subs -vobsuboutindex $k -sid ${indexsub[$i]}
               else
                  mencoder -dvd-device $DEVICE $dvdsyntaxe$title -o /dev/null -nosound -ovc copy -vobsubout subs -vobsuboutindex $k -sid ${indexsub[$i]} > /dev/null 2>&1
               fi
               i=$(($i+1))
            done
            t2=`date +'%s'`
            duree=`cat $RACINE/$projet/tmp/infos.son | grep "length" | awk -F "=" '{print $3}' | awk '{print $1}'`
            nbhrs=`bc <<EOF
                scale=0
                ($t2 - $t1) / 3600
EOF`
            nbmin=`bc <<EOF
                scale=0
                ($t2 - $t1) / 60 - $nbhrs * 60
EOF`
            nbsec=`bc <<EOF
                scale=0
                ($t2 - $t1) - $nbmin * 60 - $nbhrs * 3600
EOF`
            vitsub=`bc <<EOF
                scale=2
                $duree / ($t2 - $t1) * $fps
EOF`
            i=1
            nomsub=""
            while [ $i -le $nbsub ]; do
               a="${pistesub[$i]}"
               if [ "$nomsub" = "" ]; then
                 nomsub="$a"
               else
                 nomsub="${nomsub}_${a}"
               fi
               i=$(($i+1))
            done
            mv -f $RACINE/$projet/sub/subs.sub $RACINE/$projet/sub/$projet-subs-${nomsub}.sub 2>/dev/null
            mv -f $RACINE/$projet/sub/subs.idx $RACINE/$projet/sub/$projet-subs-${nomsub}.idx 2>/dev/null
            echo "$projet-subs-${nomsub}.sub" > $RACINE/$projet/sub/nom

#compression des sub dans le cas container ogm. pas utile dans matroska car mix dans le mkv (et compress !)
            if [ "$contain" = "ogm" ]; then
               isformat=""
               while [ "$isformat" = "" ]; do
                  echo -n -e  "${SUBCOLOR}------->$p339"
                  echo -n -e "${INPUTCOLOR}> "
                  read verif
                  [ "$verif" = "N" ] && verif=n
                  [ "$verif" = "$p3" ] && verif=$p4
                  if [ "$verif" = "" ]; then
                     verif=n
                     echo "$p340"
                  fi
                  if [ "$lng" = "fr" ]; then
                     isformat=`echo $verif | grep "^[oOnN]$"`
                  elif [ "$lng" = "en" ]; then
                     isformat=`echo $verif | grep "^[yYnN]$"`
                  elif [ "$lng" = "sp" ]; then
                     isformat=`echo $verif | grep "^[sSnN]$"`
                  fi
                  if [ "$isformat" = "" ]; then
                     echo "$p124"
                  fi
                  echo -n -e "${MAINCOLOR}"
                  if [ "$verif" = "$p4" ]; then
                     cd $RACINE/$projet/sub/
                     if [ "$debug" = "OK" ]; then
                        tar cvfj $projet-subs-${nomsub}.tar.bz2 $projet-subs-${nomsub}.sub $projet-subs-${nomsub}.idx
                     else
                        tar cvfj $projet-subs-${nomsub}.tar.bz2 $projet-subs-${nomsub}.sub $projet-subs-${nomsub}.idx 2>/dev/null
                     fi
                     rm -f $projet-subs-${nomsub}.sub 2>/dev/null
                     rm -f $projet-subs-${nomsub}.idx 2>/dev/null
                     echo "$projet-subs-${nomsub}.tar.bz2" > nom
                  fi
               done
            fi
#fin compression            
            echo "$p341 : ${nbhrs}hrs ${nbmin}min ${nbsec}sec" | tee $RACINE/$projet/tmp/subtime
            echo "$p342 : $vitsub fps" | tee $RACINE/$projet/tmp/subspeed
            echo
            if [ "$source" != "OK" ]; then
               echo "$p374"
            fi
            echo
         else # pas de sstitres
            indexsub=$nbsubmax
            nbsub=$nbsubmax
            echo -e "${MAINCOLOR}$p331..."
            if [ "$source" != "OK" ]; then
               echo "$p374"
            fi
            echo    
         fi
      fi
   fi


# ENCODAGE AUDIO----------------------------
if [ $etapedeb -le 3 ]; then
   echo -e "${TABLECOLOR}$p170${MAINCOLOR}"
   if [ "$multiaudio" != "OK" ];then
      rescale=`cat $RACINE/$projet/tmp/infos.son | grep "volume" | awk -F "=" '{print $3}'`
      test=`bc <<EOF
   $rescale > $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  "$p171"$rescale

      isnum=""
      while [ "$isnum" = "" ]
      do
         echo -e "${MAINCOLOR}"
         echo -n -e "${SUBCOLOR}------->$p172"
         echo -n -e "${INPUTCOLOR}> "
         read qualite
         if [ "$qualite" = "" ] ; then
               qualite=1.0
               echo "$p173"
         fi
         isnum=`echo $qualite | egrep "^[0-9]+[\.]?[0-9]*$"`
         if [ "$isnum" = "" ] ; then
               echo "$p174"
         fi
      done

      echo -e "${HEADCOLOR}$p240${MAINCOLOR}"
      t1=`date +'%s'`
      if [ "$debug" = "OK" ]; then
         nice -19 transcode -q 1 -i $RACINE/$projet/vob -a $index -u 50 -s $rescale,1,1,1 --a52_drc_off -x null,vob -y null,ogg -m $RACINE/$projet/audio/son.ogg -o /dev/null -b 0,0,$qualite
      else
         nice -19 transcode -q 1 -i $RACINE/$projet/vob -a $index -u 50 -s $rescale,1,1,1 --a52_drc_off -x null,vob -y null,ogg -m $RACINE/$projet/audio/son.ogg -o /dev/null -b 0,0,$qualite 2>/dev/null     
      fi
      echo
   else
      t1=`date +'%s'`
      i=1
      while [ $i -le $nbaudio ]; do
         echo -e "${SUBCOLOR}-->$p305$i :${MAINCOLOR}"
         rescale=`cat $RACINE/$projet/tmp/infos$i.son | grep "volume" | awk -F "=" '{print $3}'`
         test=`bc <<EOF
         $rescale > $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  "$p171"$rescale

         isnum=""
         while [ "$isnum" = "" ]
         do
            echo -e "${MAINCOLOR}"
            echo -n -e "${SUBCOLOR}------->$p172"
            echo -n -e "${INPUTCOLOR}> "
            read qualite
            if [ "$qualite" = "" ] ; then
                  qualite=1.0
                  echo "$p173"
            fi
            isnum=`echo $qualite | egrep "^[0-9]+[\.]?[0-9]*$"`
            if [ "$isnum" = "" ] ; then
               echo "$p174"
            fi
         done

         echo -e "${HEADCOLOR}$p240${MAINCOLOR}"
         if [ "$debug" = "OK" ]; then
            nice -19 transcode -q 1 -i $RACINE/$projet/vob -a ${index[$i]} -u 50 -s $rescale,1,1,1 --a52_drc_off -x null,vob -y null,ogg -m $RACINE/$projet/audio/son$i.ogg -o /dev/null -b 0,0,$qualite
         else
            nice -19 transcode -q 1 -i $RACINE/$projet/vob -a ${index[$i]} -u 50 -s $rescale,1,1,1 --a52_drc_off -x null,vob -y null,ogg -m $RACINE/$projet/audio/son$i.ogg -o /dev/null -b 0,0,$qualite 2>/dev/null
         fi           
         echo
         i=$(($i+1))
      done
   fi

#   > /dev/null 2>&1
   duree=`cat $RACINE/$projet/tmp/infos.son | grep "length" | awk -F "=" '{print $3}' | awk '{print $1}'`
   t2=`date +'%s'`
   nbhrs=`bc <<EOF
          scale=0
          ($t2 - $t1) / 3600
EOF`
   nbmin=`bc <<EOF
          scale=0
          ($t2 - $t1) / 60 - $nbhrs * 60
EOF`
   nbsec=`bc <<EOF
          scale=0
          ($t2 - $t1) - $nbmin * 60 - $nbhrs * 3600
EOF`
   vitencaudio=`bc <<EOF
          scale=2
          $duree / ($t2 - $t1) * $fps
EOF`
   echo "$p257 : ${nbhrs}hrs ${nbmin}min ${nbsec}sec" | tee $RACINE/$projet/tmp/audiotime
   echo "$p260 : $vitencaudio fps" | tee $RACINE/$projet/tmp/audiospeed
   if [ "$multiaudio" != "OK" ];then
      echo "encodage audio --> $qualite" >> $RACINE/$projet/tmp/log
   else
      echo "encodage audio --> multi" >> $RACINE/$projet/tmp/log
   fi
   echo
fi

# cropping

if [ $etapedeb -le 4 ]; then
   echo -e "${TABLECOLOR}$p175${MAINCOLOR}"
   cd $RACINE/$projet/tmp
   if [ "$fat32" = "OK" ];then
      taille1=`ls -l $RACINE/$projet/vob/${projet}-1.vob | awk '{print $5}'`
   else
      taille1=`ls -l $RACINE/$projet/vob/$projet.vob | awk '{print $5}'`
   fi
   deb=`bc <<EOF
      scale=0
      $taille1 * 0.20 / 1
EOF`
   pas=`bc <<EOF
   scale=0
   $deb * 0.50 / 1
EOF`
# on dmarre la recherche  20% du vob et ensuite on augmente de 10%  chaque essai...
   verif=n
   while [ "$verif" = "n" ]
   do
      [ -f "$RACINE/$projet/tmp/infos.crop" ] && rm -f $RACINE/$projet/tmp/infos.crop
      [ -f "$RACINE/$projet/tmp/00000001.png" ] && rm -f $RACINE/$projet/tmp/00000001.png
      [ -f "$RACINE/$projet/tmp/00000002.png" ] && rm -f $RACINE/$projet/tmp/00000002.png
      [ -f "$RACINE/$projet/tmp/00000003.png" ] && rm -f $RACINE/$projet/tmp/00000003.png
      [ -f "$RACINE/$projet/tmp/00000004.png" ] && rm -f $RACINE/$projet/tmp/00000004.png
      [ -f "$RACINE/$projet/tmp/00000005.png" ] && rm -f $RACINE/$projet/tmp/00000005.png
      if [ "$fat32" = "OK" ];then
         mplayer -ao null -vo null -sb $deb -frames 20 -vop cropdetect=$seuil $RACINE/$projet/vob/${projet}-1.vob > $RACINE/$projet/tmp/infos.crop 2>&1
      else
         mplayer -ao null -vo null -sb $deb -frames 20 -vop cropdetect=$seuil $RACINE/$projet/vob/$projet.vob > $RACINE/$projet/tmp/infos.crop 2>&1
      fi
      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 "$p176" $crop
      echo -e "$p177"${top}"$p181"
      echo -e "$p178"${bot}"$p181"
      echo -e "$p179"${droite}"$p181"
      echo -e "$p180"${gauche}"$p181"
      echo
      echo -e "${MAINCOLOR}"
      echo ">>>> $p182 <<<<"
      echo
      if [ "$fat32" = "OK" ];then
         if [ "$debug" = "OK" ]; then
            mplayer -ao null -vo png -z 0 -sb $deb -frames 5 -vop rectangle=$crop $RACINE/$projet/vob/${projet}-1.vob
         else
            mplayer -ao null -vo png -z 0 -sb $deb -frames 5 -vop rectangle=$crop $RACINE/$projet/vob/${projet}-1.vob  > /dev/null 2>&1
         fi
      else
         if [ "$debug" = "OK" ]; then
            mplayer -ao null -vo png -z 0 -sb $deb -frames 5 -vop rectangle=$crop $RACINE/$projet/vob/$projet.vob
         else
            mplayer -ao null -vo png -z 0 -sb $deb -frames 5 -vop rectangle=$crop $RACINE/$projet/vob/$projet.vob  > /dev/null 2>&1
         fi
      fi
#      [ -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 & )
            if [ -f "$RACINE/$projet/tmp/00000005.png" ]; then
               mv -f $RACINE/$projet/tmp/00000005.png $RACINE/$projet/tmp/cropping.png
               rm -f $RACINE/$projet/tmp/000*.png
               if [ "$debug" = "OK" ]; then
                  $visu $RACINE/$projet/tmp/cropping.png &
               else
                  $visu $RACINE/$projet/tmp/cropping.png > /dev/null 2>&1 &
               fi
            elif [ -f "$RACINE/$projet/tmp/00000004.png" ]; then
               mv -f $RACINE/$projet/tmp/00000004.png $RACINE/$projet/tmp/croppping.png
               rm -f $RACINE/$projet/tmp/000*.png
               if [ "$debug" = "OK" ]; then
                  $visu $RACINE/$projet/tmp/cropping.png &
               else
                  $visu $RACINE/$projet/tmp/cropping.png > /dev/null 2>&1 &
               fi
            elif [ -f "$RACINE/$projet/tmp/00000003.png" ]; then
               mv -f $RACINE/$projet/tmp/00000003.png $RACINE/$projet/tmp/cropping.png
               rm -f $RACINE/$projet/tmp/000*.png
               if [ "$debug" = "OK" ]; then
                  $visu $RACINE/$projet/tmp/cropping.png &
               else
                  $visu $RACINE/$projet/tmp/cropping.png > /dev/null 2>&1 &
               fi
            elif [ -f "$RACINE/$projet/tmp/00000002.png" ]; then
               mv -f $RACINE/$projet/tmp/00000002.png $RACINE/$projet/tmp/cropping.png
               rm -f $RACINE/$projet/tmp/000*.png
               if [ "$debug" = "OK" ]; then
                  $visu $RACINE/$projet/tmp/cropping.png &
               else
                  $visu $RACINE/$projet/tmp/cropping.png > /dev/null 2>&1 &
               fi
            elif [ -f "$RACINE/$projet/tmp/00000001.png" ]; then
               mv -f $RACINE/$projet/tmp/00000001.png $RACINE/$projet/tmp/cropping.png
               rm -f $RACINE/$projet/tmp/000*.png
               if [ "$debug" = "OK" ]; then
                  $visu $RACINE/$projet/tmp/cropping.png &
               else
                  $visu $RACINE/$projet/tmp/cropping.png > /dev/null 2>&1 &
               fi
            fi
      isformat=""
      while [ "$isformat" = "" ] ; do
         echo -n -e "${SUBCOLOR}------->$p183"
         echo -n -e "${INPUTCOLOR}> "
         read verif
         [ "$verif" = "N" ] && verif=n
         [ "$verif" = "$p3" ] && verif=$p4
         if [ "$verif" = "" ]; then
            verif=n
            echo "$p184"
         fi
         if [ "$lng" = "fr" ]; then
             isformat=`echo $verif | grep "^[oOnN]$"`
         elif [ "$lng" = "en" ]; then
             isformat=`echo $verif | grep "^[yYnN]$"`
         elif [ "$lng" = "sp" ]; then
             isformat=`echo $verif | grep "^[sSnN]$"`
         fi
         if [ "$isformat" = "" ]; then
            echo "$p124"
         fi
      done
      echo -n -e "${MAINCOLOR}"
      deb=`bc <<EOF
        $deb + $pas
EOF`
   done
   echo
   echo "cropping --> $crop $haut $larg"  >> $RACINE/$projet/tmp/log
fi

# resolution, bitrate...

if [ $etapedeb -le 5 ]; then
   cd $RACINE/$projet
   echo -e "${TABLECOLOR}$p185"
   echo -e "${HEADCOLOR}"

   ARi=`bc <<EOF
      scale=6
      $resXdvd / $resYdvd
EOF`
#Display aspect ratio codes:
#1 - 1:1 pixels
#2 - 4:3 display
#3 - 16:9 display
#4 - 2.21:1 display
   case $aspect in
      4) echo "$p186 : 2.21:1"
         ARa=2.210000 ;;
      3) echo "$p186 : 16/9"
         ARa=1.777777 ;;
      2) echo "$p186 : 4/3"
         ARa=1.333333 ;;
      1) echo "$p186 : 1:1"
         ARa=1.000000 ;;
   esac
   ratio=`bc <<EOF
      scale=6
      $larg * ($ARa / $ARi) / $haut
EOF`
   echo  "$p187: " $ratio

# calcul bitrate, rsolution et bouclage jusqu' satisfaction

   duree=`cat $RACINE/$projet/tmp/infos.son | grep "length" | awk -F "=" '{print $3}' | awk '{print $1}'`
   echo "$p188: " $duree "sec"

   satisf=n
   while [ "$satisf" = "n" ]
   do
      [ -d "$RACINE/$projet/video/cd1" ] && rm -rf $RACINE/$projet/video/cd*
      isnum=""
      while [ "$isnum" = "" ]
      do
         echo -e "${SUBCOLOR}-------> 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) $p189"
         echo -n -e "${INPUTCOLOR}$p190"
         read cd
         if [ "$cd" = "" ]; then
             cd=2
             echo "$p191"
         fi
         isnum=`echo $cd | grep "^[1-5]$"`
         if [ "$isnum" = "" ]; then
            echo "$p192"
         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}------->$p193"
                 echo -n -e "${INPUTCOLOR}> "
                 autres=ok
                 read tailleCD
                 isnum=`echo $tailleCD | grep "^[1-9][0-9]*$"`
                 if [ "$isnum" = "" ] ; then
                    echo "$p194"
                 fi
              done ;;
      esac
      echo -n -e "${MAINCOLOR}"

#interleave (+ marge) de 1 %
      tailledispo=`bc <<EOF
      scale=0
      $tailleCD * 0.99
EOF`
      if [ "$multiaudio" != "OK" ];then
         tailleson=`bc <<EOF
         scale=6
         $(ls -l $RACINE/$projet/audio/son.ogg | awk '{print $5}') / 1024 / 1024
EOF`
      else
         i=1
         tailleson=0
         while [ $i -le $nbaudio ]; do
            vase=$(ls -l $RACINE/$projet/audio/son$i.ogg | awk '{print $5}')
            tailleson=$(($tailleson+$vase))
            i=$(($i+1))
         done
         tailleson=`bc <<EOF
         scale=6
         $tailleson / 1024 / 1024
EOF`
      fi
      echo "$p195" $tailleson "$p117"

      taillevideo=`bc <<EOF
      scale=6
      $tailledispo - $tailleson
EOF`
      if [ "$sub" = "OK" ]; then
         nomfichsub=$(cat $RACINE/$projet/sub/nom)
         taillesub=$(ls -l $RACINE/$projet/sub/$nomfichsub | awk '{print $5}')
         taillesub=`bc <<EOF
         scale=6
         $taillesub / 1024 / 1024
EOF`
         echo "$p338" $taillesub "$p117"
         taillevideo=`bc <<EOF
         scale=6
         $taillevideo - $taillesub
EOF`
      fi
      echo "$p196" $taillevideo "$p117"

      bitvideo=`bc <<EOF
      scale=6
      $taillevideo * 1024 * 1024 / $duree * 8 / 1000
EOF`
      bitvideo=`bc <<EOF
      scale=0
      $bitvideo / 1
EOF`
      echo -e "${HEADCOLOR}$p197${SUBCOLOR}$bitvideo${HEADCOLOR} kbps"
      echo -e "${MAINCOLOR}"
      isnum0=""
      while [ "$isnum0" = "" ];
      do
         echo -n -e "${SUBCOLOR}------->$p198"
         echo -n -e "${INPUTCOLOR}> "
         read CQ
         if [ "$CQ" = "" ] ; then
            CQ=0.22
            echo "$p199"
         fi
         isnum0=`echo $CQ | egrep "^[0-9]+\.?[0-9]*$"`
         if [ "$isnum0" = "" ]; then
            echo "$p200"
         fi
      done
      echo -n -e "${MAINCOLOR}"

      ResY=`bc <<EOF
      scale=6
      sqrt( 1000 * $bitvideo / $fps / $ratio / $CQ)
EOF`

      ResY=`bc <<EOF
      scale=6
      ( $ResY / 16 ) + 0.5
EOF`

      ResY=`bc <<EOF
      scale=0
      $ResY / 1 * 16
EOF`

      ResX=`bc <<EOF
      scale=6
      $ResY * $ratio
EOF`

      ResX=`bc <<EOF
      scale=6
      ( $ResX / 16 ) + 0.5
EOF`

      ResX=`bc <<EOF
      scale=0
      $ResX / 1 * 16
EOF`


     if [ $ResX -gt $larg ]; then # jamais, tu ne "resizeras" en UP !!!
         ResX=`bc <<EOF
         scale=0
         $larg / 16 * 16
EOF`
         [ $ResX -gt $larg ] && ResX=$(($ResX-16))
         ResY=`bc <<EOF
           scale=6
           $ResX / $ratio
EOF`
         ResY=`bc <<EOF
           scale=6
           ( $ResY / 16 ) + 0.5
EOF`
         ResY=`bc <<EOF
           scale=0
           $ResY / 1 * 16
EOF`
      fi

      scale=`echo "${ResX}:${ResY}"`
      echo -e "${HEADCOLOR}$p201 ${SUBCOLOR}$scale"
      echo -e "${MAINCOLOR}"

      Ratioenc=`bc <<EOF
      scale=3
      $ResX / $ResY
EOF`
      deform=`bc <<EOF
      scale=3
      ( $Ratioenc - $ratio ) / $Ratioenc * 100
EOF`
      echo "$p202 " $Ratioenc" ($p203 ${deform}%)"

      CQreel=`bc <<EOF
      scale=3
      $bitvideo * 1000 / $ResX / $ResY / $fps
EOF`

      echo "$p204" $CQreel
      if [ "$testcomp" = "" ]; then
         choixres=0
         preview
      else
# compressibility check
     if [ "$fat32" = "OK" ];then
        echo
        echo "$p316."
        echo "$p317$p91."
        exit
     else
         echo
         scalinit=$scale
         echo -e "${TABLECOLOR}$p205"
         echo -e "${MAINCOLOR}"
         taille1=`ls -l $RACINE/$projet/vob/$projet.vob | awk '{print $5}'`
         isnum=""
         while [ "$isnum" = "" ]; do
            echo -e -n "${SUBCOLOR}------->$p206"
            echo -e -n "${INPUTCOLOR}> "
            read pcfilm
            if [ "$pcfilm" = "" ]; then
               pcfilm=5
               echo "$p207"
            fi
            isnum=`echo $pcfilm | grep "^[1-9][0-9]*$"`
            if [ "$isnum" = "" ]; then
               echo "$p208"
            else
               if [ $pcfilm -gt 20 ]; then
                  echo "$p209"
                  isnum=""
               fi
            fi
         done
         echo -n -e "${MAINCOLOR}"
         sec=`bc <<EOF
                scale=6
                ( $pcfilm / 100 ) * $duree / 100
EOF`
         sec=`bc <<EOF
                scale=0
                $sec / 1
EOF`
         [ $sec -eq 0 ] && sec=1
         pas=`bc <<EOF
                scale=0
                $taille1 / 105
EOF`
         i=1
         echo -e "${HEADCOLOR}$p210${MAINCOLOR}"
         while [ $i -le 100 ]; do
            debut=`bc <<EOF
                      ($i + 2) * $pas
EOF`
            echo -n -e "\r$p211 : $i%"
            if [ "$debug" = "OK" ]; then
               nice -19 mencoder $RACINE/$projet/vob/$projet.vob -ovc lavc -lavcopts vcodec=mpeg4:vmax_b_frames=0:vhq:keyint=250:vme=4:v4mv:vqscale=2 -vf crop=$crop,scale=$scale -sws $sws -nosound -sb $debut -endpos $sec -o $RACINE/$projet/tmp/cctemp${i}.avi
            else
               nice -19 mencoder $RACINE/$projet/vob/$projet.vob -ovc lavc -lavcopts vcodec=mpeg4:vmax_b_frames=0:vhq:keyint=250:vme=4:v4mv:vqscale=2 -vf crop=$crop,scale=$scale -sws $sws -nosound -sb $debut -endpos $sec -o $RACINE/$projet/tmp/cctemp${i}.avi >/dev/null 2>&1
            fi           
            i=$(($i + 1))
        done
        echo
        echo -e "${HEADCOLOR}$p212${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 <<EOF
                     $(cat $RACINE/$projet/tmp/infocc$projet.merge | tail -n 1 | awk -F"=" '{print $3}' | awk -F "," '{print $1}') / $fps
EOF`
        rm -f $RACINE/$projet/tmp/cctemp*.avi
        taillecc=`ls -l $RACINE/$projet/tmp/ccheck$projet.avi | awk '{print $5}'`
        bitratecc=`bc <<EOF
                    scale=6
                    $taillecc / $dureecc * 8 / 1000
EOF`
        CC=`bc <<EOF
              scale=3
              $bitratecc * 1000 / ( ${ResX} * ${ResY} * $fps )
EOF`
        pc=`bc <<EOF
              scale=6
              $CQreel / $CC * 100
EOF`2
        echo $dureecc $bitvideo $bitratecc $CQreel $CC $pc > $RACINE/$projet/tmp/infocc$projet
        echo
        echo -e "${MAINCOLOR}$p231=${SUBCOLOR}0$CC${MAINCOLOR}"
        echo
        ResX=`bc <<EOF
            scale=6
            ( $larg / 16 ) + 0.5
EOF`
        ResX=`bc <<EOF
             scale=0
             $ResX / 1 * 16
EOF`
        [ $ResX -gt $larg ] && ResX=$(($ResX-16))
        ResY=`bc <<EOF
              scale=6
              $ResX / $ratio
EOF`
        ResY=`bc <<EOF
              scale=6
             ( $ResY / 16 ) + 0.5
EOF`
        ResY=`bc <<EOF
             scale=0
             $ResY / 1 * 16
EOF`
       ResXmax=$ResX
       ResYmax=$ResY
        i=1
        resdefaut=""
        [ -f $RACINE/$projet/tmp/res ] && rm -f $RACINE/$projet/tmp/res
        touch $RACINE/$projet/tmp/res
        while [ $i -lt 16 ] ;do
           scale0="${ResX}:${ResY}"
           [ "$scale0" = "$scalinit" ] && resdefaut=$i
           Ratioenc=`bc <<EOF
                scale=6
                $ResX / $ResY
EOF`
           deform=`bc <<EOF
                scale=6
                ( $Ratioenc - $ratio ) / $Ratioenc * 100
EOF`
            CQ=`bc <<EOF
                 scale=6
                 $bitvideo * 1000 / ( ${ResX} * ${ResY} * $fps )
EOF`
             pc=`bc <<EOF
                 scale=6
                 $CQ / $CC * 100
EOF`
             echo "$i  $ResX:$ResY $deform $CQ $pc" >> $RACINE/$projet/tmp/res
             ResY=`bc <<EOF
                   scale=0
                   $ResY - 16
EOF`
             ResX=`bc <<EOF
                   scale=6
                   $ResY * $ratio
EOF`
             ResX=`bc <<EOF
                   scale=6
                  ( $ResX / 16 ) + 0.5
EOF`
             ResX=`bc <<EOF
                  scale=0
                  $ResX / 1 * 16
EOF`
              i=$(($i+1))
        done
        if [ "$lng" = "fr" ]; then
          awk '{printf "| %2d)   | %8s   | %7.1f     | %6.3f | %5.1f  |\n", $1 , $2 , $3 , $4 , $5 }' $RACINE/$projet/tmp/res > $RACINE/$projet/tmp/res.format
          printf "%1s %5s %1s %10s %1s %10s %1s %2s %1s %3s %1s \n" \| Choix \| Rsolution \|  Dformation \| CQvis \| %Comp. \|
        elif [ "$lng" = "en" ]; then
          awk '{printf "| %2d)    | %8s   | %7.1f     | %6.3f   | %5.1f  |\n", $1 , $2 , $3 , $4 , $5 }' $RACINE/$projet/tmp/res > $RACINE/$projet/tmp/res.format
          printf "%1s %6s %1s %10s %1s %10s %1s %4s %1s %3s %1s \n" \| Choice \| Resolution \|  Deformation \| QFtarget \| %Comp. \|
        elif [ "$lng" = "sp" ]; then
          awk '{printf "| %2d)    | %8s   | %7.1f     | %6.3f   | %5.1f  |\n", $1 , $2 , $3 , $4 , $5 }' $RACINE/$projet/tmp/res > $RACINE/$projet/tmp/res.format
          printf "%1s %6s %1s %10s %1s %10s %1s %4s %1s %3s %1s \n" \| Choice \| Resolution \|  Deformation \| QFtarget \| %Comp. \|
        fi
        cat $RACINE/$projet/tmp/res.format
        echo "  16)  $p213"
        isnum=""
        while [ "$isnum" = "" ]
        do
           if [ "$resdefaut"  != "" ]; then
              echo -n -e "${INPUTCOLOR}$p214 $resdefaut] ? > "
           else
              echo -n -e "${INPUTCOLOR}$p215"
           fi
           read choixres
           if [ "$resdefaut"  != "" ]; then
              if [ "$choixres" = "" ]; then
                 choixres=$resdefaut
                 echo "$p216 $resdefaut"
              fi
           fi
           isnum=`echo $choixres | grep "^[1-9][0-9]*$"`
           [ "$isnum" != "" ] && [ $isnum -gt 16 ] && isnum=""
           if [ "$isnum" = "" ]; then
             echo "$p217"
           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 16 ] && satisf="n"
        [ $choixres -lt 16 ] && satisf="o"
        [ $choixres -lt 16 ] && echo "$p229$scale"
        preview
   fi
# fin compressibility check
      fi
   done
   echo "taille vise, rsolution, bitrate --> $tailleCD $scale $bitvideo" >> $RACINE/$projet/tmp/log
fi

#encodage video
if [ $etapedeb -le 6 ]; then
   echo -e "${TABLECOLOR}$p218${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

   a=`echo $LAVCOPT | grep psnr`
   [ "$a" = "" ] && LAVCOPT="$LAVCOPT:psnr"
   if [ "$xvid4" != "OK" ]; then
      if [ "$xvid" = "OK" ]; then
         echo "$p296$XVIDOPT"
      else
         echo "$p296$LAVCOPT"
      fi
   fi
   CIBLE=$RACINE/$projet/video/${projet}sans-son.avi
   if [ "$fat32" = "OK" ];then
      SOURCE=$RACINE/$projet/vob
   else
      SOURCE=$RACINE/$projet/vob/$projet.vob
   fi
   fin=`bc <<EOF
         scale=0
         $(cat $RACINE/$projet/tmp/infos.son | grep "length" | awk -F "=" '{print $3}' | awk '{print $1}') * $fps / 1
EOF`
   ResX=`echo $scale | cut -d: -f 1`
   ResY=`echo $scale | cut -d: -f 2`
   echo
   [ "$xvid4" != "OK" ] && echo -e "${HEADCOLOR}$p219"
   echo -e "${MAINCOLOR}"
   [ "$xvid4" != "OK" ] && sleep 2
   t1=`date +'%s'`
if [ "$xvid4" = "OK" ]; then
      echo "$p366"
      read
      if [ "$lb" = "OK" ]; then
          xvid4conf $RACINE/$projet/tmp/xvid4.cfg && $transperl --projet $projet --desentrelace
      else
          xvid4conf $RACINE/$projet/tmp/xvid4.cfg && $transperl --projet $projet
      fi
else
if [ "$fat32" = "OK" ];then
   if [ "$silence" = "OK" ]; then
      if [ "$xvid" = "OK" ]; then
         if [ "$fps" = "29.97" ]; then
            echo "$p220"
            echo -e "${SUBCOLOR}$p223${MAINCOLOR}"
            cat $SOURCE/*.vob | nice -15 mencoder -mc 0 -nosound -o /dev/null -ovc xvid -xvidencopts $XVIDOPT:bitrate=$bitvideo:pass=1 -vf crop=$crop,scale=$scale -ofps 23.976 -sws $sws - 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 | grep "Video stream" | awk '{print $3}' | sed -e "s/,/./"`
            CQmax=`bc <<EOF
                             scale=2
                             $bitmax * 1000 / ( ${ResX} * ${ResY} * $fps )
EOF`
            echo
            echo -e "${HEADCOLOR}$p221 $p231=${SUBCOLOR}0$CQmax${MAINCOLOR}" | tee $RACINE/$projet/tmp/mitemps
            echo
            echo -e "${SUBCOLOR}$p222${MAINCOLOR}"
            sleep 2
            cat $SOURCE/*.vob | nice -15 mencoder -mc 0 -nosound -o $CIBLE -ovc xvid -xvidencopts $XVIDOPT:bitrate=$bitvideo:pass=2 -vf crop=$crop,scale=$scale -ofps 23.976 -sws $sws - 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}$p223${MAINCOLOR}"
               cat $SOURCE/*.vob | nice -15 mencoder -mc 0 -nosound -o /dev/null -ovc xvid -xvidencopts $XVIDOPT:bitrate=$bitvideo:pass=1 -vf crop=$crop,pp=$deint,scale=$scale -sws $sws - 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 | grep "Video stream" | awk '{print $3}' | sed -e "s/,/./"`
               CQmax=`bc <<EOF
                             scale=2
                             $bitmax * 1000 / ( ${ResX} * ${ResY} * $fps )
EOF`
               echo
               echo -e "${HEADCOLOR}$p221 $p231=${SUBCOLOR}0$CQmax${MAINCOLOR}" | tee $RACINE/$projet/tmp/mitemps
               echo
               echo -e "${SUBCOLOR}$p222${MAINCOLOR}"
               sleep 2
               cat $SOURCE/*.vob | nice -15 mencoder -mc 0 -nosound -o $CIBLE -ovc xvid -xvidencopts $XVIDOPT:bitrate=$bitvideo:pass=2 -vf crop=$crop,pp=$deint,scale=$scale -sws $sws - 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}$p223${MAINCOLOR}"
               cat $SOURCE/*.vob | nice -15 mencoder -mc 0 -nosound -o /dev/null -ovc xvid -xvidencopts $XVIDOPT:bitrate=$bitvideo:pass=1 -vf crop=$crop,scale=$scale -sws $sws - 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 | grep "Video stream" | awk '{print $3}' | sed -e "s/,/./"`
               CQmax=`bc <<EOF
                                scale=2
                                $bitmax * 1000 / ( ${ResX} * ${ResY} * $fps )
EOF`
               echo
               echo -e "${HEADCOLOR}$p221 $p231=${SUBCOLOR}0$CQmax${MAINCOLOR}" | tee $RACINE/$projet/tmp/mitemps
               echo
               echo -e "${SUBCOLOR}$p222${MAINCOLOR}"
               sleep 2
               cat $SOURCE/*.vob | nice -15 mencoder -mc 0 -nosound -o $CIBLE -ovc xvid -xvidencopts $XVIDOPT:bitrate=$bitvideo:pass=2 -vf crop=$crop,scale=$scale -sws $sws - 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 "$p220"
              echo -e "${SUBCOLOR}$p223${MAINCOLOR}"
              cat $SOURCE/*.vob | nice -15 mencoder -mc 0 -nosound -o /dev/null -ovc lavc -lavcopts $LAVCOPT:vrc_override=$credits,$fin,$quantgen:vqscale=2:vpass=1 -vf crop=$crop,scale=$scale -ofps 23.976 -sws $sws - 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 | grep "Video stream" | awk '{print $3}' | sed -e "s/,/./"`
              CQmax=`bc <<EOF
                             scale=2
                             $bitmax * 1000 / ( ${ResX} * ${ResY} * $fps )
EOF`
              echo
              echo -e "${HEADCOLOR}$p221 $p231=${SUBCOLOR}0$CQmax${MAINCOLOR}" | tee $RACINE/$projet/tmp/mitemps
              echo
              echo -e "${SUBCOLOR}$p222${MAINCOLOR}"
              sleep 2
              cat $SOURCE/*.vob | nice -15 mencoder -mc 0 -nosound -o $CIBLE -ovc lavc -lavcopts $LAVCOPT:vrc_override=$credits,$fin,$quantgen:vbitrate=$bitvideo:vpass=2 -vf crop=$crop,scale=$scale -ofps 23.976 -sws $sws - 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}$p223${MAINCOLOR}"
               cat $SOURCE/*.vob | nice -15 mencoder -mc 0 -nosound -o /dev/null -ovc lavc -lavcopts $LAVCOPT:vrc_override=$credits,$fin,$quantgen:vqscale=2:vpass=1 -vf crop=$crop,pp=$deint,scale=$scale -sws $sws - 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 | grep "Video stream" | awk '{print $3}' | sed -e "s/,/./"`
               CQmax=`bc <<EOF
                             scale=2
                             $bitmax * 1000 / ( ${ResX} * ${ResY} * $fps )
EOF`
               echo
               echo -e "${HEADCOLOR}$p221 $p231=${SUBCOLOR}0$CQmax${MAINCOLOR}" | tee $RACINE/$projet/tmp/mitemps
               echo
               echo -e "${SUBCOLOR}$p222${MAINCOLOR}"
               sleep 2
               cat $SOURCE/*.vob | nice -15 mencoder -mc 0 -nosound -o $CIBLE -ovc lavc -lavcopts $LAVCOPT:vrc_override=$credits,$fin,$quantgen:vbitrate=$bitvideo:vpass=2 -vf crop=$crop,pp=$deint,scale=$scale -sws $sws - 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}$p223${MAINCOLOR}"
               cat $SOURCE/*.vob | nice -15 mencoder -mc 0 -nosound -o /dev/null -ovc lavc -lavcopts $LAVCOPT:vrc_override=$credits,$fin,$quantgen:vqscale=2:vpass=1 -vf crop=$crop,scale=$scale -sws $sws - 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 | grep "Video stream" | awk '{print $3}' | sed -e "s/,/./"`
               CQmax=`bc <<EOF
                             scale=2
                             $bitmax * 1000 / ( ${ResX} * ${ResY} * $fps )
EOF`
               echo
               echo -e "${HEADCOLOR}$p221 $p231=${SUBCOLOR}0$CQmax${MAINCOLOR}" | tee $RACINE/$projet/tmp/mitemps
               echo
               echo -e "${SUBCOLOR}$p222${MAINCOLOR}"
               sleep 2
               cat $SOURCE/*.vob | nice -15 mencoder -mc 0 -nosound -o $CIBLE -ovc lavc -lavcopts $LAVCOPT:vrc_override=$credits,$fin,$quantgen:vbitrate=$bitvideo:vpass=2 -vf crop=$crop,scale=$scale -sws $sws - 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
   else
      if [ "$xvid" = "OK" ]; then
      if [ "$fps" = "29.97" ]; then
         echo "$p220"
         echo -e "${SUBCOLOR}$p223${MAINCOLOR}"
         cat $SOURCE/*.vob | nice -15 mencoder -mc 0 -nosound -o /dev/null -ovc xvid -xvidencopts $XVIDOPT:bitrate=$bitvideo:pass=1 -vf crop=$crop,scale=$scale -ofps 23.976 -sws $sws - 2>&1 | tee $RACINE/$projet/tmp/suivi1.log
         bitmax=`cat $RACINE/$projet/tmp/suivi1.log | grep "Video stream" | awk '{print $3}' | sed -e "s/,/./"`
         CQmax=`bc <<EOF
                             scale=2
                             $bitmax * 1000 / ( ${ResX} * ${ResY} * $fps )
EOF`
         echo
         echo -e "${HEADCOLOR}$p221 $p231=${SUBCOLOR}0$CQmax${MAINCOLOR}" | tee $RACINE/$projet/tmp/mitemps
         echo
         echo -e "${SUBCOLOR}$p222${MAINCOLOR}"
         sleep 2
         cat $SOURCE/*.vob | nice -15 mencoder -mc 0 -nosound -o $CIBLE -ovc xvid -xvidencopts $XVIDOPT:bitrate=$bitvideo:pass=2 -vf crop=$crop,scale=$scale -ofps 23.976 -sws $sws - 2>&1 | tee $RACINE/$projet/tmp/suivi2.log
      else
         if [ "$lb" = "OK" ]; then
            echo -e "${SUBCOLOR}$p223${MAINCOLOR}"
            cat $SOURCE/*.vob | nice -15 mencoder -mc 0 -nosound -o /dev/null -ovc xvid -xvidencopts $XVIDOPT:bitrate=$bitvideo:pass=1 -vf crop=$crop,pp=$deint,scale=$scale -sws $sws - 2>&1 | tee $RACINE/$projet/tmp/suivi1.log
            bitmax=`cat $RACINE/$projet/tmp/suivi1.log | grep "Video stream" | awk '{print $3}' | sed -e "s/,/./"`
            CQmax=`bc <<EOF
                             scale=2
                             $bitmax * 1000 / ( ${ResX} * ${ResY} * $fps )
EOF`
            echo
            echo -e "${HEADCOLOR}$p221 $p231=${SUBCOLOR}0$CQmax${MAINCOLOR}" | tee $RACINE/$projet/tmp/mitemps
            echo
            echo -e "${SUBCOLOR}$p222${MAINCOLOR}"
            sleep 2
            cat $SOURCE/*.vob | nice -15 mencoder -mc 0 -nosound -o $CIBLE -ovc xvid -xvidencopts $XVIDOPT:bitrate=$bitvideo:pass=2 -vf crop=$crop,pp=$deint,scale=$scale -sws $sws - 2>&1 | tee $RACINE/$projet/tmp/suivi2.log
         else
            echo -e "${SUBCOLOR}$p223${MAINCOLOR}"
            cat $SOURCE/*.vob | nice -15 mencoder -mc 0 -nosound -o /dev/null -ovc xvid -xvidencopts $XVIDOPT:bitrate=$bitvideo:pass=1 -vf crop=$crop,scale=$scale -sws $sws - 2>&1 | tee $RACINE/$projet/tmp/suivi1.log
            bitmax=`cat $RACINE/$projet/tmp/suivi1.log | grep "Video stream" | awk '{print $3}' | sed -e "s/,/./"`
            CQmax=`bc <<EOF
                             scale=2
                             $bitmax * 1000 / ( ${ResX} * ${ResY} * $fps )
EOF`
            echo
            echo -e "${HEADCOLOR}$p221 $p231=${SUBCOLOR}0$CQmax${MAINCOLOR}" | tee $RACINE/$projet/tmp/mitemps
            echo
            echo -e "${SUBCOLOR}$p222${MAINCOLOR}"
            sleep 2
            cat $SOURCE/*.vob | nice -15 mencoder -mc 0 -nosound -o $CIBLE -ovc xvid -xvidencopts $XVIDOPT:bitrate=$bitvideo:pass=2 -vf crop=$crop,scale=$scale -sws $sws - 2>&1 | tee $RACINE/$projet/tmp/suivi2.log
         fi
      fi
   else
      if [ "$fps" = "29.97" ]; then
         echo "$p220"
         echo -e "${SUBCOLOR}$p223${MAINCOLOR}"
         cat $SOURCE/*.vob | nice -15 mencoder -mc 0 -nosound -o /dev/null -ovc lavc -lavcopts $LAVCOPT:vrc_override=$credits,$fin,$quantgen:vqscale=2:vpass=1 -vf crop=$crop,scale=$scale -ofps 23.976 -sws $sws - 2>&1 | tee $RACINE/$projet/tmp/suivi1.log
         bitmax=`cat $RACINE/$projet/tmp/suivi1.log | grep "Video stream" | awk '{print $3}' | sed -e "s/,/./"`
         CQmax=`bc <<EOF
                             scale=2
                             $bitmax * 1000 / ( ${ResX} * ${ResY} * $fps )
EOF`
         echo
         echo -e "${HEADCOLOR}$p221 $p231=${SUBCOLOR}0$CQmax${MAINCOLOR}" | tee $RACINE/$projet/tmp/mitemps
         echo
         echo -e "${SUBCOLOR}$p222${MAINCOLOR}"
         sleep 2
         cat $SOURCE/*.vob | nice -15 mencoder -mc 0 -nosound -o $CIBLE -ovc lavc -lavcopts $LAVCOPT:vrc_override=$credits,$fin,$quantgen:vbitrate=$bitvideo:vpass=2 -vf crop=$crop,scale=$scale -ofps 23.976 -sws $sws - 2>&1 | tee $RACINE/$projet/tmp/suivi2.log
      else
         if [ "$lb" = "OK" ]; then
            echo -e "${SUBCOLOR}$p223${MAINCOLOR}"
           cat $SOURCE/*.vob |  nice -15 mencoder -mc 0 -nosound -o /dev/null -ovc lavc -lavcopts $LAVCOPT:vrc_override=$credits,$fin,$quantgen:vqscale=2:vpass=1 -vf crop=$crop,pp=$deint,scale=$scale -sws $sws - 2>&1 | tee $RACINE/$projet/tmp/suivi1.log
            bitmax=`cat $RACINE/$projet/tmp/suivi1.log | grep "Video stream" | awk '{print $3}' | sed -e "s/,/./"`
            CQmax=`bc <<EOF
                             scale=2
                             $bitmax * 1000 / ( ${ResX} * ${ResY} * $fps )
EOF`
            echo
            echo -e "${HEADCOLOR}$p221 $p231=${SUBCOLOR}0$CQmax${MAINCOLOR}" | tee $RACINE/$projet/tmp/mitemps
            echo
            echo -e "${SUBCOLOR}$p222${MAINCOLOR}"
            sleep 2
            cat $SOURCE/*.vob | nice -15 mencoder -mc 0 -nosound -o $CIBLE -ovc lavc -lavcopts $LAVCOPT:vrc_override=$credits,$fin,$quantgen:vbitrate=$bitvideo:vpass=2 -vf crop=$crop,pp=$deint,scale=$scale -sws $sws - 2>&1 | tee $RACINE/$projet/tmp/suivi2.log
         else
            echo -e "${SUBCOLOR}$p223${MAINCOLOR}"
            cat $SOURCE/*.vob | nice -15 mencoder -mc 0 -nosound -o /dev/null -ovc lavc -lavcopts $LAVCOPT:vrc_override=$credits,$fin,$quantgen:vqscale=2:vpass=1 -vf crop=$crop,scale=$scale -sws $sws - 2>&1 | tee $RACINE/$projet/tmp/suivi1.log
            bitmax=`cat $RACINE/$projet/tmp/suivi1.log | grep "Video stream" | awk '{print $3}' | sed -e "s/,/./"`
            CQmax=`bc <<EOF
                             scale=2
                             $bitmax * 1000 / ( ${ResX} * ${ResY} * $fps )
EOF`
            echo
            echo -e "${HEADCOLOR}$p221 $p231=${SUBCOLOR}0$CQmax${MAINCOLOR}" | tee $RACINE/$projet/tmp/mitemps
            echo
            echo -e "${SUBCOLOR}$p222${MAINCOLOR}"
            sleep 2
            cat $SOURCE/*.vob | nice -15 mencoder -mc 0 -nosound -o $CIBLE -ovc lavc -lavcopts $LAVCOPT:vrc_override=$credits,$fin,$quantgen:vbitrate=$bitvideo:vpass=2 -vf crop=$crop,scale=$scale -sws $sws - 2>&1 | tee $RACINE/$projet/tmp/suivi2.log
         fi
      fi
    fi
   fi
else
 if [ "$silence" = "OK" ]; then
      if [ "$xvid" = "OK" ]; then
         if [ "$fps" = "29.97" ]; then
            echo "$p220"
            echo -e "${SUBCOLOR}$p223${MAINCOLOR}"
            nice -15 mencoder $SOURCE -mc 0 -nosound -o /dev/null -ovc xvid -xvidencopts $XVIDOPT:bitrate=$bitvideo:pass=1 -vf crop=$crop,scale=$scale -ofps 23.976 -sws $sws 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 | grep "Video stream" | awk '{print $3}' | sed -e "s/,/./"`
            CQmax=`bc <<EOF
                             scale=2
                             $bitmax * 1000 / ( ${ResX} * ${ResY} * $fps )
EOF`
            echo
            echo -e "${HEADCOLOR}$p221 $p231=${SUBCOLOR}0$CQmax${MAINCOLOR}" | tee $RACINE/$projet/tmp/mitemps
            echo
            echo -e "${SUBCOLOR}$p222${MAINCOLOR}"
            sleep 2
            nice -15 mencoder $SOURCE -mc 0 -nosound -o $CIBLE -ovc xvid -xvidencopts $XVIDOPT:bitrate=$bitvideo:pass=2 -vf crop=$crop,scale=$scale -ofps 23.976 -sws $sws 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}$p223${MAINCOLOR}"
               nice -15 mencoder $SOURCE -mc 0 -nosound -o /dev/null -ovc xvid -xvidencopts $XVIDOPT:bitrate=$bitvideo:pass=1 -vf crop=$crop,pp=$deint,scale=$scale -sws $sws 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 | grep "Video stream" | awk '{print $3}' | sed -e "s/,/./"`
               CQmax=`bc <<EOF
                             scale=2
                             $bitmax * 1000 / ( ${ResX} * ${ResY} * $fps )
EOF`
               echo
               echo -e "${HEADCOLOR}$p221 $p231=${SUBCOLOR}0$CQmax${MAINCOLOR}" | tee $RACINE/$projet/tmp/mitemps
               echo
               echo -e "${SUBCOLOR}$p222${MAINCOLOR}"
               sleep 2
	       nice -15 mencoder $SOURCE -mc 0 -nosound -o $CIBLE -ovc xvid -xvidencopts $XVIDOPT:bitrate=$bitvideo:pass=2 -vf crop=$crop,pp=$deint,scale=$scale -sws $sws 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}$p223${MAINCOLOR}"
               nice -15 mencoder $SOURCE -mc 0 -nosound -o /dev/null -ovc xvid -xvidencopts $XVIDOPT:bitrate=$bitvideo:pass=1 -vf crop=$crop,scale=$scale -sws $sws 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 | grep "Video stream" | awk '{print $3}' | sed -e "s/,/./"`
               CQmax=`bc <<EOF
                                scale=2
                                $bitmax * 1000 / ( ${ResX} * ${ResY} * $fps )
EOF`
               echo
               echo -e "${HEADCOLOR}$p221 $p231=${SUBCOLOR}0$CQmax${MAINCOLOR}" | tee $RACINE/$projet/tmp/mitemps
               echo
               echo -e "${SUBCOLOR}$p222${MAINCOLOR}"
               sleep 2
               nice -15 mencoder $SOURCE -mc 0 -nosound -o $CIBLE -ovc xvid -xvidencopts $XVIDOPT:bitrate=$bitvideo:pass=2 -vf crop=$crop,scale=$scale -sws $sws 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 "$p220"
              echo -e "${SUBCOLOR}$p223${MAINCOLOR}"
              nice -15 mencoder $SOURCE -mc 0 -nosound -o /dev/null -ovc lavc -lavcopts $LAVCOPT:vrc_override=$credits,$fin,$quantgen:vqscale=2:vpass=1 -vf crop=$crop,scale=$scale -ofps 23.976 -sws $sws 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 | grep "Video stream" | awk '{print $3}' | sed -e "s/,/./"`
              CQmax=`bc <<EOF
                             scale=2
                             $bitmax * 1000 / ( ${ResX} * ${ResY} * $fps )
EOF`
              echo
              echo -e "${HEADCOLOR}$p221 $p231=${SUBCOLOR}0$CQmax${MAINCOLOR}" | tee $RACINE/$projet/tmp/mitemps
              echo
              echo -e "${SUBCOLOR}$p222${MAINCOLOR}"
              sleep 2
              nice -15 mencoder $SOURCE -mc 0 -nosound -o $CIBLE -ovc lavc -lavcopts $LAVCOPT:vrc_override=$credits,$fin,$quantgen:vbitrate=$bitvideo:vpass=2 -vf crop=$crop,scale=$scale -ofps 23.976 -sws $sws 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}$p223${MAINCOLOR}"
               nice -15 mencoder $SOURCE -mc 0 -nosound -o /dev/null -ovc lavc -lavcopts $LAVCOPT:vrc_override=$credits,$fin,$quantgen:vqscale=2:vpass=1 -vf crop=$crop,pp=$deint,scale=$scale -sws $sws 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 | grep "Video stream" | awk '{print $3}' | sed -e "s/,/./"`
               CQmax=`bc <<EOF
                             scale=2
                             $bitmax * 1000 / ( ${ResX} * ${ResY} * $fps )
EOF`
               echo
               echo -e "${HEADCOLOR}$p221 $p231=${SUBCOLOR}0$CQmax${MAINCOLOR}" | tee $RACINE/$projet/tmp/mitemps
               echo
               echo -e "${SUBCOLOR}$p222${MAINCOLOR}"
               sleep 2
               nice -15 mencoder $SOURCE -mc 0 -nosound -o $CIBLE -ovc lavc -lavcopts $LAVCOPT:vrc_override=$credits,$fin,$quantgen:vbitrate=$bitvideo:vpass=2 -vf crop=$crop,pp=$deint,scale=$scale -sws $sws 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}$p223${MAINCOLOR}"
               nice -15 mencoder $SOURCE -mc 0 -nosound -o /dev/null -ovc lavc -lavcopts $LAVCOPT:vrc_override=$credits,$fin,$quantgen:vqscale=2:vpass=1 -vf crop=$crop,scale=$scale -sws $sws 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 | grep "Video stream" | awk '{print $3}' | sed -e "s/,/./"`
               CQmax=`bc <<EOF
                             scale=2
                             $bitmax * 1000 / ( ${ResX} * ${ResY} * $fps )
EOF`
               echo
               echo -e "${HEADCOLOR}$p221 $p231=${SUBCOLOR}0$CQmax${MAINCOLOR}" | tee $RACINE/$projet/tmp/mitemps
               echo
               echo -e "${SUBCOLOR}$p222${MAINCOLOR}"
               sleep 2
               nice -15 mencoder $SOURCE -mc 0 -nosound -o $CIBLE -ovc lavc -lavcopts $LAVCOPT:vrc_override=$credits,$fin,$quantgen:vbitrate=$bitvideo:vpass=2 -vf crop=$crop,scale=$scale -sws $sws 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
   else
      if [ "$xvid" = "OK" ]; then
      if [ "$fps" = "29.97" ]; then
         echo "$p220"
         echo -e "${SUBCOLOR}$p223${MAINCOLOR}"
         nice -15 mencoder $SOURCE -mc 0 -nosound -o /dev/null -ovc xvid -xvidencopts $XVIDOPT:bitrate=$bitvideo:pass=1 -vf crop=$crop,scale=$scale -ofps 23.976 -sws $sws 2>&1 | tee $RACINE/$projet/tmp/suivi1.log
         bitmax=`cat $RACINE/$projet/tmp/suivi1.log | grep "Video stream" | awk '{print $3}' | sed -e "s/,/./"`
         CQmax=`bc <<EOF
                             scale=2
                             $bitmax * 1000 / ( ${ResX} * ${ResY} * $fps )
EOF`
         echo
         echo -e "${HEADCOLOR}$p221 $p231=${SUBCOLOR}0$CQmax${MAINCOLOR}" | tee $RACINE/$projet/tmp/mitemps
         echo
         echo -e "${SUBCOLOR}$p222${MAINCOLOR}"
         sleep 2
         nice -15 mencoder $SOURCE -mc 0 -nosound -o $CIBLE -ovc xvid -xvidencopts $XVIDOPT:bitrate=$bitvideo:pass=2 -vf crop=$crop,scale=$scale -ofps 23.976 -sws $sws 2>&1 | tee $RACINE/$projet/tmp/suivi2.log
      else
         if [ "$lb" = "OK" ]; then
            echo -e "${SUBCOLOR}$p223${MAINCOLOR}"
            nice -15 mencoder $SOURCE -mc 0 -nosound -o /dev/null -ovc xvid -xvidencopts $XVIDOPT:bitrate=$bitvideo:pass=1 -vf crop=$crop,pp=$deint,scale=$scale -sws $sws 2>&1 | tee $RACINE/$projet/tmp/suivi1.log
            bitmax=`cat $RACINE/$projet/tmp/suivi1.log | grep "Video stream" | awk '{print $3}' | sed -e "s/,/./"`
            CQmax=`bc <<EOF
                             scale=2
                             $bitmax * 1000 / ( ${ResX} * ${ResY} * $fps )
EOF`
            echo
            echo -e "${HEADCOLOR}$p221 $p231=${SUBCOLOR}0$CQmax${MAINCOLOR}" | tee $RACINE/$projet/tmp/mitemps
            echo
            echo -e "${SUBCOLOR}$p222${MAINCOLOR}"
            sleep 2
            nice -15 mencoder $SOURCE -mc 0 -nosound -o $CIBLE -ovc xvid -xvidencopts $XVIDOPT:bitrate=$bitvideo:pass=2 -vf crop=$crop,pp=$deint,scale=$scale -sws $sws 2>&1 | tee $RACINE/$projet/tmp/suivi2.log
         else
            echo -e "${SUBCOLOR}$p223${MAINCOLOR}"
            nice -15 mencoder $SOURCE -mc 0 -nosound -o /dev/null -ovc xvid -xvidencopts $XVIDOPT:bitrate=$bitvideo:pass=1 -vf crop=$crop,scale=$scale -sws $sws 2>&1 | tee $RACINE/$projet/tmp/suivi1.log
            bitmax=`cat $RACINE/$projet/tmp/suivi1.log | grep "Video stream" | awk '{print $3}' | sed -e "s/,/./"`
            CQmax=`bc <<EOF
                             scale=2
                             $bitmax * 1000 / ( ${ResX} * ${ResY} * $fps )
EOF`
            echo
            echo -e "${HEADCOLOR}$p221 $p231=${SUBCOLOR}0$CQmax${MAINCOLOR}" | tee $RACINE/$projet/tmp/mitemps
            echo
            echo -e "${SUBCOLOR}$p222${MAINCOLOR}"
            sleep 2
            nice -15 mencoder $SOURCE -mc 0 -nosound -o $CIBLE -ovc xvid -xvidencopts $XVIDOPT:bitrate=$bitvideo:pass=2 -vf crop=$crop,scale=$scale -sws $sws 2>&1 | tee $RACINE/$projet/tmp/suivi2.log
         fi
      fi
   else
      if [ "$fps" = "29.97" ]; then
         echo "$p220"
         echo -e "${SUBCOLOR}$p223${MAINCOLOR}"
         nice -15 mencoder $SOURCE -mc 0 -nosound -o /dev/null -ovc lavc -lavcopts $LAVCOPT:vrc_override=$credits,$fin,$quantgen:vqscale=2:vpass=1 -vf crop=$crop,scale=$scale -ofps 23.976 -sws $sws 2>&1 | tee $RACINE/$projet/tmp/suivi1.log
         bitmax=`cat $RACINE/$projet/tmp/suivi1.log | grep "Video stream" | awk '{print $3}' | sed -e "s/,/./"`
         CQmax=`bc <<EOF
                             scale=2
                             $bitmax * 1000 / ( ${ResX} * ${ResY} * $fps )
EOF`
         echo
         echo -e "${HEADCOLOR}$p221 $p231=${SUBCOLOR}0$CQmax${MAINCOLOR}" | tee $RACINE/$projet/tmp/mitemps
         echo
         echo -e "${SUBCOLOR}$p222${MAINCOLOR}"
         sleep 2
         nice -15 mencoder $SOURCE -mc 0 -nosound -o $CIBLE -ovc lavc -lavcopts $LAVCOPT:vrc_override=$credits,$fin,$quantgen:vbitrate=$bitvideo:vpass=2 -vf crop=$crop,scale=$scale -ofps 23.976 -sws $sws 2>&1 | tee $RACINE/$projet/tmp/suivi2.log
      else
         if [ "$lb" = "OK" ]; then
            echo -e "${SUBCOLOR}$p223${MAINCOLOR}"
            nice -15 mencoder $SOURCE -mc 0 -nosound -o /dev/null -ovc lavc -lavcopts $LAVCOPT:vrc_override=$credits,$fin,$quantgen:vqscale=2:vpass=1 -vf crop=$crop,pp=$deint,scale=$scale -sws $sws 2>&1 | tee $RACINE/$projet/tmp/suivi1.log
            bitmax=`cat $RACINE/$projet/tmp/suivi1.log | grep "Video stream" | awk '{print $3}' | sed -e "s/,/./"`
            CQmax=`bc <<EOF
                             scale=2
                             $bitmax * 1000 / ( ${ResX} * ${ResY} * $fps )
EOF`
            echo
            echo -e "${HEADCOLOR}$p221 $p231=${SUBCOLOR}0$CQmax${MAINCOLOR}" | tee $RACINE/$projet/tmp/mitemps
            echo
            echo -e "${SUBCOLOR}$p222${MAINCOLOR}"
            sleep 2
            nice -15 mencoder $SOURCE -mc 0 -nosound -o $CIBLE -ovc lavc -lavcopts $LAVCOPT:vrc_override=$credits,$fin,$quantgen:vbitrate=$bitvideo:vpass=2 -vf crop=$crop,pp=$deint,scale=$scale -sws $sws 2>&1 | tee $RACINE/$projet/tmp/suivi2.log
         else
            echo -e "${SUBCOLOR}$p223${MAINCOLOR}"
            nice -15 mencoder $SOURCE -mc 0 -nosound -o /dev/null -ovc lavc -lavcopts $LAVCOPT:vrc_override=$credits,$fin,$quantgen:vqscale=2:vpass=1 -vf crop=$crop,scale=$scale -sws $sws 2>&1 | tee $RACINE/$projet/tmp/suivi1.log
            bitmax=`cat $RACINE/$projet/tmp/suivi1.log | grep "Video stream" | awk '{print $3}' | sed -e "s/,/./"`
            CQmax=`bc <<EOF
                             scale=2
                             $bitmax * 1000 / ( ${ResX} * ${ResY} * $fps )
EOF`
            echo
            echo -e "${HEADCOLOR}$p221 $p231=${SUBCOLOR}0$CQmax${MAINCOLOR}" | tee $RACINE/$projet/tmp/mitemps
            echo
            echo -e "${SUBCOLOR}$p222${MAINCOLOR}"
            sleep 2
            nice -15 mencoder $SOURCE -mc 0 -nosound -o $CIBLE -ovc lavc -lavcopts $LAVCOPT:vrc_override=$credits,$fin,$quantgen:vbitrate=$bitvideo:vpass=2 -vf crop=$crop,scale=$scale -sws $sws 2>&1 | tee $RACINE/$projet/tmp/suivi2.log
         fi
      fi
    fi
   fi
fi
fi
   if [ "$xvid4" = "" ]; then
      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
   fi
   duree=`cat $RACINE/$projet/tmp/infos.son | grep "length" | awk -F "=" '{print $3}' | awk '{print $1}'`
   t2=`date +'%s'`
   nbhrs=`bc <<EOF
          scale=0
          ($t2 - $t1) / 3600
EOF`
   nbmin=`bc <<EOF
          scale=0
          ($t2 - $t1) / 60 - $nbhrs * 60
EOF`
   nbsec=`bc <<EOF
          scale=0
          ($t2 - $t1) - $nbmin * 60 - $nbhrs * 3600
EOF`
   vitencvideo=`bc <<EOF
          scale=2
          $duree / ($t2 - $t1) * $fps
EOF`
   echo
   echo "$p256 : ${nbhrs}hrs ${nbmin}min ${nbsec}sec" | tee $RACINE/$projet/tmp/videotime
   echo "$p261 : $vitencvideo fps" | tee $RACINE/$projet/tmp/videospeed
   
   echo "encodage video" >> $RACINE/$projet/tmp/log

   if [ "$extinction" = "OK" ]; then
      echo
      echo "$p224"
      sleep 10
      touch ~/.tuxripextinction
      echo $RACINE $projet >> ~/.tuxripextinction
      sudo /sbin/shutdown -h now
   fi

fi

# mixage A/V
    finalisation

if [ "$grave" = "OK" ]; then
   if [ $etapedeb -le 8 ]; then
      case $tailleCD in
         1300 ) echo -e "${TABLECOLOR}$p225"
                echo -e "${MAINCOLOR}"
                tailleSECT1=`mkisofs -r -J -q -print-size $RACINE/$projet/video/cd1/${projet}-cd1.$extvideo`
                tailleSECT2=`mkisofs -r -J -q -print-size $RACINE/$projet/video/cd2/${projet}-cd2.$extvideo`
                if  [ $tailleSECT1 -le 333000 ] ; then
                   disk1=650
                elif [ $tailleSECT1 -le 360000 ] ; then
                   disk1=700
                else
                   echo "$p226"
                   exit 0
                fi
                if  [ $tailleSECT2 -le 333000 ] ; then
                   disk2=650
                elif [ $tailleSECT2 -le 360000 ] ; then
                   disk2=700
                else
                   echo "$p226"
                   exit 0
                fi
                echo -e "CD1 : ${SUBCOLOR}$p227 $disk1$p117 $p228${MAINCOLOR}"
                su -c "mkisofs -r -J $RACINE/$projet/video/cd1/${projet}-cd1.$extvideo 2>/dev/null | cdrecord -v -dao speed=$vitesse dev=$graveur -tsize=${tailleSECT1}s -"
                echo -e "CD2 : ${SUBCOLOR}$p227 $disk2$p117 $p228${MAINCOLOR}"
                su -c "mkisofs -r -J $RACINE/$projet/video/cd2/${projet}-cd2.$extvideo 2>/dev/null | cdrecord -v -dao speed=$vitesse dev=$graveur -tsize=${tailleSECT2}s -"
                exit ;;

         1404 ) echo -e "${TABLECOLOR}$p225"
                echo -e "${MAINCOLOR}"
                tailleSECT1=`mkisofs -r -J -q -print-size $RACINE/$projet/video/cd1/${projet}-cd1.$extvideo`
                tailleSECT2=`mkisofs -r -J -q -print-size $RACINE/$projet/video/cd2/${projet}-cd2.$extvideo`
                if  [ $tailleSECT1 -le 333000 ] ; then
                   disk1=650
                elif [ $tailleSECT1 -le 360000 ] ; then
                   disk1=700
                else
                   echo "$p226"
                   exit 0
                fi
                if  [ $tailleSECT2 -le 333000 ] ; then
                   disk2=650
                elif [ $tailleSECT2 -le 360000 ] ; then
                   disk2=700
                else
                   echo "$p226"
                   exit 0
                fi
                echo -e "CD1 : ${SUBCOLOR}$p227 $disk1$p117 $p228${MAINCOLOR}"
                su -c "mkisofs -r -J $RACINE/$projet/video/cd1/${projet}-cd1.$extvideo 2>/dev/null | cdrecord -v -dao speed=$vitesse dev=$graveur -tsize=${tailleSECT1}s -"
                echo -e "CD2 : ${SUBCOLOR}$p227 $disk2$p117 $p228${MAINCOLOR}"
                su -c "mkisofs -r -J $RACINE/$projet/video/cd2/${projet}-cd2.$extvideo 2>/dev/null | cdrecord -v -dao speed=$vitesse dev=$graveur -tsize=${tailleSECT2}s -"
                exit ;;

         *) echo -e "${TABLECOLOR}$p225"
            echo -e "${MAINCOLOR}"
            if [ "$sub" = "OK" ] && [ "$contain" = "ogm" ]; then
                comp=`cat $RACINE/$projet/sub/nom | grep -w "bz2"`
                if [ "$comp" = "" ]; then
                   nomsub1=`cat $RACINE/$projet/sub/nom`
                   nomsub2=`cat $RACINE/$projet/sub/nom | sed -e "s/\.sub/\.idx/"`
                   tailleSECT=`mkisofs -r -J -q -print-size $RACINE/$projet/video/${projet}.$extvideo $RACINE/$projet/sub/$nomsub1 $RACINE/$projet/sub/$nomsub2`
                else
                   nomsub=`cat $RACINE/$projet/sub/nom`
                   tailleSECT=`mkisofs -r -J -q -print-size $RACINE/$projet/video/${projet}.$extvideo $RACINE/$projet/sub/$nomsub`
                fi
            else
                tailleSECT=`mkisofs -r -J -q -print-size $RACINE/$projet/video/${projet}.$extvideo`
            fi
            if  [ $tailleSECT -le 333000 ] ; then
               disk=650
            elif [ $tailleSECT -le 360000 ] ; then
               disk=700
            else
               echo "$p226"
               exit 0
            fi
            echo -e "${SUBCOLOR}$p227 $disk$p117 $p228${MAINCOLOR}"
            if [ "$sub" = "OK" ] && [ "$contain" = "ogm" ]; then
                if [ "$comp" = "" ]; then
                   su -c "mkisofs -r -J $RACINE/$projet/video/${projet}.$extvideo $RACINE/$projet/sub/$nomsub1 $RACINE/$projet/sub/$nomsub2 2>/dev/null | cdrecord -v -dao speed=$vitesse dev=$graveur -tsize=${tailleSECT}s -"
                else
                   su -c "mkisofs -r -J $RACINE/$projet/video/${projet}.$extvideo $RACINE/$projet/sub/$nomsub 2>/dev/null | cdrecord -v -dao speed=$vitesse dev=$graveur -tsize=${tailleSECT}s -"
                fi
            else
               su -c "mkisofs -r -J $RACINE/$projet/video/${projet}.$extvideo 2>/dev/null | cdrecord -v -dao speed=$vitesse dev=$graveur -tsize=${tailleSECT}s -"
            fi;;
       esac
   fi
fi
   echo -e "${MAINCOLOR}"
