use _frames for frame cache

This commit is contained in:
j 2009-01-19 10:43:30 +11:00
parent 4f9c3da160
commit b2c553fd36
2 changed files with 6 additions and 6 deletions

View file

@ -26,7 +26,7 @@ if __name__ == '__main__':
parser = OptionParser() parser = OptionParser()
parser.add_option('-x', '--width', dest='width', help='scale image to given width') parser.add_option('-x', '--width', dest='width', help='scale image to given width')
parser.add_option('-y', '--height', dest='height', help='scale image to given height') parser.add_option('-y', '--height', dest='height', help='scale image to given height')
parser.add_option('-p', '--pos', dest='pos', help='frame position in milliseconds') parser.add_option('-p', '--pos', dest='pos', help='frame position in seconds, float')
parser.add_option('-i', '--input', dest='input', help='video input') parser.add_option('-i', '--input', dest='input', help='video input')
parser.add_option('-o', '--output', dest='output', help='path to save frame to, jpg, png supported') parser.add_option('-o', '--output', dest='output', help='path to save frame to, jpg, png supported')
(opts, args) = parser.parse_args() (opts, args) = parser.parse_args()

View file

@ -25,7 +25,7 @@ class Video(gst.Pipeline):
# queue callbacks # queue callbacks
self.callback = {} self.callback = {}
# extracted frames # extracted frames
self.frames = {} self._frames = {}
# true only if we are prerolled # true only if we are prerolled
self._ready = False self._ready = False
@ -119,13 +119,13 @@ class Video(gst.Pipeline):
def frame(self, timestamp): def frame(self, timestamp):
mainloop = gobject.MainLoop() mainloop = gobject.MainLoop()
self.frames[timestamp] = None self._frames[timestamp] = None
def callback(frame, timestamp): def callback(frame, timestamp):
self.frames[timestamp] = frame self._frames[timestamp] = frame
mainloop.quit() mainloop.quit()
if self.getFrame(timestamp, callback): if self.getFrame(timestamp, callback):
mainloop.run() mainloop.run()
frame = self.frames[timestamp] frame = self._frames[timestamp]
del self.frames[timestamp] del self._frames[timestamp]
return frame return frame