GstRtspServer.RTSPServer on Raspberry Pi [Python]

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

GstRtspServer.RTSPServer on Raspberry Pi [Python]

Vassiliev
Hello,

I want to stream video from my RPi's camera to my PC via Internet (Not local network). I found that I can use RTSP server for that reason.
Firstly I tried to stream RPi cam's video on the localhost via TCP, than server receives it and sharing (Or it just I thought that it will work like this) combining founded info. But nothing happend and I decided to sort out with server first.

The other problem is that my knowledge of C is pretty poor and I use Python, while 9 of 10 examples are on C. So, here is the code that should stream sample_video.mp4. Later I am going to change that line for rpicamsrc plugin.

#!/usr/bin/env python
import gi
gi.require_version('Gst', '1.0')
gi.require_version('GstRtspServer', '1.0')
from gi.repository import Gst, GObject, GstRtspServer
 
GObject.threads_init()
Gst.init(None)

class RTSP_Server:
    def __init__(self):
        self.server = GstRtspServer.RTSPServer.new()
        self.address = '192.168.1.13' #my RPi's local IP
        self.port = '8554'
        self.launch_description = '( playbin uri=file:///home/pi/sample_video.mp4 )'
       
        self.server.set_address(self.address)
        self.server.set_service(self.port)  
        self.factory = GstRtspServer.RTSPMediaFactory()
        self.factory.set_launch(self.launch_description)
        self.factory.set_shared(True)
        self.mount_points = self.server.get_mount_points()
        self.mount_points.add_factory('/video', self.factory)
       
        self.server.attach(None)  
        print('Stream ready')
        GObject.MainLoop().run()
             
       
server = RTSP_Server()

Then on PC I launch this gst-launch-1.0 -v rtspsrc location=rtsp://192.168.1.13:8554/video (Likely it is not full but I dont know what to write else). And get this:

C:\gstreamer\1.0\x86_64\bin>gst-launch-1.0 -v rtspsrc location=rtsp://192.168.1.
13:8554/video
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Progress: (open) Opening Stream
Progress: (connect) Connecting to rtsp://192.168.1.13:8554/video
Progress: (open) Retrieving server options
Progress: (open) Retrieving media info
ERROR: from element /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0: Could not get/se
t settings from/on resource.
Additional debug info:
gstrtspsrc.c(6845): gst_rtspsrc_setup_streams (): /GstPipeline:pipeline0/GstRTSP
Src:rtspsrc0:
SDP contains no streams
ERROR: pipeline doesn't want to preroll.
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...


So, guys, what should I do?
Thnx in advance,
Valeriy
Reply | Threaded
Open this post in threaded view
|

Re: GstRtspServer.RTSPServer on Raspberry Pi [Python]

saepia
Regarding language: you can give a try to Vala (http://live.gnome.org/Vala). It has Java-like syntax, but internally compiles down to C, producing fast native code, which may make sense in environments such as rpi. It has very good support for GStreamer and other libraries from GLib family.

In terms of your issue:

1) rtsp server: in order to pass data to the RTSP server, you have to end pipeline with RTP payloader, e.g. rtpopuspay with name payN where N is 0..n. Your current playbin call won't fit into this requirement.

2) receiver: try to play it with playbin or even gst-play-1.0 command first. Regardless of that, I think your pipeline lacks further elements after rtspsrc.

m.

2016-03-20 18:26 GMT+01:00 Vassiliev <[hidden email]>:
Hello,

I want to stream video from my RPi's camera to my PC via Internet (Not local
network). I found that I can use RTSP server for that reason.
Firstly I tried to stream RPi cam's video on the localhost via TCP, than
server receives it and sharing (Or it just I thought that it will work like
this) combining founded info. But nothing happend and I decided to sort out
with server first.

The other problem is that my knowledge of C is pretty poor and I use Python,
while 9 of 10 examples are on C. So, here is the code that should stream
sample_video.mp4. Later I am going to change that line for rpicamsrc plugin.

#!/usr/bin/env python
import gi
gi.require_version('Gst', '1.0')
gi.require_version('GstRtspServer', '1.0')
from gi.repository import Gst, GObject, GstRtspServer

GObject.threads_init()
Gst.init(None)

class RTSP_Server:
    def __init__(self):
        self.server = GstRtspServer.RTSPServer.new()
        self.address = '192.168.1.13' #my RPi's local IP
        self.port = '8554'
        self.launch_description = '( playbin
uri=file:///home/pi/sample_video.mp4 )'

        self.server.set_address(self.address)
        self.server.set_service(self.port)
        self.factory = GstRtspServer.RTSPMediaFactory()
        self.factory.set_launch(self.launch_description)
        self.factory.set_shared(True)
        self.mount_points = self.server.get_mount_points()
        self.mount_points.add_factory('/video', self.factory)

        self.server.attach(None)
        print('Stream ready')
        GObject.MainLoop().run()


server = RTSP_Server()

Then on PC I launch this gst-launch-1.0 -v rtspsrc
location=rtsp://192.168.1.13:8554/video (Likely it is not full but I dont
know what to write else). And get this:

C:\gstreamer\1.0\x86_64\bin>gst-launch-1.0 -v rtspsrc
location=rtsp://192.168.1.
13:8554/video
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Progress: (open) Opening Stream
Progress: (connect) Connecting to rtsp://192.168.1.13:8554/video
Progress: (open) Retrieving server options
Progress: (open) Retrieving media info
ERROR: from element /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0: Could not
get/se
t settings from/on resource.
Additional debug info:
gstrtspsrc.c(6845): gst_rtspsrc_setup_streams ():
/GstPipeline:pipeline0/GstRTSP
Src:rtspsrc0:
SDP contains no streams
ERROR: pipeline doesn't want to preroll.
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...


So, guys, what should I do?
Thnx in advance,
Valeriy



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/GstRtspServer-RTSPServer-on-Raspberry-Pi-Python-tp4676461.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: GstRtspServer.RTSPServer on Raspberry Pi [Python]

Vassiliev
Thank you for reply, saepia!

I've tried this two pipelines on the server:
'( playbin uri=file:///E:/Programs/Python/Gstreamer/sample_video.mp4 ! h264parse ! rtph264pay name=pay0 pt=96 )'
'( playbin uri=file:///E:/Programs/Python/Gstreamer/sample_video.mp4 ! rtpmp4vpay name=pay0 pt=96 )'

And on client I launch this:
gst-launch-1.0 -v playbin uri=rtsp://192.168.1.19:8554/video

Firstly, first frame of the video opens and I get this:
Setting pipeline to PAUSED ...
/GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0: ring-buffer-max-size = 0
/GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0: buffer-size = -1
/GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0: buffer-duration = -1
/GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0: use-buffering = false
/GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0: download = false
/GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0: uri = rtsp://192.168.1.19:85
54/video
/GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0: connection-speed = 0
/GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0: source = "\(GstRTSPSrc\)\ so
urce"
Pipeline is live and does not need PREROLL ...
Progress: (open) Opening Stream
Progress: (connect) Connecting to rtsp://192.168.1.19:8554/video
Progress: (open) Retrieving server options
Progress: (open) Retrieving media info

And after about 15 secs it closes and this error prints:
ERROR: from element /GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0/GstRTSPSr
c:source: Could not read from resource.
Additional debug info:
gstrtspsrc.c(5893): gst_rtspsrc_try_send (): /GstPlayBin:playbin0/GstURIDecodeBi
n:uridecodebin0/GstRTSPSrc:source:
Could not receive message. (Timeout while waiting for server response)
ERROR: pipeline doesn't want to preroll.
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...
What's the problem now?
Reply | Threaded
Open this post in threaded view
|

Re: GstRtspServer.RTSPServer on Raspberry Pi [Python]

saepia
You improperly use playbin in the RSTP server, it's not suited for such linking. Try to use filesrc and then link appopriate parse/decoder/whatever you want and end with payloader.

m.

2016-03-25 18:30 GMT+01:00 Vassiliev <[hidden email]>:
Thank you for reply, saepia!

I've tried this two pipelines on the server:
'( playbin uri=file:///E:/Programs/Python/Gstreamer/sample_video.mp4 !
h264parse ! rtph264pay name=pay0 pt=96 )'
'( playbin uri=file:///E:/Programs/Python/Gstreamer/sample_video.mp4 !
rtpmp4vpay name=pay0 pt=96 )'

And on client I launch this:
gst-launch-1.0 -v playbin uri=rtsp://192.168.1.19:8554/video

Firstly, first frame of the video opens and I get this:
Setting pipeline to PAUSED ...
/GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0: ring-buffer-max-size = 0
/GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0: buffer-size = -1
/GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0: buffer-duration = -1
/GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0: use-buffering = false
/GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0: download = false
/GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0: uri =
rtsp://192.168.1.19:85
54/video
/GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0: connection-speed = 0
/GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0: source =
"\(GstRTSPSrc\)\ so
urce"
Pipeline is live and does not need PREROLL ...
Progress: (open) Opening Stream
Progress: (connect) Connecting to rtsp://192.168.1.19:8554/video
Progress: (open) Retrieving server options
Progress: (open) Retrieving media info

And after about 15 secs it closes and this error prints:
ERROR: from element
/GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0/GstRTSPSr
c:source: Could not read from resource.
Additional debug info:
gstrtspsrc.c(5893): gst_rtspsrc_try_send ():
/GstPlayBin:playbin0/GstURIDecodeBi
n:uridecodebin0/GstRTSPSrc:source:
Could not receive message. (Timeout while waiting for server response)
ERROR: pipeline doesn't want to preroll.
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...
What's the problem now?



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/GstRtspServer-RTSPServer-on-Raspberry-Pi-Python-tp4676461p4676561.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: GstRtspServer.RTSPServer on Raspberry Pi [Python]

Tim Müller
In reply to this post by Vassiliev
On Fri, 2016-03-25 at 10:30 -0700, Vassiliev wrote:

> I've tried this two pipelines on the server:
> '( playbin uri=file:///E:/Programs/Python/Gstreamer/sample_video.mp4
> !
> h264parse ! rtph264pay name=pay0 pt=96 )'
> '( playbin uri=file:///E:/Programs/Python/Gstreamer/sample_video.mp4
> !
> rtpmp4vpay name=pay0 pt=96 )'

Perhaps have a look at the test-uri example application in the gst-
rtsp-server examples directory. It uses gst-rtsp-server to stream a
file over RTSP.

Cheers
 -Tim

--
Tim Müller, Centricular Ltd - http://www.centricular.com


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: GstRtspServer.RTSPServer on Raspberry Pi [Python]

Vassiliev
In reply to this post by saepia
Thanks saepia and Tim Müller!

Pipeline '( filesrc location=E:/Programs/Python/Gstreamer/sample_video.mp4 ! decodebin ! x264enc ! rtph264pay name=pay0 pt=96 )' works as it should with gst-launch-1.0 -v playbin uri=rtsp://192.168.1.19:8554/video
Reply | Threaded
Open this post in threaded view
|

Re: GstRtspServer.RTSPServer on Raspberry Pi [Python]

Krutskikh Ivan
In reply to this post by Vassiliev

I can help you with python and gstrtsp server tomorrow. I have a working example

20 марта 2016 г. 20:56 пользователь "Vassiliev" <[hidden email]> написал:
Hello,

I want to stream video from my RPi's camera to my PC via Internet (Not local
network). I found that I can use RTSP server for that reason.
Firstly I tried to stream RPi cam's video on the localhost via TCP, than
server receives it and sharing (Or it just I thought that it will work like
this) combining founded info. But nothing happend and I decided to sort out
with server first.

The other problem is that my knowledge of C is pretty poor and I use Python,
while 9 of 10 examples are on C. So, here is the code that should stream
sample_video.mp4. Later I am going to change that line for rpicamsrc plugin.

#!/usr/bin/env python
import gi
gi.require_version('Gst', '1.0')
gi.require_version('GstRtspServer', '1.0')
from gi.repository import Gst, GObject, GstRtspServer

GObject.threads_init()
Gst.init(None)

class RTSP_Server:
    def __init__(self):
        self.server = GstRtspServer.RTSPServer.new()
        self.address = '192.168.1.13' #my RPi's local IP
        self.port = '8554'
        self.launch_description = '( playbin
uri=file:///home/pi/sample_video.mp4 )'

        self.server.set_address(self.address)
        self.server.set_service(self.port)
        self.factory = GstRtspServer.RTSPMediaFactory()
        self.factory.set_launch(self.launch_description)
        self.factory.set_shared(True)
        self.mount_points = self.server.get_mount_points()
        self.mount_points.add_factory('/video', self.factory)

        self.server.attach(None)
        print('Stream ready')
        GObject.MainLoop().run()


server = RTSP_Server()

Then on PC I launch this gst-launch-1.0 -v rtspsrc
location=rtsp://192.168.1.13:8554/video (Likely it is not full but I dont
know what to write else). And get this:

C:\gstreamer\1.0\x86_64\bin>gst-launch-1.0 -v rtspsrc
location=rtsp://192.168.1.
13:8554/video
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Progress: (open) Opening Stream
Progress: (connect) Connecting to rtsp://192.168.1.13:8554/video
Progress: (open) Retrieving server options
Progress: (open) Retrieving media info
ERROR: from element /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0: Could not
get/se
t settings from/on resource.
Additional debug info:
gstrtspsrc.c(6845): gst_rtspsrc_setup_streams ():
/GstPipeline:pipeline0/GstRTSP
Src:rtspsrc0:
SDP contains no streams
ERROR: pipeline doesn't want to preroll.
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...


So, guys, what should I do?
Thnx in advance,
Valeriy



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/GstRtspServer-RTSPServer-on-Raspberry-Pi-Python-tp4676461.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: GstRtspServer.RTSPServer on Raspberry Pi [Python]

Vassiliev
Cool, I am interested to see it
Reply | Threaded
Open this post in threaded view
|

Re: GstRtspServer.RTSPServer on Raspberry Pi [Python]

Vassiliev
This post was updated on .
In reply to this post by saepia
Now I've tried to launch it on Raspberry Pi with pipelines:
'( videotestsrc pattern=smpte is-live=1 ! video/x-raw, width=1280, height=720 ! decodebin ! x264enc ! rtph264pay pt=96 name=pay0 )'
'( videotestsrc pattern=smpte is-live=1 ! video/x-raw, width=1280, height=720 ! x264enc ! rtph264pay pt=96 name=pay0 )'
'( filesrc location=/home/pi/sample_video.mp4 ! decodebin ! x264enc ! rtph264pay pt=96 name=pay0 )'
And also without self.factory.set_transport_mode(GstRtspServer.RTSPTransportMode.PLAY) because I received an error, that MediaFactory doesn't have a method set_transport_mode, while on PC it works correct.

Receiving this stream with
gst-launch-1.0 -v playbin uri=rtsp://192.168.1.13:8554/video
gst-launch-1.0 -v rtspsrc location=rtsp://192.168.1.13:8554/video ! rtph264depay ! avdec_h264 ! videoconvert ! autovideosink
throws me into error after 15 seconds? like when I used playbin in RTSP:

ERROR: from element /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0: Could not read f
rom resource.
Additional debug info:
gstrtspsrc.c(5893): gst_rtspsrc_try_send (): /GstPipeline:pipeline0/GstRTSPSrc:r
tspsrc0:
Could not receive message. (Timeout while waiting for server response)