[SCM] morituri/master: * morituri/extern/task/gstreamer.py: Query using time if DEFAULT fails.
js at users.alioth.debian.org
js at users.alioth.debian.org
Sun Oct 19 20:09:35 UTC 2014
The following commit has been merged in the master branch:
commit ba3dd85dc54381ba792ee71f426a2900e44d3d9a
Author: Thomas Vander Stichele <thomas (at) apestaart (dot) org>
Date: Thu Sep 15 14:23:25 2011 +0000
* morituri/extern/task/gstreamer.py:
Query using time if DEFAULT fails.
diff --git a/ChangeLog b/ChangeLog
index 84d511d..e28eb45 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2011-09-15 Thomas Vander Stichele <thomas at apestaart dot org>
+ * morituri/extern/task/gstreamer.py:
+ Query using time if DEFAULT fails.
+
+2011-09-15 Thomas Vander Stichele <thomas at apestaart dot org>
+
* morituri/common/program.py:
Add Musicbrainz command.
diff --git a/morituri/extern/task/gstreamer.py b/morituri/extern/task/gstreamer.py
index 071ed79..1fa7491 100644
--- a/morituri/extern/task/gstreamer.py
+++ b/morituri/extern/task/gstreamer.py
@@ -223,16 +223,43 @@ class GstPipelineTask(task.Task):
try:
duration, qformat = element.query_duration(self.gst.FORMAT_DEFAULT)
except self.gst.QueryError, e:
- self.setException(e)
- # schedule it, otherwise runner can get set to None before
- # we're done starting
- self.schedule(0, self.stop)
- return
+ # Fall back to time; for example, oggdemux/vorbisdec only supports
+ # TIME
+ try:
+ duration, qformat = element.query_duration(self.gst.FORMAT_TIME)
+ except self.gst.QueryError, e:
+ self.setException(e)
+ # schedule it, otherwise runner can get set to None before
+ # we're done starting
+ self.schedule(0, self.stop)
+ return
# wavparse 0.10.14 returns in bytes
if qformat == self.gst.FORMAT_BYTES:
self.debug('query returned in BYTES format')
duration /= 4
+
+ if qformat == self.gst.FORMAT_TIME:
+ rate = None
+ self.debug('query returned in TIME format')
+ # we need sample rate
+ pads = list(element.pads())
+ sink = element.get_by_name('sink')
+ pads += list(sink.pads())
+
+ for pad in pads:
+ caps = pad.get_negotiated_caps()
+ print caps[0].keys()
+ if 'rate' in caps[0].keys():
+ rate = caps[0]['rate']
+ self.debug('Sample rate: %d Hz', rate)
+
+ if not rate:
+ raise KeyError(
+ 'Cannot find sample rate, cannot convert to samples')
+
+ duration = int(float(rate) * (float(duration) / self.gst.SECOND))
+
self.debug('total duration: %r', duration)
return duration
--
morituri packaging
More information about the pkg-multimedia-commits
mailing list