From 757572f64d10172341b60191dcbfe7ba280bd286 Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Wed, 27 Jan 2016 12:36:12 +0100 Subject: add source-example with network-time client --- ...source-videotestsrc-as-cam1-with-networktime.py | 68 ++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100755 example-scripts/gstreamer/source-videotestsrc-as-cam1-with-networktime.py (limited to 'example-scripts') diff --git a/example-scripts/gstreamer/source-videotestsrc-as-cam1-with-networktime.py b/example-scripts/gstreamer/source-videotestsrc-as-cam1-with-networktime.py new file mode 100755 index 0000000..cf3870c --- /dev/null +++ b/example-scripts/gstreamer/source-videotestsrc-as-cam1-with-networktime.py @@ -0,0 +1,68 @@ +#!/usr/bin/python3 +import sys, gi, signal + +gi.require_version('Gst', '1.0') +from gi.repository import Gst, GstNet, GObject + +# init GObject & Co. before importing local classes +GObject.threads_init() +Gst.init([]) + +class Source(object): + def __init__(self): + # it works much better with a local file + pipeline = """ + videotestsrc pattern=ball foreground-color=0x00ff0000 background-color=0x00440000 !\ + timeoverlay ! + video/x-raw,format=I420,width=192,height=108,framerate=25/1,pixel-aspect-ratio=1/1 !\ + mux. \ + \ + audiotestsrc freq=330 !\ + audio/x-raw,format=S16LE,channels=2,layout=interleaved,rate=48000 !\ + mux. \ + \ + matroskamux name=mux !\ + tcpclientsink host=127.0.0.1 port=10000 + """ + + clock = Gst.SystemClock.obtain() + self.clock = GstNet.NetClientClock.new('voctocore', '127.0.0.1', 9998, clock.get_time()) + print('obtained NetClientClock from host', self.clock) + + self.senderPipeline = Gst.parse_launch(pipeline) + self.senderPipeline.use_clock(self.clock) + self.src = self.senderPipeline.get_by_name('src') + + # Binding End-of-Stream-Signal on Source-Pipeline + self.senderPipeline.bus.add_signal_watch() + self.senderPipeline.bus.connect("message::eos", self.on_eos) + self.senderPipeline.bus.connect("message::error", self.on_error) + + print("playing") + self.senderPipeline.set_state(Gst.State.PLAYING) + + + def on_eos(self, bus, message): + print('Received EOS-Signal') + sys.exit(1) + + def on_error(self, bus, message): + print('Received Error-Signal') + (error, debug) = message.parse_error() + print('Error-Details: #%u: %s' % (error.code, debug)) + sys.exit(1) + +def main(): + signal.signal(signal.SIGINT, signal.SIG_DFL) + + src = Source() + + mainloop = GObject.MainLoop() + try: + mainloop.run() + except KeyboardInterrupt: + print('Terminated via Ctrl-C') + + +if __name__ == '__main__': + main() -- cgit v1.2.3 From 6bc0e4f5733c2abb6aaf85bb3e0ec2cab4322a7c Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Thu, 28 Jan 2016 11:19:43 +0100 Subject: remove unnecessary slashes --- .../source-videotestsrc-as-cam1-with-networktime.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'example-scripts') diff --git a/example-scripts/gstreamer/source-videotestsrc-as-cam1-with-networktime.py b/example-scripts/gstreamer/source-videotestsrc-as-cam1-with-networktime.py index cf3870c..63ee180 100755 --- a/example-scripts/gstreamer/source-videotestsrc-as-cam1-with-networktime.py +++ b/example-scripts/gstreamer/source-videotestsrc-as-cam1-with-networktime.py @@ -12,16 +12,16 @@ class Source(object): def __init__(self): # it works much better with a local file pipeline = """ - videotestsrc pattern=ball foreground-color=0x00ff0000 background-color=0x00440000 !\ + videotestsrc pattern=ball foreground-color=0x00ff0000 background-color=0x00440000 ! timeoverlay ! - video/x-raw,format=I420,width=192,height=108,framerate=25/1,pixel-aspect-ratio=1/1 !\ - mux. \ - \ - audiotestsrc freq=330 !\ - audio/x-raw,format=S16LE,channels=2,layout=interleaved,rate=48000 !\ - mux. \ - \ - matroskamux name=mux !\ + video/x-raw,format=I420,width=192,height=108,framerate=25/1,pixel-aspect-ratio=1/1 ! + mux. + + audiotestsrc freq=330 ! + audio/x-raw,format=S16LE,channels=2,layout=interleaved,rate=48000 ! + mux. + + matroskamux name=mux ! tcpclientsink host=127.0.0.1 port=10000 """ -- cgit v1.2.3 From 60e205cb92e7127742b42ff0e5c0bbc06df1d0e5 Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Thu, 28 Jan 2016 11:21:52 +0100 Subject: fix example resolution --- .../gstreamer/source-videotestsrc-as-cam1-with-networktime.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'example-scripts') diff --git a/example-scripts/gstreamer/source-videotestsrc-as-cam1-with-networktime.py b/example-scripts/gstreamer/source-videotestsrc-as-cam1-with-networktime.py index 63ee180..b07bf55 100755 --- a/example-scripts/gstreamer/source-videotestsrc-as-cam1-with-networktime.py +++ b/example-scripts/gstreamer/source-videotestsrc-as-cam1-with-networktime.py @@ -14,7 +14,7 @@ class Source(object): pipeline = """ videotestsrc pattern=ball foreground-color=0x00ff0000 background-color=0x00440000 ! timeoverlay ! - video/x-raw,format=I420,width=192,height=108,framerate=25/1,pixel-aspect-ratio=1/1 ! + video/x-raw,format=I420,width=1920,height=1080,framerate=25/1,pixel-aspect-ratio=1/1 ! mux. audiotestsrc freq=330 ! -- cgit v1.2.3 From c64ce93a9f2a85bcaafe8fddf1b591f1ba618d32 Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Thu, 28 Jan 2016 11:22:26 +0100 Subject: wait until clock-sync --- .../gstreamer/source-videotestsrc-as-cam1-with-networktime.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'example-scripts') diff --git a/example-scripts/gstreamer/source-videotestsrc-as-cam1-with-networktime.py b/example-scripts/gstreamer/source-videotestsrc-as-cam1-with-networktime.py index b07bf55..441a129 100755 --- a/example-scripts/gstreamer/source-videotestsrc-as-cam1-with-networktime.py +++ b/example-scripts/gstreamer/source-videotestsrc-as-cam1-with-networktime.py @@ -25,10 +25,13 @@ class Source(object): tcpclientsink host=127.0.0.1 port=10000 """ - clock = Gst.SystemClock.obtain() - self.clock = GstNet.NetClientClock.new('voctocore', '127.0.0.1', 9998, clock.get_time()) + self.clock = GstNet.NetClientClock.new('voctocore', '127.0.0.1', 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') self.senderPipeline = Gst.parse_launch(pipeline) self.senderPipeline.use_clock(self.clock) self.src = self.senderPipeline.get_by_name('src') -- cgit v1.2.3 From 23fdb289436d792557227ec4d445636b2808de2d Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Thu, 28 Jan 2016 12:27:27 +0100 Subject: rename source and make hostname a parameter --- .../source-remote-videotestsrc-as-cam1.py | 85 ++++++++++++++++++++++ ...source-videotestsrc-as-cam1-with-networktime.py | 71 ------------------ 2 files changed, 85 insertions(+), 71 deletions(-) create mode 100755 example-scripts/gstreamer/source-remote-videotestsrc-as-cam1.py delete mode 100755 example-scripts/gstreamer/source-videotestsrc-as-cam1-with-networktime.py (limited to 'example-scripts') diff --git a/example-scripts/gstreamer/source-remote-videotestsrc-as-cam1.py b/example-scripts/gstreamer/source-remote-videotestsrc-as-cam1.py new file mode 100755 index 0000000..70e838f --- /dev/null +++ b/example-scripts/gstreamer/source-remote-videotestsrc-as-cam1.py @@ -0,0 +1,85 @@ +#!/usr/bin/python3 +import sys, gi, signal +import argparse, socket + +gi.require_version('Gst', '1.0') +from gi.repository import Gst, GstNet, GObject + +# init GObject & Co. before importing local classes +GObject.threads_init() +Gst.init([]) + +class Source(object): + def __init__(self, ip): + # it works much better with a local file + pipeline = """ + videotestsrc pattern=ball foreground-color=0x00ff0000 background-color=0x00440000 ! + timeoverlay ! + video/x-raw,format=I420,width=1280,height=720,framerate=25/1,pixel-aspect-ratio=1/1 ! + mux. + + audiotestsrc freq=330 ! + audio/x-raw,format=S16LE,channels=2,layout=interleaved,rate=48000 ! + mux. + + matroskamux name=mux ! + tcpclientsink host={ip} port=10000 + """.format( + ip=ip + ) + + self.clock = GstNet.NetClientClock.new('voctocore', 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') + self.senderPipeline = Gst.parse_launch(pipeline) + self.senderPipeline.use_clock(self.clock) + self.src = self.senderPipeline.get_by_name('src') + + # Binding End-of-Stream-Signal on Source-Pipeline + self.senderPipeline.bus.add_signal_watch() + self.senderPipeline.bus.connect("message::eos", self.on_eos) + self.senderPipeline.bus.connect("message::error", self.on_error) + + print("playing") + self.senderPipeline.set_state(Gst.State.PLAYING) + + + def on_eos(self, bus, message): + print('Received EOS-Signal') + sys.exit(1) + + def on_error(self, bus, message): + print('Received Error-Signal') + (error, debug) = message.parse_error() + print('Error-Details: #%u: %s' % (error.code, debug)) + sys.exit(1) + +def main(): + signal.signal(signal.SIGINT, signal.SIG_DFL) + + parser = argparse.ArgumentParser(description='Voctocore Remote-Source') + parser.add_argument('host') + + args = parser.parse_args() + print('Resolving hostname '+args.host) + addrs = [ str(i[4][0]) for i in socket.getaddrinfo(args.host, None) ] + if len(addrs) == 0: + print('Found no IPs') + sys.exit(1) + + print('Using IP '+addrs[0]) + + src = Source(addrs[0]) + mainloop = GObject.MainLoop() + try: + mainloop.run() + except KeyboardInterrupt: + print('Terminated via Ctrl-C') + + +if __name__ == '__main__': + main() diff --git a/example-scripts/gstreamer/source-videotestsrc-as-cam1-with-networktime.py b/example-scripts/gstreamer/source-videotestsrc-as-cam1-with-networktime.py deleted file mode 100755 index 441a129..0000000 --- a/example-scripts/gstreamer/source-videotestsrc-as-cam1-with-networktime.py +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/python3 -import sys, gi, signal - -gi.require_version('Gst', '1.0') -from gi.repository import Gst, GstNet, GObject - -# init GObject & Co. before importing local classes -GObject.threads_init() -Gst.init([]) - -class Source(object): - def __init__(self): - # it works much better with a local file - pipeline = """ - videotestsrc pattern=ball foreground-color=0x00ff0000 background-color=0x00440000 ! - timeoverlay ! - video/x-raw,format=I420,width=1920,height=1080,framerate=25/1,pixel-aspect-ratio=1/1 ! - mux. - - audiotestsrc freq=330 ! - audio/x-raw,format=S16LE,channels=2,layout=interleaved,rate=48000 ! - mux. - - matroskamux name=mux ! - tcpclientsink host=127.0.0.1 port=10000 - """ - - self.clock = GstNet.NetClientClock.new('voctocore', '127.0.0.1', 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') - self.senderPipeline = Gst.parse_launch(pipeline) - self.senderPipeline.use_clock(self.clock) - self.src = self.senderPipeline.get_by_name('src') - - # Binding End-of-Stream-Signal on Source-Pipeline - self.senderPipeline.bus.add_signal_watch() - self.senderPipeline.bus.connect("message::eos", self.on_eos) - self.senderPipeline.bus.connect("message::error", self.on_error) - - print("playing") - self.senderPipeline.set_state(Gst.State.PLAYING) - - - def on_eos(self, bus, message): - print('Received EOS-Signal') - sys.exit(1) - - def on_error(self, bus, message): - print('Received Error-Signal') - (error, debug) = message.parse_error() - print('Error-Details: #%u: %s' % (error.code, debug)) - sys.exit(1) - -def main(): - signal.signal(signal.SIGINT, signal.SIG_DFL) - - src = Source() - - mainloop = GObject.MainLoop() - try: - mainloop.run() - except KeyboardInterrupt: - print('Terminated via Ctrl-C') - - -if __name__ == '__main__': - main() -- cgit v1.2.3 From 95f72ae9ff3f616484000e30e8d6a0f1b273ff6d Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Thu, 28 Jan 2016 13:06:20 +0100 Subject: add an example streaming live-video-content from a remote-location --- .../gstreamer/source-remote-desktop-as-cam1.py | 91 ++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100755 example-scripts/gstreamer/source-remote-desktop-as-cam1.py (limited to 'example-scripts') diff --git a/example-scripts/gstreamer/source-remote-desktop-as-cam1.py b/example-scripts/gstreamer/source-remote-desktop-as-cam1.py new file mode 100755 index 0000000..686cc73 --- /dev/null +++ b/example-scripts/gstreamer/source-remote-desktop-as-cam1.py @@ -0,0 +1,91 @@ +#!/usr/bin/python3 +import sys, gi, signal +import argparse, socket + +gi.require_version('Gst', '1.0') +from gi.repository import Gst, GstNet, GObject + +# init GObject & Co. before importing local classes +GObject.threads_init() +Gst.init([]) + +class Source(object): + def __init__(self, ip): + # it works much better with a local file + pipeline = """ + ximagesrc use-damage=0 startx=0 starty=0 endx=1919 endy=1079 ! + queue ! + videoscale ! + videorate ! + timeoverlay ! + videoconvert ! + video/x-raw,format=I420,width=1280,height=720,framerate=25/1,pixel-aspect-ratio=1/1 ! + queue ! + mux. + + pulsesrc ! + audio/x-raw,format=S16LE,channels=2,layout=interleaved,rate=48000 ! + queue ! + mux. + + matroskamux name=mux ! + tcpclientsink host={ip} port=10000 + """.format( + ip=ip + ) + + self.clock = GstNet.NetClientClock.new('voctocore', 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') + self.senderPipeline = Gst.parse_launch(pipeline) + self.senderPipeline.use_clock(self.clock) + self.src = self.senderPipeline.get_by_name('src') + + # Binding End-of-Stream-Signal on Source-Pipeline + self.senderPipeline.bus.add_signal_watch() + self.senderPipeline.bus.connect("message::eos", self.on_eos) + self.senderPipeline.bus.connect("message::error", self.on_error) + + print("playing") + self.senderPipeline.set_state(Gst.State.PLAYING) + + + def on_eos(self, bus, message): + print('Received EOS-Signal') + sys.exit(1) + + def on_error(self, bus, message): + print('Received Error-Signal') + (error, debug) = message.parse_error() + print('Error-Details: #%u: %s' % (error.code, debug)) + sys.exit(1) + +def main(): + signal.signal(signal.SIGINT, signal.SIG_DFL) + + parser = argparse.ArgumentParser(description='Voctocore Remote-Source') + parser.add_argument('host') + + args = parser.parse_args() + print('Resolving hostname '+args.host) + addrs = [ str(i[4][0]) for i in socket.getaddrinfo(args.host, None) ] + if len(addrs) == 0: + print('Found no IPs') + sys.exit(1) + + print('Using IP '+addrs[0]) + + src = Source(addrs[0]) + mainloop = GObject.MainLoop() + try: + mainloop.run() + except KeyboardInterrupt: + print('Terminated via Ctrl-C') + + +if __name__ == '__main__': + main() -- cgit v1.2.3