Live Video Streaming to Server

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

Live Video Streaming to Server

strange_loop
Hi, I have some devices(like rpi) that I want them to stream to a server and
I want to show the stream in a server/website from browser.
This seemed fairly simple at first but as I go through some examples I get
more confused.

simply:
device(s) stream to server and clients watch this streams

My first approach was setup an rtsp server, which I failed to understand.
Is this exactly what rtsp servers do.  
I am looking for advice on how to do that.

Also, I want to use webrtc stuff. Can I connect rtsp servers with webrtc, if
so what gstwebrtc is for.

Thanks!







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

Re: Live Video Streaming to Server

yair
the easiest stream i got was using hlssink,
  gst-launch-1.0 videotestsrc is-live=true ! x264enc ! mpegtsmux \
  ! hlssink playlist-root=https://your-site.org \
  location=/srv/hls/hlssink.%05d.ts \
  playlist-location=/srv/hls/playlist.m3u8
and video.js on the other site

rtsp is black art. hard to find info.

On Wed, Apr 15, 2020 at 2:24 PM strange_loop <[hidden email]> wrote:

>
> Hi, I have some devices(like rpi) that I want them to stream to a server and
> I want to show the stream in a server/website from browser.
> This seemed fairly simple at first but as I go through some examples I get
> more confused.
>
> simply:
> device(s) stream to server and clients watch this streams
>
> My first approach was setup an rtsp server, which I failed to understand.
> Is this exactly what rtsp servers do.
> I am looking for advice on how to do that.
>
> Also, I want to use webrtc stuff. Can I connect rtsp servers with webrtc, if
> so what gstwebrtc is for.
>
> Thanks!
>
>
>
>
>
>
>
> --
> Sent from: http://gstreamer-devel.966125.n4.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: Live Video Streaming to Server

strange_loop
Rtsp really felt like black art. I think it is an expertise on its own. Maybe
you need to be a dark lord to understand it :)

For the clarification, this pipeline streams video to the rtsp server and
video.js listens to it, right?

And would something like this be sufficient for the server?
https://github.com/GStreamer/gst-rtsp-server/blob/master/examples/test-video.c
or
https://github.com/GStreamer/gst-rtsp-server/blob/master/examples/test-video-rtx.c



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

Re: Live Video Streaming to Server

yair
the, videojs has hls (they call it vhs) built in.
like this. just adapt to your .m3u8 location, more here
https://videojs.github.io/http-streaming/

<video-js id=vid1 width=600 height=300 class="vjs-default-skin" controls>
  <source
     src="https://example.com/index.m3u8"
     type="application/x-mpegURL">
</video-js>
<script src="video.js"></script>
<script src="videojs-http-streaming.min.js"></script>
<script>
var player = videojs('vid1');
player.play();
</script>


didn't get to work on android for some reason,
i guess is "server issues" as i tried with caddy and not the good old nginx.


On Thu, Apr 16, 2020 at 4:31 PM strange_loop <[hidden email]> wrote:

>
> Rtsp really felt like black art. I think it is an expertise on its own. Maybe
> you need to be a dark lord to understand it :)
>
> For the clarification, this pipeline streams video to the rtsp server and
> video.js listens to it, right?
>
> And would something like this be sufficient for the server?
> https://github.com/GStreamer/gst-rtsp-server/blob/master/examples/test-video.c
> or
> https://github.com/GStreamer/gst-rtsp-server/blob/master/examples/test-video-rtx.c
>
>
>
> --
> Sent from: http://gstreamer-devel.966125.n4.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: Live Video Streaming to Server

Alexander Wolfe
I did this recently with nginx and RTMP, using videojs like Yair suggested. I put the details here: https://five381.com/blog/2020-03/rpi-camera-rtmp-streaming/

If you move the nginx server off of the pi to another host I think it will be what you want. That's what I'm doing right now actually.


On Thu, Apr 16, 2020 at 7:11 AM Yair Reshef <[hidden email]> wrote:
the, videojs has hls (they call it vhs) built in.
like this. just adapt to your .m3u8 location, more here
https://videojs.github.io/http-streaming/

<video-js id=vid1 width=600 height=300 class="vjs-default-skin" controls>
  <source
     src="https://example.com/index.m3u8"
     type="application/x-mpegURL">
</video-js>
<script src="video.js"></script>
<script src="videojs-http-streaming.min.js"></script>
<script>
var player = videojs('vid1');
player.play();
</script>


didn't get to work on android for some reason,
i guess is "server issues" as i tried with caddy and not the good old nginx.


On Thu, Apr 16, 2020 at 4:31 PM strange_loop <[hidden email]> wrote:
>
> Rtsp really felt like black art. I think it is an expertise on its own. Maybe
> you need to be a dark lord to understand it :)
>
> For the clarification, this pipeline streams video to the rtsp server and
> video.js listens to it, right?
>
> And would something like this be sufficient for the server?
> https://github.com/GStreamer/gst-rtsp-server/blob/master/examples/test-video.c
> or
> https://github.com/GStreamer/gst-rtsp-server/blob/master/examples/test-video-rtx.c
>
>
>
> --
> Sent from: http://gstreamer-devel.966125.n4.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

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

Re: Live Video Streaming to Server

yair
thanks alexander for the writeup,
afaiu the RTMP nginx mod is not needed in delivery of HLS context.

bonus link > https://caniuse.com/#search=hls


On Thu, Apr 16, 2020 at 7:22 PM Alexander Wolfe <[hidden email]> wrote:

>
> I did this recently with nginx and RTMP, using videojs like Yair suggested. I put the details here: https://five381.com/blog/2020-03/rpi-camera-rtmp-streaming/
>
> If you move the nginx server off of the pi to another host I think it will be what you want. That's what I'm doing right now actually.
>
>
>> On Thu, Apr 16, 2020 at 7:11 AM Yair Reshef <[hidden email]> wrote:
>>>
>>> the, videojs has hls (they call it vhs) built in.
>>> like this. just adapt to your .m3u8 location, more here
>>> https://videojs.github.io/http-streaming/
>>>
>>> <video-js id=vid1 width=600 height=300 class="vjs-default-skin" controls>
>>>   <source
>>>      src="https://example.com/index.m3u8"
>>>      type="application/x-mpegURL">
>>> </video-js>
>>> <script src="video.js"></script>
>>> <script src="videojs-http-streaming.min.js"></script>
>>> <script>
>>> var player = videojs('vid1');
>>> player.play();
>>> </script>
>>>
>>>
>>> didn't get to work on android for some reason,
>>> i guess is "server issues" as i tried with caddy and not the good old nginx.
>>>
>>>
>>> On Thu, Apr 16, 2020 at 4:31 PM strange_loop <[hidden email]> wrote:
>>> >
>>> > Rtsp really felt like black art. I think it is an expertise on its own. Maybe
>>> > you need to be a dark lord to understand it :)
>>> >
>>> > For the clarification, this pipeline streams video to the rtsp server and
>>> > video.js listens to it, right?
>>> >
>>> > And would something like this be sufficient for the server?
>>> > https://github.com/GStreamer/gst-rtsp-server/blob/master/examples/test-video.c
>>> > or
>>> > https://github.com/GStreamer/gst-rtsp-server/blob/master/examples/test-video-rtx.c
>>> >
>>> >
>>> >
>>> > --
>>> > Sent from: http://gstreamer-devel.966125.n4.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
>
> _______________________________________________
> 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: Live Video Streaming to Server

yair
ah you are using flv/rtmp.
some say its still the smoothest video around
does it play well on mobiles?

On Thu, Apr 16, 2020 at 9:53 PM Yair Reshef <[hidden email]> wrote:

>
> thanks alexander for the writeup,
> afaiu the RTMP nginx mod is not needed in delivery of HLS context.
>
> bonus link > https://caniuse.com/#search=hls
>
>
> On Thu, Apr 16, 2020 at 7:22 PM Alexander Wolfe <[hidden email]> wrote:
> >
> > I did this recently with nginx and RTMP, using videojs like Yair suggested. I put the details here: https://five381.com/blog/2020-03/rpi-camera-rtmp-streaming/
> >
> > If you move the nginx server off of the pi to another host I think it will be what you want. That's what I'm doing right now actually.
> >
> >
> >> On Thu, Apr 16, 2020 at 7:11 AM Yair Reshef <[hidden email]> wrote:
> >>>
> >>> the, videojs has hls (they call it vhs) built in.
> >>> like this. just adapt to your .m3u8 location, more here
> >>> https://videojs.github.io/http-streaming/
> >>>
> >>> <video-js id=vid1 width=600 height=300 class="vjs-default-skin" controls>
> >>>   <source
> >>>      src="https://example.com/index.m3u8"
> >>>      type="application/x-mpegURL">
> >>> </video-js>
> >>> <script src="video.js"></script>
> >>> <script src="videojs-http-streaming.min.js"></script>
> >>> <script>
> >>> var player = videojs('vid1');
> >>> player.play();
> >>> </script>
> >>>
> >>>
> >>> didn't get to work on android for some reason,
> >>> i guess is "server issues" as i tried with caddy and not the good old nginx.
> >>>
> >>>
> >>> On Thu, Apr 16, 2020 at 4:31 PM strange_loop <[hidden email]> wrote:
> >>> >
> >>> > Rtsp really felt like black art. I think it is an expertise on its own. Maybe
> >>> > you need to be a dark lord to understand it :)
> >>> >
> >>> > For the clarification, this pipeline streams video to the rtsp server and
> >>> > video.js listens to it, right?
> >>> >
> >>> > And would something like this be sufficient for the server?
> >>> > https://github.com/GStreamer/gst-rtsp-server/blob/master/examples/test-video.c
> >>> > or
> >>> > https://github.com/GStreamer/gst-rtsp-server/blob/master/examples/test-video-rtx.c
> >>> >
> >>> >
> >>> >
> >>> > --
> >>> > Sent from: http://gstreamer-devel.966125.n4.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
> >
> > _______________________________________________
> > 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: Live Video Streaming to Server

strange_loop
In reply to this post by yair
hls seems to be not supported in major browsers, however my problem is that
what is the role of the server is this scenario.
Like okey I used  pipeline and video.js but how does my stream reaches the
client, over internet? How does it distirubuted?

I am trying to create a mental model, so that I will know what tool serves
which purpose.

I am very new to streaming, I basically know very little about it.  




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

Re: Live Video Streaming to Server

yair
yep,  many issues
transcoding is the simple(~) step. you have control of your hardware.
but distribution, CDNs, multi-client detection of bandwidth and
processing capabilities.

without going into two-way and the sub 150ms latency humans demand.
i had the pleasure of sitting next to a conferencing heavy hitter,
requiring servers with 30k open ports to negotiate STUN/TURN and
tweaking freeswitch configs for weeks.
what a mess.

i suggest to start with requirements.
is this a LOLs project on a raspi and a 5$ docker node?
one2one, one2many (how many)?

not speaking as a pro. and would love any info you can gather on the subject
the scenarios are so verified and can get complex easily.
this is where 3rd party vendors, some of open source solutions, play a big part.
and CDNs offering turnkey solutions

black art




On Fri, Apr 17, 2020 at 11:30 AM strange_loop <[hidden email]> wrote:

>
> hls seems to be not supported in major browsers, however my problem is that
> what is the role of the server is this scenario.
> Like okey I used  pipeline and video.js but how does my stream reaches the
> client, over internet? How does it distirubuted?
>
> I am trying to create a mental model, so that I will know what tool serves
> which purpose.
>
> I am very new to streaming, I basically know very little about it.
>
>
>
>
> --
> Sent from: http://gstreamer-devel.966125.n4.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: Live Video Streaming to Server

Nicolas Dufresne-5
In reply to this post by strange_loop
Le jeudi 16 avril 2020 à 16:25 -0500, strange_loop a écrit :
> hls seems to be not supported in major browsers, however my problem is that

See https://github.com/video-dev/hls.js/ it's widely used for the
purpose. But indeed, HLS is not natively supported in browsers in
general as it's not part of the standard.

> what is the role of the server is this scenario.
> Like okey I used  pipeline and video.js but how does my stream reaches the
> client, over internet? How does it distirubuted?
>
> I am trying to create a mental model, so that I will know what tool serves
> which purpose.
>
> I am very new to streaming, I basically know very little about it.  

Streaming capabilities of browser is really poor in fact. That's mostly
because the browser offers very high level solution where normal OS
gives you low level UDP socket to play with.

In the case of HLS the flow is the following:

Server:
  - A server (your RPi) encode and mux into MPEG TS
  - It then split the MPEG TS in chunk and update a m3u8 playlist
  - Another server (e.g. nginx) picks these files from disk to make
them available to your browser

Browser:
  - The javascript will download though HTTP the m3u8 file and the MPEG
TS chunk
  - As MPEG TS is not supported by browser, it will transmux to
fragmented ISOMP4 (yes, in JavaScript!)
  - Is passes the chunk to the MSE JavaScript interface
  - That get decoded and played on screen (using a video tag)

If you use mpegsash, it's a bit lighter, since there is no transmuxing,
you need a JS library still. For video conferencing it's a bit complex,
but I'll keep it simple.

You need 2 peers, and web server. Potentially a STUN and/or TURN server
if the two peers have too restrictive network.

  1. Peers call each other through the web server
  2. They will use the web server to exchange some info:
    - Network candidates, for ICE negotiation (nat traversal protocol)
    - SDP to negotiate the transport and encoding
  3. When a "connection" is established things goes peer-to-peer
    - A DTLS connection is established (server no longer see what is
going on)
    - RTP and RTCP packets starts flowing

Of course, when you go into big conference, the server becomes your
peer so that it can do video and audio mixing. In that case, the server
can see everything that is going on.

In the old days, there was some "video streaming" that was using image
tags and refreshing it. I think this is still possible using JPEG
compression.

>
>
>
>
> --
> Sent from: http://gstreamer-devel.966125.n4.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: Live Video Streaming to Server

yair


On Fri, Apr 17, 2020 at 3:41 PM Nicolas Dufresne <[hidden email]> wrote:
Le jeudi 16 avril 2020 à 16:25 -0500, strange_loop a écrit :
> hls seems to be not supported in major browsers, however my problem is that

See https://github.com/video-dev/hls.js/ it's widely used for the
purpose. But indeed, HLS is not natively supported in browsers in
general as it's not part of the standard.

> what is the role of the server is this scenario.
> Like okey I used  pipeline and video.js but how does my stream reaches the
> client, over internet? How does it distirubuted?
>
> I am trying to create a mental model, so that I will know what tool serves
> which purpose.
>
> I am very new to streaming, I basically know very little about it. 

Streaming capabilities of browser is really poor in fact. That's mostly
because the browser offers very high level solution where normal OS
gives you low level UDP socket to play with.

In the case of HLS the flow is the following:

Server:
  - A server (your RPi) encode and mux into MPEG TS
  - It then split the MPEG TS in chunk and update a m3u8 playlist
  - Another server (e.g. nginx) picks these files from disk to make
them available to your browser

Browser:
  - The javascript will download though HTTP the m3u8 file and the MPEG
TS chunk
  - As MPEG TS is not supported by browser, it will transmux to
fragmented ISOMP4 (yes, in JavaScript!)
  - Is passes the chunk to the MSE JavaScript interface
  - That get decoded and played on screen (using a video tag)

If you use mpegsash, it's a bit lighter, since there is no transmuxing,
you need a JS library still. For video conferencing it's a bit complex,
but I'll keep it simple.

You need 2 peers, and web server. Potentially a STUN and/or TURN server
if the two peers have too restrictive network.

  1. Peers call each other through the web server
  2. They will use the web server to exchange some info:
    - Network candidates, for ICE negotiation (nat traversal protocol)
    - SDP to negotiate the transport and encoding
  3. When a "connection" is established things goes peer-to-peer
    - A DTLS connection is established (server no longer see what is
going on)
    - RTP and RTCP packets starts flowing

Of course, when you go into big conference, the server becomes your
peer so that it can do video and audio mixing. In that case, the server
can see everything that is going on.

In the old days, there was some "video streaming" that was using image
tags and refreshing it. I think this is still possible using JPEG
compression.

motion delivers such simple robust solution. 
brutforce and no audio 
but works on anything that can pull a jpeg from a server
 
 
>
>
>
>
> --
> Sent from: http://gstreamer-devel.966125.n4.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

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel