snippets / convert2flv (Convert avi to flv)

Language: Shell - First posted by llaumgui on 2007-10-3 22:04 (1 year, 1 month)
Link to the snippet: http://www.friendsnippets.org/snippet/38/

Need : - zenity - ffmpeg

  1 #!/bin/bash
2 ###############################################################################
3 #
4 # convert2flv :
5 # Convert avi to flv.
6 # Need :
7 # - zenity
8 # - ffmpeg
9 #
10 # by Guillaume Kulakowski a.k.a LLaumgui <guillaume at llaumgui dot com>
11 # Version 1.0^M
12 #
13 ###############################################################################
14 # This program is free software; you can redistribute it and/or
15 # modify it under the terms of the GNU General Public License
16 # as published by the Free Software Foundation; either version 2
17 # of the License, or (at your option) any later version.
18 #
19 # This program is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
23 #
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not,
26 # - write to the Free Software
27 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28 # - See http://www.gnu.org/licenses/gpl.html^M
29 ###############################################################################
30
31
32 ###############################################################################
33 # Variables :
34 #
35 OPT_AR=22050
36 OPT_AB=32
37 OPT_S="320X240"
38 OPT_NAME="video.flv"
39 OPT_LOG=true
40
41
42
43
44 ###############################################################################
45 # Fonctions :
46 #
47 ##
48 # Définir le taux d’échantillonnage du son :
49 #
50 function setAr () {
51
52 OPT_AR=`zenity --entry --text="Taux d’échantillonnage" --entry-text=$OPT_AR`
53 }
54
55
56
57 ##
58 # Définir le audio bitrate en kbit / seconde :
59 #
60 function setAb () {
61
62 OPT_AB=`zenity --entry --text="Audio bitrate en kbit / seconde" --entry-text=$OPT_AB`
63 }
64
65
66
67 ##
68 # Définir les dimensions après conversion :
69 #
70 function setS () {
71
72 OPT_S=`zenity --entry --text="Dimensions après conversion" --entry-text=$OPT_S`
73 }
74
75
76
77 ##
78 # Définir les nom de la vidéo de sortie :
79 #
80 function setName () {
81
82 OPT_NAME=`zenity --entry --text="Non du fichier flv de sortie" --entry-text=$OPT_NAME`
83 }
84
85
86
87 ##
88 # Test l'appel du script :
89 #
90 function testArg () {
91 if [ $1 -lt 2 ]; then
92 zenity --info \
93 --width=600 \
94 --title="Usage incorrect de convert2flv !" \
95 --text="L'usage correct est :
96 convert2flv &#60;Chemin vers le fichier&#62; &#60;Nom du fichier&#62;";
97 exit
98 fi
99 }
100
101
102
103 ##
104 # Lancement
105 #
106 function convert () {
107
108 #Debug zenity --error --text="ffmpeg -i '$1/$2' -ar $OPT_AR -ab $OPT_AB -f flv -s $OPT_S '$1/$OPT_NAME'"
109 #echo "ffmpeg -i '$1/$2' -ar $OPT_AR -ab $OPT_AB -f flv -s $OPT_S '$1/$OPT_NAME'" > "$1/$OPT_NAME.log"
110 if [ $OPT_LOG = true ]; then
111 ffmpeg -y -i "$1/$2" -ar $OPT_AR -ab $OPT_AB -f flv -s $OPT_S "$1/$OPT_NAME" 2> "$1/$OPT_NAME.log"
112 zenity --text-info --filename="$1/$OPT_NAME.log"
113 else
114 ffmpeg -y -i "$1/$2" -ar $OPT_AR -ab $OPT_AB -f flv -s $OPT_S "$1/$OPT_NAME"
115 fi
116 }
117
118
119
120
121
122 ###############################################################################
123 # Code brut :
124 #
125 testArg $#
126 setAr
127 setAb
128 setS
129 setName
130 convert "$1" "$2"
In order to post a comment, you should have a friendsnippet account. Please sign-in.

0 comments

Oct '07
  • Need : - zenity - ffmpeg

  • pour les screencasts ça peut aider