]> git.plutz.net Git - viper/blob - plugins/v_default.py
moved from svn.imp.fu-berlin.de/viper rev33
[viper] / plugins / v_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 V_Custom(V_Plugin):
22     def build_dialog(self):
23         self.subgets['desc'] = Label(self, text = 'Enter a piece of mplayer command line\n'+
24                                      'specifying a video encoder. I.e.:\n' +
25                                      '"-ovc raw"')
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 V_Copy(V_Plugin):
37     def build_dialog(self):
38         self.subgets['desc'] = Label(self, text = 'This will copy an existing video stream.')
39         self.subgets['desc'].pack(side = TOP, expand = True, fill = BOTH)
40
41     def name(self):
42         return 'Copy'
43
44     def subcommand(self):
45         return ['-ovc', 'copy']
46
47     def is_available(self):
48         result = False
49         slave = os.popen2(['mencoder', '-ovc', 'help'])
50         line = '#'
51         while line != '':
52             line = slave[1].readline()
53             if line.lstrip().find('copy') == 0:
54                 result = True
55         return result
56
57 class V_Raw(V_Plugin):
58     def build_dialog(self):
59         slave = os.popen2(['mencoder', '-vf', 'format=fmt=help'])
60         line = '#'
61         formatstr = ''
62         while line != '':
63             line = slave[1].readline()
64             if line.lstrip().find('Available formats:') > -1:
65                 formatstr = line.split(':', 1)[1]
66         formats = formatstr.split(' ')[1:]
67         try:
68             init = formats.index('rgb24')
69         except:
70             init = 0
71
72         self.subgets['desc'] = Label(self,
73                                      text = 'This will output an uncompressed video stream.\n'+
74                                             'The resulting file will be VERY large!!!')
75         self.subgets['desc'].grid(row = 0, column = 0, columnspan = 4)
76
77         self.subgets['l_format'] = Label(self, text = 'Format:')
78         self.subgets['l_format'].grid(row = 1, column = 1)
79         self.subgets['format'] = Pmw.OptionMenu(self, initialitem = init,
80                                                 items = formats)
81         self.subgets['format'].grid(row = 1, column = 2)
82
83     def name(self):
84         return 'Raw'
85
86     def subcommand(self):
87         return ['-ovc', 'raw', '-vf', 'format='+self.subgets['format'].getvalue()]
88
89     def is_available(self):
90         result = False
91         slave = os.popen2(['mencoder', '-ovc', 'help'])
92         line = '#'
93         while line != '':
94             line = slave[1].readline()
95             if line.lstrip().find('raw') == 0:
96                 result = True
97         return result