summaryrefslogtreecommitdiff
path: root/example-scripts/gstreamer/source-background-loop.py
diff options
context:
space:
mode:
Diffstat (limited to 'example-scripts/gstreamer/source-background-loop.py')
-rwxr-xr-xexample-scripts/gstreamer/source-background-loop.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/example-scripts/gstreamer/source-background-loop.py b/example-scripts/gstreamer/source-background-loop.py
index 8b65088..2f13edf 100755
--- a/example-scripts/gstreamer/source-background-loop.py
+++ b/example-scripts/gstreamer/source-background-loop.py
@@ -1,4 +1,5 @@
-import sys, gi, signal
+#!/usr/bin/env python3
+import os, sys, gi, signal
gi.require_version('Gst', '1.0')
from gi.repository import Gst, GObject
@@ -8,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')
@@ -52,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: