summaryrefslogtreecommitdiff
path: root/voctocore/experiments/videodisplay.py
blob: b8b7a86c45cc416a5e8b868990d321b54b69a8e4 (plain)
  1. #!/usr/bin/python3
  2. from gi.repository import GObject, Gst
  3. class VideomixerWithDisplay(Gst.Bin):
  4. def __init__(self):
  5. super().__init__()
  6. # Create elements
  7. self.secondsrc = Gst.ElementFactory.make('videotestsrc', None)
  8. self.mixer = Gst.ElementFactory.make('videomixer', None)
  9. self.ident = Gst.ElementFactory.make('identity', None)
  10. self.q1 = Gst.ElementFactory.make('queue', None)
  11. self.q2 = Gst.ElementFactory.make('queue', None)
  12. self.display = Gst.ElementFactory.make('ximagesink', None)
  13. # Add elements to Bin
  14. self.add(self.secondsrc)
  15. self.add(self.mixer)
  16. self.add(self.ident)
  17. self.add(self.display)
  18. self.add(self.q1)
  19. self.add(self.q2)
  20. # Set properties
  21. self.secondsrc.set_property('pattern', 'ball')
  22. self.ident.set_property('sync', True)
  23. self.display.set_property('sync', False)
  24. # Request Pads
  25. self.firstpad = self.mixer.get_request_pad('sink_%u')
  26. self.secondpad = self.mixer.get_request_pad('sink_%u')
  27. # Set pad-properties
  28. self.secondpad.set_property('alpha', 0.75)
  29. self.secondpad.set_property('xpos', 50)
  30. self.secondpad.set_property('ypos', 50)
  31. # Link elements
  32. self.q1.get_static_pad('src').link(self.firstpad)
  33. self.q2.get_static_pad('src').link(self.secondpad)
  34. self.secondsrc.link_filtered(self.ident, Gst.Caps.from_string('video/x-raw,width=400,height=400,framerate=25/1,format=RGBx'))
  35. self.ident.link(self.q2)
  36. self.mixer.link(self.display)
  37. # Add Ghost Pads
  38. self.add_pad(
  39. Gst.GhostPad.new('sink', self.q1.get_static_pad('sink'))
  40. )