[FFmpeg-user] Setup a rtmps server with nginx + ffmpeg.

Hongyi Zhao hongyi.zhao at gmail.com
Thu Jan 14 17:30:29 EET 2021


On Thu, Jan 14, 2021 at 3:20 PM Vic Mortelmans <vicmortelmans at gmail.com> wrote:
>
> Hi HY,
>
> looks like you should be ok. Did you give it a try?

Till now, I only tried to stream a local mp4 media file to nginx rtmp
server and replay the stream simultaneously. The steps are shown
below:

1. Start the self-compiled nginx rtmp server with the following
settings appended at the end of the default
/usr/local/nginx/conf/nginx.conf:

rtmp {
    server {
        listen 1935;

        application live {
            live on;
        }
    }
}

2. Publishing a Stream via FFMPEG:
$ ffmpeg -re -i in.mp4 -c copy -f flv "rtmp://127.0.0.1:1935/live"

3. Pull the steam with vlc:
 Fill out the following URL in "vlc --> Media --> Open Network Stream"
and click on the play button:

rtmp://127.0.0.1:1935/live

> What will be the use?

Currently, I'm participating in a remote driverless car monitoring
system, which utilize the camera installed on the car to capture the
real-time state of the surrounding environment and transfer it to the
monitoring device located remotely. The platform installed on the car
is an embedded Linux distribution, say, Raspberry Pi.

I plan to do this with the following ideas: ffmpeg is used to capture
the camera device and then rtmp(s)/hls protocols are used to publish
the stream to the rtmp(s)/hls server supplied by nginx running on a
cloud based VPS. On the remote client/monitoring side, we can access
the nginx server by a rtmp(s)/hls capable client software/browser,
e.g. VLC/Firefox/Chrome for real time monitoring.


> Will the server be receiving RTMP, or rather sending out?

I think it should do the both simultaneously.

> What will it be connected to?

See the detailed description of the above-mentioned project background.

> I've been doing an nginx + ffmpeg RTMP setup myself very recently and I
> published my notes here:
> https://gelovenleren.net/blog/raspberry-pi-broadcaster-diy/

Wonderful notes and valuable experiences. Thanks a lot for sharing it
with me. But I still have a question on your notes, to be more
specific, I think for the rtmps/hls protocols, the stream URLs should
look like "rtmp://" and "hls://". But I don't know how to setup these
type of nginx based streaming servers. Furthermore, I also learned
that rtmps ptotocol is not supported by nginx rtmp module currently as
told by the notes give by
<https://dev.to/lax/rtmps-relay-with-stunnel-12d3>:

Unfortunately nginx-rtmp-module doesn't support replaying to an
rtmps:// address, and the feature is not supposed be added in a recent
release.
There's an issue nginx-rtmp-module#1397 discussing about this.


> I've been through a lot of trial and error, though!

Thanks again for your hard work and due diligence. I will make further
attempts according to your notes and give the necessary feedback.

Best regards
HY
-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao at gmail.com>
Theory and Simulation of Materials
Hebei Polytechnic University of Science and Technology engineering
NO. 552 North Gangtie Road, Xingtai, China


More information about the ffmpeg-user mailing list