summaryrefslogtreecommitdiff
path: root/example-scripts/gstreamer/source-background-loop.py
diff options
context:
space:
mode:
authorMaZderMind <git@mazdermind.de>2016-02-05 12:54:25 +0100
committerMaZderMind <git@mazdermind.de>2016-02-05 12:54:25 +0100
commit9ad4f83327c472a7119d105891416b8c9cc3cdd1 (patch)
treeb449059f073b2cfb8da9d016c58712cebae81857 /example-scripts/gstreamer/source-background-loop.py
parent5408b306ca699b3f8a64aaa1e5ae70ceecdfcd18 (diff)
honour the example-script config.sh in the py-source-files
Diffstat (limited to 'example-scripts/gstreamer/source-background-loop.py')
-rwxr-xr-xexample-scripts/gstreamer/source-background-loop.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/example-scripts/gstreamer/source-background-loop.py b/example-scripts/gstreamer/source-background-loop.py
index 79ffbad..2f13edf 100755
--- a/example-scripts/gstreamer/source-background-loop.py
+++ b/example-scripts/gstreamer/source-background-loop.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-import sys, gi, signal
+import os, sys, gi, signal
gi.require_version('Gst', '1.0')
from gi.repository import Gst, GObject
@@ -9,17 +9,18 @@ GObject.threads_init()
Gst.init([])
class LoopSource(object):
- def __init__(self):
+ def __init__(self, settings):
# it works much better with a local file
pipeline = """
uridecodebin name=src uri=http://c3voc.mazdermind.de/testfiles/bg.ts !
videoscale !
videoconvert !
- video/x-raw,format=I420,width=1920,height=1080,framerate=25/1,pixel-aspect-ratio=1/1 !
+ video/x-raw,format=I420,width={WIDTH},height={HEIGHT},framerate={FRAMERATE}/1,pixel-aspect-ratio=1/1 !
matroskamux !
tcpclientsink host=localhost port=16000
- """
+ """.format_map(settings)
+ print('starting pipeline '+pipeline)
self.senderPipeline = Gst.parse_launch(pipeline)
self.src = self.senderPipeline.get_by_name('src')
@@ -53,7 +54,13 @@ class LoopSource(object):
def main():
signal.signal(signal.SIGINT, signal.SIG_DFL)
- src = LoopSource()
+ config = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../config.sh')
+ with open(config, 'r') as config:
+ lines = [ line.strip() for line in config if line[0] != '#' ]
+ pairs = [ line.split('=', 1) for line in lines ]
+ settings = { pair[0]: pair[1] for pair in pairs }
+
+ src = LoopSource(settings)
mainloop = GObject.MainLoop()
try: