summaryrefslogtreecommitdiff
path: root/voctocore/videomix.py
blob: 4ed9d25f12beb0438b4d9c2b13f8a5c632718056 (plain)
  1. import sys, inspect
  2. from pprint import pprint
  3. from gi.repository import GLib, Gst
  4. class Videomix:
  5. decoder = []
  6. mixerpads = []
  7. def __init__(self):
  8. self.pipeline = Gst.parse_launch("""
  9. videomixer name=livevideo ! autovideosink
  10. input-selector name=liveaudio ! autoaudiosink
  11. """)
  12. uris = ('file:///home/peter/122.mp4', 'file:///home/peter/10025.mp4',)
  13. for idx, uri in enumerate(uris):
  14. # create a bin for camera input
  15. camberabin = Gst.parse_bin_from_description("""
  16. uridecodebin name=input
  17. input. ! videoconvert ! videoscale ! videorate ! video/x-raw,width=1024,height=576,framerate=25/1 ! identity name=video_src
  18. input. ! audioconvert name=audio_src
  19. """, False)
  20. # configure camera input
  21. camberabin.get_by_name('input').set_property('uri', uri)
  22. # add to pipeline and link to mixers
  23. self.pipeline.add(camberabin)
  24. camberabin.get_by_name('video_src').link(self.pipeline.get_by_name('livevideo'))
  25. camberabin.get_by_name('audio_src').link(self.pipeline.get_by_name('liveaudio'))
  26. # demonstrate some control
  27. liveaudio = self.pipeline.get_by_name('liveaudio')
  28. liveaudio.set_property('active-pad', liveaudio.get_static_pad('sink_0'))
  29. livevideo = self.pipeline.get_by_name('livevideo')
  30. pad = livevideo.get_static_pad('sink_1')
  31. pad.set_property('alpha', 0.5)
  32. self.pipeline.set_state(Gst.State.PLAYING)