2 #Copyright 2009 Paul Hänsch
4 #This file is part of Viper.
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.
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.
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/>
24 A set of single frames.
26 The frames are stored on harddisk and advanced editing operations can be
27 performed on the set. This object requires a project folder on the harddisk
28 where the frames can be stored.
31 def __init__(self, projectdir, chunk):
35 projectdir - path of the existing project directory, a subdirectory will
36 be created for each Frameset object
37 chunk - a Chunk object from which the frameset will be created
45 if projectdir[-1] == '/':
46 self.projectdir = projectdir
48 self.projectdir = projectdir + '/'
50 self.subdir = chunk.videofile + ":" + str(chunk.start) + ":" + str(chunk.frames) + '/'
52 os.mkdir(self.projectdir + self.subdir)
54 print 'subdirectory seems to exist, ignoring'
56 self.width = int(chunk.videoprops['ID_VIDEO_WIDTH'])
57 self.height = int(chunk.videoprops['ID_VIDEO_HEIGHT'])
58 self.fps = float(chunk.videoprops['ID_VIDEO_FPS'])
60 self.framegen(self.projectdir + self.subdir, chunk)
62 def framegen(self, dir, chunk):
64 Generate the frameset from chunk
66 This method is normally called by the constructor.
72 slave = os.popen('mplayer -vf format=bgr24 -vo tga "' +
73 cwd + '/"' + chunk.slave_subcommand())
74 line = slave.readline()
77 line = slave.readline()
79 for file in os.listdir('./'):
80 if file[-4:] == '.tga':
81 self.frames.append(file)
85 def slave_video(self):
87 Return a list of mplayer command line arguments,
88 which specifies the video to play.
91 ['mf://images', '-mf', 'fps={framerate}'
93 return ('mf://' + self.projectdir + self.subdir + '*.tga',
94 '-mf', 'fps=' + str(self.fps)