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.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('-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('-o', '--output', dest='output', help='path to save frame to, jpg, png supported')
(opts, args) = parser.parse_args()

View File

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