diff options
Diffstat (limited to 'voctocore')
-rwxr-xr-x | voctocore/experiments/sync-videomix.py | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/voctocore/experiments/sync-videomix.py b/voctocore/experiments/sync-videomix.py index 0f6e780..1e17a2e 100755 --- a/voctocore/experiments/sync-videomix.py +++ b/voctocore/experiments/sync-videomix.py @@ -17,11 +17,15 @@ class Example: pipeline = """ videotestsrc pattern=red ! {caps} ! + videoscale ! + capsfilter name=caps0 ! identity sync=true signal-handoffs=false ! mix. videotestsrc pattern=green ! {caps} ! + videoscale ! + capsfilter name=caps1 ! identity sync=true signal-handoffs=false ! mix. @@ -32,22 +36,47 @@ class Example: pngenc ! multifilesink location=frame%04d.png """.format( - caps='video/x-raw,height=450,width=800,format=I420,framerate=25/1' + caps='video/x-raw,width=800,height=450,format=I420,framerate=25/1' ) self.pipeline = Gst.parse_launch(pipeline) sig = self.pipeline.get_by_name('sig') sig.connect('handoff', self.handoff) - self.mix = self.pipeline.get_by_name('mix') - self.state = 0 + self.pad0 = self.pipeline.get_by_name('mix').get_static_pad('sink_0') + self.pad1 = self.pipeline.get_by_name('mix').get_static_pad('sink_1') + + self.caps0 = self.pipeline.get_by_name('caps0') + self.caps1 = self.pipeline.get_by_name('caps1') + + self.state = False def handoff(self, object, buffer): - mixerpad = self.mix.get_static_pad('sink_1') - print('handoff, alpha=%u' % self.state) - mixerpad.set_property('alpha', self.state) - self.state = 0 if self.state else 1 + if self.state: + padA = self.pad0 + padB = self.pad1 + capsA = self.caps0 + capsB = self.caps1 + else: + padA = self.pad1 + padB = self.pad0 + capsA = self.caps1 + capsB = self.caps0 + + padA.set_property('xpos', 10) + padA.set_property('ypos', 10) + padA.set_property('alpha', 1.0) + padA.set_property('zorder', 1) + capsA.set_property('caps', Gst.Caps.from_string('video/x-raw,width=400,height=225')) + + padB.set_property('xpos', 390) + padB.set_property('ypos', 215) + padB.set_property('alpha', 1.0) + padB.set_property('zorder', 2) + capsB.set_property('caps', Gst.Caps.from_string('video/x-raw,width=400,height=225')) + + self.state = not self.state def run(self): self.pipeline.set_state(Gst.State.PLAYING) |