Convert2
[modifier] Introduction
Convert2, (script bash) est un script interactif de conversion vidéo conçu à la base pour les utilisateurs de Rockbox pour iPod. Il a été modifié pour pouvoir être utilisé avec un grand nombre de codec. Convert2 à été codé pour faciliter l'utilisation du programme de conversion multimédia ffmpeg.
[modifier] Utilisation
Pour l'utiliser, rendez le exécutable et lancez le en tapant dans un shell :
$ ./
Vous aurez ensuite à choisir le format d'entrée puis de sortie et la résolution souhaiter en sortie.
Ceci fait, ce script ce chargera de convertir tout les fichiers dont vous avez au préalable choisi l'extension comme format d'entrée étant dans le même dossier que votre script.
[modifier] Le script
Copiez le script suivant dans un éditeur de fichiers (gedit, kate, nano, vim, ...), et enregistrez-le. Ajoutez le bit exécutable :
$ chmod u+x ./Convert2.sh
Le script :
#!/bin/bash # Convert2 est un script interactif de conversion vidéo conçu essentiellement pour les utilisateurs de Rockbox pour iPod. ## Convert2 is a interactive video conversion script designed primarily for users of Rockbox iPod. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ # Version : 1.1 _/ # _/ # Author : Shad _/ # Email : shadweasel@gmail.com _/ #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ # Copyright 2010 Shad # Programme délivré sous licence GNU 'General Public License', version 2 ou ultérieure. ## This is licensed under the GNU General Public License, version 2 or later. #------------------------------------------------------- # Players | LCD size | 4:3 video | 16:9 video | #------------------------------------------------------- # iPod Nano | 176x132 | 176x128 | 176x100 | #------------------------------------------------------- # (S) by sfr 241 | 320x240 | 320x240 | 320x180 | #------------------------------------------------------- # Variables : input='' fmtinput='' fmtoutput='' aspect='' resolution='' #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ # Choice of input formats and output._/ ## Choice of input formats. _/ #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ echo -e "_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/\n" echo "_/ _/\n" echo "_/ Welcome on Convert2 script _/\n" echo "_/ Version 1.1, by Shad _/\n" echo "_/ _/\n" echo "_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/\n" echo "\n" echo -e "Choice of input formats.\n------------------------\n" echo -e "1) AVI (Xvid/DivX)\n2) OGG\n3) Other..." read -p 'What is the input format of your video ? ' fmtinput if [ "$fmtinput" = "2" ] then fmtinput='ogg' elif [ "$fmtinput" = "3" ] then read -p "Enter the extension of your input format : " fmtinput else fmtinput='avi' fi #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ ## Choice of output formats. _/ #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ echo -e "\n\nChoice of output formats.\n------------------------\n" echo -e "1) MPEG (MPEG-2 video)\n2) MPEG4 (MPEG-4 part 2)\n3) Other..." read -p 'What is the input format of your video ? ' fmtoutput if [ "$fmtoutput" = "1" ] then fmtoutput='mpeg' elif [ $fmtoutput = "2" ] then fmtoutput='mpeg4' else read -p "Enter the extension of your output format : " fmtoutput fi #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ # Choose your screen resolution. _/ #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ echo -e "\n\nChoose your screen resolution.\n------------------------------\n" echo -e "1) iPod Nano (176x132)\n2) (S) by sfr 241 (320x240)\n3) Other..." read -p 'What is the input format of your video ? ' resolution if [ "$resolution" = "1" ] then echo -e "\n\nAspect of the input video.\n--------------------------\n" echo -e "1) 4:3\n2) 16:9" read aspect if [ "$aspect" = "1" ] then resolution='176x128' else resolution='176x100' fi elif [ $resolution = "2" ] then echo -e "\n\nAspect of the input video.\n--------------------------\n" echo -e "1) 4:3\n2) 16:9" read aspect if [ "$aspect" = "1" ] then resolution='320x240' else resolution='320x180' fi else read -p "Enter the resolution of your screen. (Ex: 320x240) : " resolution fi echo -e "\n\n********************\n" ls -1 *.$fmtinput echo -e "\n********************\n" read -p "Are you sure you want to convert all the above files to $fmtoutput ? [Y/n]" sure if [ "$sure" = "Y" ] || [ "$sure" = "" ] then if [ -d "YourVideos_$fmtoutput" ] then echo "Dossier :: OK" else mkdir YourVideos_$fmtoutput/ fi for input in *.$fmtinput; do ffmpeg -i "$input" -s $resolution "YourVideos_$fmtoutput/${input%$fmtinput}$fmtoutput"; echo "==> Okey ! Go for the next video ! :D" done fi echo -e "\n\n_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/\n_/ The End - Thank you for using Convert2 script. _/\n_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/\n" #_/_/_/_/_/_/_/_/ ## Debugging : _/ #_/_/_/_/_/_/_/_/ # echo "RESULTS :" # echo "---------" # echo $fmtinput # echo $fmtoutput # echo $aspect # echo $resolution # echo "---------"