From 9ad4f83327c472a7119d105891416b8c9cc3cdd1 Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Fri, 5 Feb 2016 12:54:25 +0100 Subject: honour the example-script config.sh in the py-source-files --- example-scripts/gstreamer/source-background-loop.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'example-scripts/gstreamer/source-background-loop.py') 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: -- cgit v1.2.3