aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xexample-scripts/gstreamer/source-background-loop.py17
-rwxr-xr-xexample-scripts/gstreamer/source-remote-desktop-as-cam1.py29
-rwxr-xr-xexample-scripts/gstreamer/source-remote-videotestsrc-as-cam1.py24
3 files changed, 44 insertions, 26 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:
diff --git a/example-scripts/gstreamer/source-remote-desktop-as-cam1.py b/example-scripts/gstreamer/source-remote-desktop-as-cam1.py
index 686cc73..7d1c7f2 100755
--- a/example-scripts/gstreamer/source-remote-desktop-as-cam1.py
+++ b/example-scripts/gstreamer/source-remote-desktop-as-cam1.py
@@ -1,5 +1,5 @@
#!/usr/bin/python3
-import sys, gi, signal
+import os, sys, gi, signal
import argparse, socket
gi.require_version('Gst', '1.0')
@@ -10,8 +10,7 @@ GObject.threads_init()
Gst.init([])
class Source(object):
- def __init__(self, ip):
- # it works much better with a local file
+ def __init__(self, settings):
pipeline = """
ximagesrc use-damage=0 startx=0 starty=0 endx=1919 endy=1079 !
queue !
@@ -19,28 +18,26 @@ class Source(object):
videorate !
timeoverlay !
videoconvert !
- video/x-raw,format=I420,width=1280,height=720,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 !
queue !
mux.
pulsesrc !
- audio/x-raw,format=S16LE,channels=2,layout=interleaved,rate=48000 !
+ audio/x-raw,format=S16LE,channels=2,layout=interleaved,rate={AUDIORATE} !
queue !
mux.
matroskamux name=mux !
- tcpclientsink host={ip} port=10000
- """.format(
- ip=ip
- )
+ tcpclientsink host={IP} port=10000
+ """.format_map(settings)
- self.clock = GstNet.NetClientClock.new('voctocore', ip, 9998, 0)
+ self.clock = GstNet.NetClientClock.new('voctocore', settings['IP'], 9998, 0)
print('obtained NetClientClock from host', self.clock)
print('waiting for NetClientClock to sync…')
self.clock.wait_for_sync(Gst.CLOCK_TIME_NONE)
- print('starting pipeline')
+ print('starting pipeline '+pipeline)
self.senderPipeline = Gst.parse_launch(pipeline)
self.senderPipeline.use_clock(self.clock)
self.src = self.senderPipeline.get_by_name('src')
@@ -79,7 +76,15 @@ def main():
print('Using IP '+addrs[0])
- src = Source(addrs[0])
+ config = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../config.sh')
+ with open(config) 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 }
+
+ settings['IP'] = addrs[0]
+
+ src = Source(settings)
mainloop = GObject.MainLoop()
try:
mainloop.run()
diff --git a/example-scripts/gstreamer/source-remote-videotestsrc-as-cam1.py b/example-scripts/gstreamer/source-remote-videotestsrc-as-cam1.py
index 70e838f..5404add 100755
--- a/example-scripts/gstreamer/source-remote-videotestsrc-as-cam1.py
+++ b/example-scripts/gstreamer/source-remote-videotestsrc-as-cam1.py
@@ -1,5 +1,5 @@
#!/usr/bin/python3
-import sys, gi, signal
+import os, sys, gi, signal
import argparse, socket
gi.require_version('Gst', '1.0')
@@ -10,7 +10,7 @@ GObject.threads_init()
Gst.init([])
class Source(object):
- def __init__(self, ip):
+ def __init__(self, settings):
# it works much better with a local file
pipeline = """
videotestsrc pattern=ball foreground-color=0x00ff0000 background-color=0x00440000 !
@@ -23,18 +23,16 @@ class Source(object):
mux.
matroskamux name=mux !
- tcpclientsink host={ip} port=10000
- """.format(
- ip=ip
- )
+ tcpclientsink host={IP} port=10000
+ """.format_map(settings)
- self.clock = GstNet.NetClientClock.new('voctocore', ip, 9998, 0)
+ self.clock = GstNet.NetClientClock.new('voctocore', settings['IP'], 9998, 0)
print('obtained NetClientClock from host', self.clock)
print('waiting for NetClientClock to sync…')
self.clock.wait_for_sync(Gst.CLOCK_TIME_NONE)
- print('starting pipeline')
+ print('starting pipeline '+pipeline)
self.senderPipeline = Gst.parse_launch(pipeline)
self.senderPipeline.use_clock(self.clock)
self.src = self.senderPipeline.get_by_name('src')
@@ -73,7 +71,15 @@ def main():
print('Using IP '+addrs[0])
- src = Source(addrs[0])
+ config = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../config.sh')
+ with open(config) 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 }
+
+ settings['IP'] = addrs[0]
+
+ src = Source(settings)
mainloop = GObject.MainLoop()
try:
mainloop.run()