Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/glive.py
diff options
context:
space:
mode:
authorDaniel Drake <dsd@laptop.org>2010-04-22 17:38:44 (GMT)
committer Daniel Drake <dan@reactivated.net>2010-04-29 14:49:26 (GMT)
commite41dbf9b0a4df7fcdb1b7e7996ad185b648158bc (patch)
treebc472f741e14c832be5f5013972148df484447ac /glive.py
parent85dde2f620eae56e8559ef700b6af71ead7a0c9e (diff)
Recording tweaks
Remove queue element in videobin, this makes recorded videos smoother Prefer fresh frames for A/V display Add a buffer in audiobin to avoid overrun/underrun problems when starting recording, avoiding some kind of bug where A/V sync is bad for the whole video.
Diffstat (limited to 'glive.py')
-rw-r--r--glive.py25
1 files changed, 17 insertions, 8 deletions
diff --git a/glive.py b/glive.py
index 7a02d1e..09e82bf 100644
--- a/glive.py
+++ b/glive.py
@@ -121,20 +121,25 @@ class Glive:
src = gst.element_factory_make("alsasrc", "absrc")
srccaps = gst.Caps("audio/x-raw-int,rate=16000,channels=1,depth=16")
+ # without a buffer here, gstreamer struggles at the start of the
+ # recording and then the A/V sync is bad for the whole video
+ # (possibly a gstreamer/ALSA bug -- even if it gets caught up, it
+ # should be able to resync without problem)
+ queue = gst.element_factory_make("queue")
+ queue.set_property("leaky", True) # prefer fresh data
+
enc = gst.element_factory_make("wavenc", "abenc")
sink = gst.element_factory_make("filesink", "absink")
sink.set_property("location", os.path.join(Instance.instancePath, "output.wav"))
self.audiobin = gst.Bin("audiobin")
- self.audiobin.add(src, enc, sink)
+ self.audiobin.add(src, queue, enc, sink)
- src.link(enc, srccaps)
- enc.link(sink)
+ src.link(queue, srccaps)
+ gst.element_link_many(queue, enc, sink)
def createVideoBin ( self ):
- queue = gst.element_factory_make("queue", "vbqueue")
-
scale = gst.element_factory_make("videoscale", "vbscale")
scalecapsfilter = gst.element_factory_make("capsfilter", "scalecaps")
@@ -153,14 +158,13 @@ class Glive:
sink.set_property("location", os.path.join(Instance.instancePath, "output.ogg"))
self.videobin = gst.Bin("videobin")
- self.videobin.add(queue, scale, scalecapsfilter, colorspace, enc, mux, sink)
+ self.videobin.add(scale, scalecapsfilter, colorspace, enc, mux, sink)
- queue.link(scale)
scale.link_pads(None, scalecapsfilter, "sink")
scalecapsfilter.link_pads("src", colorspace, None)
gst.element_link_many(colorspace, enc, mux, sink)
- pad = queue.get_static_pad("sink")
+ pad = scale.get_static_pad("sink")
self.videobin.add_pad(gst.GhostPad("sink", pad))
def cfgVideoBin (self, quality, width, height):
@@ -182,6 +186,11 @@ class Glive:
tee = gst.element_factory_make("tee", "tee")
queue = gst.element_factory_make("queue", "dispqueue")
+
+ # prefer fresh frames
+ queue.set_property("leaky", True)
+ queue.set_property("max-size-buffers", 2)
+
self.pipeline.add(src, rate, tee, queue)
src.link(rate)
rate.link(tee, ratecaps)