]> git.plutz.net Git - viper/blob - plugins/c_default.py
moved from svn.imp.fu-berlin.de/viper rev33
[viper] / plugins / c_default.py
1 #encoding: utf-8
2 #Copyright 2009 Paul Hänsch
3
4 #This file is part of Viper.
5
6 #Viper is free software: you can redistribute it and/or modify
7 #it under the terms of the GNU General Public License as published by
8 #the Free Software Foundation, either version 3 of the License, or
9 #(at your option) any later version.
10
11 #Viper is distributed in the hope that it will be useful,
12 #but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 #GNU General Public License for more details.
15
16 #You should have received a copy of the GNU General Public License
17 #along with Viper.  If not, see <http://www.gnu.org/licenses/>
18
19 from plugin import *
20
21 class C_Custom(C_Plugin):
22     def build_dialog(self):
23         self.subgets['desc'] = Label(self, text = 'Enter a piece of mplayer command line\n'+
24                                      'specifying a container format. I.e.:\n' +
25                                      '"-of avi"')
26         self.subgets['desc'].pack(side = TOP, expand = True, fill = BOTH)
27         self.subgets['line'] = Entry(self)
28         self.subgets['line'].pack(side = TOP, expand = True, fill = X)
29
30     def name(self):
31         return 'Custom'
32
33     def subcommand(self):
34         return self.line.split(' ')
35
36 class C_Avi(C_Plugin):
37     def build_dialog(self):
38         self.subgets['desc'] = Label(self, text = 'This will output an avi file.')
39         self.subgets['desc'].pack(side = TOP, expand = True, fill = BOTH)
40
41     def name(self):
42         return 'AVI'
43
44     def subcommand(self):
45         return ['-of', 'avi']
46
47     def is_available(self):
48         result = False
49         slave = os.popen2(['mencoder', '-of', 'help'])
50         line = '#'
51         while line != '':
52             line = slave[1].readline()
53             if line.lstrip().find('avi') == 0:
54                 result = True
55         return result
56
57 class C_Mpeg(C_Plugin):
58     def build_dialog(self):
59         self.subgets['l_format'] = Label(self, text = 'Format')
60         self.subgets['l_format'].grid(row = 0, column = 0)
61         self.subgets['format'] = Pmw.OptionMenu(self, initialitem = 1,
62                                                 items = ['mpeg1', 'mpeg2', 'xvcd', 'xsvcd',
63                                                          'dvd', 'pes1', 'pes2'])
64         self.subgets['format'].grid(row = 1, column = 0)
65
66         self.subgets['custom'] = False
67         self.subgets['c_custom'] = Checkbutton(self, text = 'Custom', command = self.c_custom)
68         self.subgets['c_custom'].deselect()
69         self.subgets['c_custom'].grid(row = 2, column = 0)
70
71         self.subgets['l_size'] = Label(self, text = 'Packetsize')
72         self.subgets['l_size'].grid(row = 0, column = 1)
73         self.subgets['size'] = Spinbox(self, from_ = 256, to = 65535,
74                                        increment = 256, width = 6)
75         self.subgets['size'].delete(0, END)
76         self.subgets['size'].insert(END, 2048)
77         self.subgets['size'].config(state = 'disabled')
78         self.subgets['size'].grid(row = 1, column = 1)
79
80         self.subgets['l_muxrate'] = Label(self, text = 'Muxrate')
81         self.subgets['l_muxrate'].grid(row = 0, column = 2)
82         self.subgets['muxrate'] = Spinbox(self, from_ = 0, to = 18000, increment = 100, width = 6)
83         self.subgets['muxrate'].delete(0, END)
84         self.subgets['muxrate'].insert(0, 1800)
85         self.subgets['muxrate'].config(state = 'disabled')
86         self.subgets['muxrate'].grid(row = 1, column = 2)
87
88         self.subgets['l_vbuf'] = Label(self, text = 'V Buffer (KB)')
89         self.subgets['l_vbuf'].grid(row = 0, column = 3)
90         self.subgets['vbuf'] = Spinbox(self, from_ = 40, to = 1194, increment = 10, width = 5)
91         self.subgets['vbuf'].delete(0, END)
92         self.subgets['vbuf'].insert(0, 400)
93         self.subgets['vbuf'].config(state = 'disabled')
94         self.subgets['vbuf'].grid(row = 1, column = 3)
95
96         self.subgets['l_abuf'] = Label(self, text = 'A Buffer (KB)')
97         self.subgets['l_abuf'].grid(row = 0, column = 4)
98         self.subgets['abuf'] = Spinbox(self, from_ = 4, to = 64, increment = 1, width = 3)
99         self.subgets['abuf'].delete(0, END)
100         self.subgets['abuf'].insert(0, 10)
101         self.subgets['abuf'].config(state = 'disabled')
102         self.subgets['abuf'].grid(row = 1, column = 4)
103
104         self.subgets['tsaf'] = False
105         self.subgets['c_tsaf'] = Checkbutton(self, text = 'Time Stamp for all Frames',
106                                              command = self.c_tsaf)
107         self.subgets['c_tsaf'].deselect()
108         self.subgets['c_tsaf'].config(state = 'disabled')
109         self.subgets['c_tsaf'].grid(row = 2, column = 1, columnspan = 2)
110
111         self.subgets['intl2'] = False
112         self.subgets['c_intl2'] = Checkbutton(self, text = 'Improved Interleaving',
113                                               command = self.c_intl2)
114         self.subgets['c_intl2'].deselect()
115         self.subgets['c_intl2'].config(state = 'disabled')
116         self.subgets['c_intl2'].grid(row = 2, column = 3, columnspan = 2)
117
118     def c_custom(self):
119         if self.subgets['custom']:
120             for name in ['size', 'muxrate', 'vbuf', 'abuf', 'c_tsaf', 'c_intl2']:
121                 self.subgets[name].config(state = 'disabled')
122         else:
123             for name in ['size', 'muxrate', 'vbuf', 'abuf', 'c_tsaf', 'c_intl2']:
124                 self.subgets[name].config(state = 'normal')
125
126         self.subgets['custom'] = not self.subgets['custom']
127
128     def c_tsaf(self):
129         self.subgets['tsaf'] = not self.subgets['tsaf']
130
131     def c_intl2(self):
132         self.subgets['intl2'] = not self.subgets['intl2']
133
134     def name(self):
135         return 'MPEG'
136
137     def subcommand(self):
138         opts = 'format='+self.subgets['format'].getvalue()
139         if self.subgets['custom']:
140             opts += ':size=' + self.subgets['size'].get()
141             opts += ':muxrate=' + self.subgets['muxrate'].get()
142             opts += ':vbuf_size=' + self.subgets['vbuf'].get()
143             opts += ':abuf_size=' + self.subgets['abuf'].get()
144             if self.subgets['tsaf']:
145                 opts += ':tsaf'
146             if self.subgets['intl2']:
147                 opts += ':interleaving2'
148         
149         return ['-of', 'mpeg', '-mpegopts', opts]
150
151     def is_available(self):
152         result = False
153         slave = os.popen2(['mencoder', '-of', 'help'])
154         line = '#'
155         while line != '':
156             line = slave[1].readline()
157             if line.lstrip().find('mpeg') == 0:
158                 result = True
159         return result
160
161 class C_RawVideo(C_Plugin):
162     def build_dialog(self):
163         self.subgets['desc'] = Label(self, text = 'This will output a raw video stream, '+
164                                      'an audio stream will not be contained.\n'+
165                                      'The resulting file may be used for further processing\n'+
166                                      'but will probably not be of any use by its own.')
167         self.subgets['desc'].pack(side = TOP, expand = True, fill = BOTH)
168
169     def name(self):
170         return 'Raw Video'
171
172     def subcommand(self):
173         return ['-of', 'rawvideo']
174
175     def is_available(self):
176         result = False
177         slave = os.popen2(['mencoder', '-of', 'help'])
178         line = '#'
179         while line != '':
180             line = slave[1].readline()
181             if line.lstrip().find('rawvideo') == 0:
182                 result = True
183         return result
184
185 class C_RawAudio(C_Plugin):
186     def build_dialog(self):
187         self.subgets['desc'] = Label(self, text = 'This will output a raw audio stream, '+
188                                      'a video stream will not be contained.\n'+
189                                      'The resulting file may be used for further processing\n'+
190                                      'but will probably not be of any use by its own.')
191         self.subgets['desc'].pack(side = TOP, expand = True, fill = BOTH)
192
193     def name(self):
194         return 'Raw Audio'
195
196     def subcommand(self):
197         return ['-of', 'rawaudio']
198
199     def is_available(self):
200         result = False
201         slave = os.popen2(['mencoder', '-of', 'help'])
202         line = '#'
203         while line != '':
204             line = slave[1].readline()
205             if line.lstrip().find('rawaudio') == 0:
206                 result = True
207         return result
208