summaryrefslogtreecommitdiff
path: root/voctocore/lib/video/mix.py
blob: 8bb7036fcb7caf32ee0d196e635545857373f9f7 (plain)
  1. #!/usr/bin/python3
  2. import logging
  3. from gi.repository import Gst
  4. from lib.config import Config
  5. class VideoMix(object):
  6. log = logging.getLogger('VideoMix')
  7. mixingPipeline = None
  8. def __init__(self):
  9. caps = Config.get('mix', 'videocaps')
  10. names = Config.getlist('sources', 'video')
  11. self.log.info('Configuring Mixer for %u Sources', len(names))
  12. pipeline = """
  13. videomixer name=mix !
  14. {caps} !
  15. textoverlay text=mixer halignment=left valignment=top ypad=175 !
  16. intervideosink channel=video_mix
  17. """.format(
  18. caps=caps
  19. )
  20. for idx, name in enumerate(names):
  21. pipeline += """
  22. intervideosrc channel=video_{name}_mixer !
  23. {caps} !
  24. videoscale !
  25. capsfilter name=caps_{idx} !
  26. mix.
  27. """.format(
  28. name=name,
  29. caps=caps,
  30. idx=idx
  31. )
  32. self.log.debug('Launching Mixing-Pipeline:\n%s', pipeline)
  33. self.mixingPipeline = Gst.parse_launch(pipeline)
  34. self.mixingPipeline.set_state(Gst.State.PLAYING)
  35. mixerpad = self.mixingPipeline.get_by_name('mix').get_static_pad('sink_0')
  36. mixerpad.set_property('alpha', 0.5)
  37. mixerpad.set_property('xpos', 64)
  38. mixerpad.set_property('ypos', 64)
  39. mixerpad = self.mixingPipeline.get_by_name('mix').get_static_pad('sink_1')
  40. mixerpad.set_property('alpha', 0.2)
  41. capsilter = self.mixingPipeline.get_by_name('caps_1')
  42. capsilter.set_property('caps', Gst.Caps.from_string(
  43. 'video/x-raw,width=320,height=180'))