diff options
-rw-r--r-- | .gitignore | 53 | ||||
-rw-r--r-- | README.md | 0 | ||||
-rw-r--r-- | voctocat/README.md | 0 | ||||
-rw-r--r-- | voctocat/controlserver.py | 4 | ||||
-rw-r--r-- | voctocat/videomix.py | 69 | ||||
-rwxr-xr-x | voctocat/voctocat.py | 25 | ||||
-rw-r--r-- | voctomix/README.md | 0 |
7 files changed, 151 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..efbe7aa --- /dev/null +++ b/.gitignore @@ -0,0 +1,53 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.cache +nosetests.xml +coverage.xml + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/README.md diff --git a/voctocat/README.md b/voctocat/README.md new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/voctocat/README.md diff --git a/voctocat/controlserver.py b/voctocat/controlserver.py new file mode 100644 index 0000000..8397705 --- /dev/null +++ b/voctocat/controlserver.py @@ -0,0 +1,4 @@ +class ControlServer: + + def __init__(self, videomix): + self.videomix = videomix diff --git a/voctocat/videomix.py b/voctocat/videomix.py new file mode 100644 index 0000000..895a25f --- /dev/null +++ b/voctocat/videomix.py @@ -0,0 +1,69 @@ +import sys, inspect +from pprint import pprint +from gi.repository import GLib, Gst + +class Videomix: + decoder = [] + mixerpads = [] + + def __init__(self): + self.pipeline = Gst.Pipeline() + + self.videomixer = Gst.ElementFactory.make('videomixer', 'videomixer') + self.pipeline.add(self.videomixer) + + for uri in ("http://video.blendertestbuilds.de/download.blender.org/ED/ED_1280.avi", "http://download.blender.org/durian/trailer/sintel_trailer-720p.mp4",): + decoder = Gst.ElementFactory.make('uridecodebin', 'uridecoder('+uri+')') + decoder.set_property("uri", uri) + decoder.connect("pad-added", self.OnDynamicPad) + self.pipeline.add(decoder) + self.decoder.append(decoder) + + self.monitorvideosink = Gst.ElementFactory.make('autovideosink', 'monitorvideosink') + self.pipeline.add(self.monitorvideosink) + self.videomixer.link(self.monitorvideosink) + + self.monitoraudiosink = Gst.ElementFactory.make('autoaudiosink', 'monitoraudiosink') + self.pipeline.add(self.monitoraudiosink) + + self.pipeline.set_state(Gst.State.PLAYING) + + GLib.io_add_watch(sys.stdin, GLib.IO_IN, self.Input) + + def Input(self, fd, condition): + if condition == GLib.IO_IN: + char = fd.readline() + try: + i = int(char.rstrip()) + print("settinh pad {0} to alpha=1".format(i)) + self.mixerpads[i].set_property('alpha', 1) + for idx, pad in enumerate(self.mixerpads): + if idx != i: + print("settinh pad {0} to alpha=0".format(idx)) + pad.set_property('alpha', 0) + except: + pass + + return True + else: + return False + + def OnDynamicPad(self, uridecodebin, src_pad): + caps = src_pad.query_caps(None).to_string() + srcname = uridecodebin.get_name() + print("{0}-source of {1} online".format(caps.split(',')[0], srcname)) + + if caps.startswith('audio/'): + sinkpad = self.monitoraudiosink.get_static_pad("sink") + + # link the first audio-stream and be done + if not sinkpad.is_linked(): + src_pad.link(sinkpad) + + else: + sinkpad = Gst.Element.get_request_pad(self.videomixer, "sink_%u") + src_pad.link(sinkpad) + self.mixerpads.append(sinkpad) + print('add', sinkpad) + sinkpad.set_property('alpha', 0.7) + diff --git a/voctocat/voctocat.py b/voctocat/voctocat.py new file mode 100755 index 0000000..5a56474 --- /dev/null +++ b/voctocat/voctocat.py @@ -0,0 +1,25 @@ +#!/usr/bin/python3 +import gi +import signal +from videomix import Videomix +from controlserver import ControlServer + +gi.require_version('Gst', '1.0') +from gi.repository import GLib, Gst, Gtk, GObject + + +class Main: + def __init__(self): + self.videomix = Videomix() + self.controlserver = ControlServer(self.videomix) + +def runmain(): + GObject.threads_init() + Gst.init(None) + + signal.signal(signal.SIGINT, signal.SIG_DFL) + start=Main() + Gtk.main() + +if __name__ == '__main__': + runmain() diff --git a/voctomix/README.md b/voctomix/README.md new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/voctomix/README.md |