fix 64px timelines
This commit is contained in:
parent
095da90eec
commit
83db829cf8
3 changed files with 40 additions and 16 deletions
|
@ -29,6 +29,25 @@ import gobject
|
||||||
import gst
|
import gst
|
||||||
|
|
||||||
|
|
||||||
|
def pad_compatible_stream(pad, stream):
|
||||||
|
"""
|
||||||
|
Checks whether the given pad is compatible with the given stream.
|
||||||
|
|
||||||
|
@param pad: The pad
|
||||||
|
@type pad: C{gst.Pad}
|
||||||
|
@param stream: The stream to match against.
|
||||||
|
@type stream: L{MultimediaStream}
|
||||||
|
@return: Whether the pad is compatible with the given stream
|
||||||
|
@rtype: C{bool}
|
||||||
|
"""
|
||||||
|
if stream == None:
|
||||||
|
# yes, None is the magical stream that takes everything
|
||||||
|
return True
|
||||||
|
# compatible caps
|
||||||
|
if stream.caps:
|
||||||
|
return not stream.caps.intersect(pad.get_caps()).is_empty()
|
||||||
|
raise Exception("Can't figure out compatibility since the stream doesn't have any caps")
|
||||||
|
|
||||||
class CachedFactoryList(object):
|
class CachedFactoryList(object):
|
||||||
def __init__(self, factoryFilter=None):
|
def __init__(self, factoryFilter=None):
|
||||||
self._factoryFilter = factoryFilter
|
self._factoryFilter = factoryFilter
|
||||||
|
|
|
@ -21,8 +21,9 @@ from video import Video
|
||||||
|
|
||||||
|
|
||||||
class Timeline(Video):
|
class Timeline(Video):
|
||||||
|
lastPos=0
|
||||||
def __init__(self, uri):
|
def __init__(self, uri):
|
||||||
Video.__init__(self, uri)
|
Video.__init__(self, uri, '25/1')
|
||||||
|
|
||||||
bus = self.get_bus()
|
bus = self.get_bus()
|
||||||
bus.add_signal_watch()
|
bus.add_signal_watch()
|
||||||
|
@ -63,10 +64,6 @@ class Timeline(Video):
|
||||||
def done(self):
|
def done(self):
|
||||||
self.mainloop.quit()
|
self.mainloop.quit()
|
||||||
|
|
||||||
def _sbinPadAddedCb(self, unused_sbin, pad):
|
|
||||||
self.log("pad : %s" % pad)
|
|
||||||
pad.link(self.csp.get_pad("sink"))
|
|
||||||
|
|
||||||
def _frameCb(self, unused_thsink, frame, timestamp):
|
def _frameCb(self, unused_thsink, frame, timestamp):
|
||||||
self.log("image:%s, timestamp:%s" % (frame, gst.TIME_ARGS(timestamp)))
|
self.log("image:%s, timestamp:%s" % (frame, gst.TIME_ARGS(timestamp)))
|
||||||
|
|
||||||
|
@ -74,13 +71,15 @@ class Timeline(Video):
|
||||||
# we know we're prerolled when we get the initial thumbnail
|
# we know we're prerolled when we get the initial thumbnail
|
||||||
self._ready = True
|
self._ready = True
|
||||||
else:
|
else:
|
||||||
framePos = int(math.ceil((float(timestamp) / (gst.SECOND) * float(self.framerate))))
|
_framePos = int(math.ceil((float(timestamp) / (gst.SECOND) * float(self.framerate))))
|
||||||
tile = int(math.floor(float(framePos) / self.input_tile_width))
|
for framePos in range(self.lastPos, _framePos):
|
||||||
tilePos = framePos - (tile * self.input_tile_width)
|
tile = int(math.floor(float(framePos) / self.input_tile_width))
|
||||||
frame = frame.resize((1, self.tile_height), Image.ANTIALIAS)
|
tilePos = framePos - (tile * self.input_tile_width)
|
||||||
for i in range(self.tile_height):
|
frame = frame.resize((1, self.tile_height), Image.ANTIALIAS)
|
||||||
self.tiles[tile].putpixel((tilePos, i), frame.getpixel((0, i)))
|
for i in range(self.tile_height):
|
||||||
|
self.tiles[tile].putpixel((tilePos, i), frame.getpixel((0, i)))
|
||||||
|
|
||||||
|
self.lastPos = _framePos
|
||||||
if self.mainloop and timestamp >= self.duration:
|
if self.mainloop and timestamp >= self.duration:
|
||||||
self.done()
|
self.done()
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ from imagesink import ImageSink
|
||||||
|
|
||||||
class Video(gst.Pipeline):
|
class Video(gst.Pipeline):
|
||||||
|
|
||||||
def __init__(self, uri):
|
def __init__(self, uri, framerate='25/1'):
|
||||||
gst.Pipeline.__init__(self)
|
gst.Pipeline.__init__(self)
|
||||||
self.duration = -1
|
self.duration = -1
|
||||||
# queue of timestamps
|
# queue of timestamps
|
||||||
|
@ -37,10 +37,16 @@ class Video(gst.Pipeline):
|
||||||
self.sbin = SingleDecodeBin(caps=gst.Caps("video/x-raw-rgb;video/x-raw-yuv"),
|
self.sbin = SingleDecodeBin(caps=gst.Caps("video/x-raw-rgb;video/x-raw-yuv"),
|
||||||
uri=self.uri)
|
uri=self.uri)
|
||||||
self.csp = gst.element_factory_make("ffmpegcolorspace")
|
self.csp = gst.element_factory_make("ffmpegcolorspace")
|
||||||
|
self.rate = gst.element_factory_make("videorate")
|
||||||
|
self.queue = gst.element_factory_make("queue")
|
||||||
|
|
||||||
self.sink = ImageSink()
|
self.sink = ImageSink()
|
||||||
self.sink.connect('frame', self._frameCb)
|
self.sink.connect('frame', self._frameCb)
|
||||||
|
|
||||||
self.add(self.sbin, self.csp, self.sink)
|
self.add(self.sbin, self.csp, self.queue, self.rate, self.sink)
|
||||||
|
|
||||||
|
self.queue.link(self.rate)
|
||||||
|
self.rate.link(self.csp, gst.Caps("video/x-raw-yuv,framerate=%s"%framerate))
|
||||||
self.csp.link(self.sink)
|
self.csp.link(self.sink)
|
||||||
|
|
||||||
self.sbin.connect('pad-added', self._sbinPadAddedCb)
|
self.sbin.connect('pad-added', self._sbinPadAddedCb)
|
||||||
|
@ -54,7 +60,7 @@ class Video(gst.Pipeline):
|
||||||
|
|
||||||
def _sbinPadAddedCb(self, unused_sbin, pad):
|
def _sbinPadAddedCb(self, unused_sbin, pad):
|
||||||
self.log("pad : %s" % pad)
|
self.log("pad : %s" % pad)
|
||||||
pad.link(self.csp.get_pad("sink"))
|
pad.link(self.queue.get_pad("sink"))
|
||||||
|
|
||||||
def _frameCb(self, unused_thsink, frame, timestamp):
|
def _frameCb(self, unused_thsink, frame, timestamp):
|
||||||
self.log("image:%s, timestamp:%s" % (frame, gst.TIME_ARGS(timestamp)))
|
self.log("image:%s, timestamp:%s" % (frame, gst.TIME_ARGS(timestamp)))
|
||||||
|
|
Loading…
Reference in a new issue