summaryrefslogtreecommitdiff
path: root/voctocore/experiments/videodisplay.py
blob: 57087da1b589914a2963470fbf04f1c364fecb13 (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.conv = Gst.ElementFactory.make('videoconvert', None)
  11. self.q1 = Gst.ElementFactory.make('queue', None)
  12. self.q2 = Gst.ElementFactory.make('queue', None)
  13. self.display = Gst.ElementFactory.make('ximagesink', None)
  14. # Add elements to Bin
  15. self.add(self.secondsrc)
  16. self.add(self.mixer)
  17. self.add(self.ident)
  18. self.add(self.conv)
  19. self.add(self.display)
  20. self.add(self.q1)
  21. self.add(self.q2)
  22. # Set properties
  23. self.secondsrc.set_property('pattern', 'ball')
  24. self.ident.set_property('sync', True)
  25. self.display.set_property('sync', False)
  26. # Request Pads
  27. self.firstpad = self.mixer.get_request_pad('sink_%u')
  28. self.secondpad = self.mixer.get_request_pad('sink_%u')
  29. # Set pad-properties
  30. self.secondpad.set_property('alpha', 0.75)
  31. self.secondpad.set_property('xpos', 50)
  32. self.secondpad.set_property('ypos', 50)
  33. # Link elements
  34. self.q1.get_static_pad('src').link(self.firstpad)
  35. self.q2.get_static_pad('src').link(self.secondpad)
  36. self.secondsrc.link_filtered(self.ident, Gst.Caps.from_string('video/x-raw,format=BGRA,width=400,height=400,framerate=25/1'))
  37. self.ident.link(self.q2)
  38. self.mixer.link(self.conv)
  39. self.conv.link(self.display)
  40. # Add Ghost Pads
  41. self.add_pad(
  42. Gst.GhostPad.new('sink', self.q1.get_static_pad('sink'))
  43. )