From 0d9bd9f868b70fadb30dc761e22002b0f5c28b36 Mon Sep 17 00:00:00 2001 From: Daniel Drake Date: Mon, 11 Aug 2008 17:53:47 +0000 Subject: Wait for EOS before ending video recording This avoids the last few frames being chopped off and is one step needed to fix the recording of multiple videos. --- diff --git a/glive.py b/glive.py index bb584fe..ae7480c 100644 --- a/glive.py +++ b/glive.py @@ -43,6 +43,7 @@ class Glive: def __init__(self, pca): self.window = None self.ca = pca + self._eos_cb = None self.playing = False self.picExposureOpen = False @@ -366,6 +367,11 @@ class Glive: # while we are adjusting the pipeline to stop recording. If we do # it on-the-fly, the following video live feed to the screen becomes # several seconds delayed. Weird! + self._eos_cb = self.stopRecordingVideoEOS + self.pipeline.get_by_name('camsrc').send_event(gst.event_new_eos()) + self.audiobin.get_by_name('absrc').send_event(gst.event_new_eos()) + + def stopRecordingVideoEOS(self): self.pipeline.set_state(gst.STATE_NULL) self.pipeline.get_by_name("tee").unlink(self.videobin) self.pipeline.remove(self.videobin) @@ -492,8 +498,10 @@ class Glive: def _onMessageCb(self, bus, message): t = message.type if t == gst.MESSAGE_EOS: - #print("MESSAGE_EOS") - pass + if self._eos_cb: + cb = self._eos_cb + self._eos_cb = None + cb() elif t == gst.MESSAGE_ERROR: #todo: if we come out of suspend/resume with errors, then get us back up and running... #todo: handle "No space left on the resource.gstfilesink.c" -- cgit v0.9.1