How to install ffmpeg on a VPS server in 2021?

Short explanation.

How can I install ffmpeg on VPS?

That is a great question and the answer can be found below in the long version. That’s where you’ll find complete instructions on the installation of ffmpeg on your own virtual private server.

What is a good VPS web hosting provider for ffmpeg in 2021?

We use Linux Hosts Inc. for ffmpeg and we never had a real problem. Our server is a VPS with Ubuntu installed. You can find them here.

Read more.

Do you like to know more about this subject? Here are a few related articles. Happy reading!

 

Long explanation.

Own live streaming server setup (ffmpeg on a VPS) instructions.

There is some documentation on this setup shown on Youtube. Often the instructions are incomplete or the necessary information is missing. After extensive research and reading into the topic, I made this setup. Many thanks to the open source community for doing an endless amount of preparatory work.

Requirements for the installation on Ubuntu VPS:

  • VLC media player
  • OBS Open Broadcast Software
  • Zip unpacker
  • VPS Linux operating system used here Ubuntu 18.03.

These instructions are to be carried out step by step. The following requirements are required for the installation.

  • Basic knowledge of the Ubuntu operating system
  • Using a simple text editor (HTML)

Before installing, you should bring your system up to date.

1. With the key combination [Ctrl] + [Alt] + [T] you open the console and enter the following command line. Enter your password and press [Enter]. Press [J] to perform the update.

$ sudo apt-get update && sudo apt-get dist-upgrade

2. The following necessary tools are to be installed next like this:

$ sudo apt-get install build-essential libpcre3 libpcre3-dev libssl-dev

3. Download the enginx (pronounced “engine-X”) web server. It is currently one of the most powerful web servers.

$ wget http://nginx.org/download/nginx-1.18.0.tar.gz

4. Download sources for the RTMP module

$ wget https://github.com/sergey-dryabzhinsky/nginx-rtmp-module/archive/dev.zip

5. Unzip and change to the server directory

$ tar -zxvf nginx-1.18.0.tar.gz
$ unzip dev.zip
$ cd /nginx-1.18.0

6. Create and install the nginx server with the integrated RTMP module.

$ ./configure –with-http_ssl_module –add-module = .. / nginx-rtmp-module-dev
$ make
$ sudo make install

7. Create the necessary directory structure for the fragments of the video stream.

$ sudo mkdir / HLS
$ sudo mkdir / HLS / live
$ sudo mkdir / HLS / mobile
$ sudo mkdir / video_recordings
$ sudo chmod -R 777 / video_recordings

If Ubuntu VPS is operated with a firewall (default is off), the following rule must be inserted.

$ sudo ufw allow 80
$ sudo ufw allow 1935 sudo
$ ufw enable

8. The server is installed in the standard directory: / usr / local / nginx and will now be started. Open the browser and enter http: // <your ip address> / or “localhost”. The start page of the server appears. (The IP address of the server is output via the $ ifconfig command.)

Server start with:

$ sudo / usr / local / nginx / sbin / nginx

Stop the server with:

$ sudo / usr / local / nginx / sbin / nginx -s stop

9. Install FFmpeg to convert and package the stream.

$ sudo apt-get install software-properties-common
$ sudo add-apt-repository ppa: kirillshkrogalev / ffmpeg-next

10. Update and install the package list

$ sudo apt-get update
$ sudo apt-get install ffmpeg

11. Configure the server beforehand and save the original configuration file “nginx.conf”.

$ sudo cp /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.original
$ sudo nano /usr/local/nginx/conf/nginx.conf

12. Copy (overwrite) and save the entire content in the existing “nginx.conf” file. The placeholders “my-ip” have to be replaced with the IP address of your server. Example: 192.168.254.178
For “my-stream-key”, use your freely invented key e.g. tuy31nevyqz9.

worker_processes 1;
error_log logs / error.log debug;
events {
worker_connections 1024;
}
rtmp {
server {
lists 1935;
allow play all;

#creates our “live” full-resolution HLS videostream from our incoming encoder stream and tells where to put the HLS video manifest and video fragments
application live {
allow play all;
live on;
record all;
record_path / video_recordings;
record_unique on;
hls on;
hls_nested on;
hls_path / HLS / live;
hls_fragment 10s;

#creates the downsampled or “trans-rated” mobile video stream as a 400kbps, 480×360 sized video
exec ffmpeg -i rtmp: // my-ip: 1935 / $ app / $ name -acodec copy -c: v libx264 -preset veryfast -profile: v baseline -vsync cfr -s 480×360 -b: v 400k maxrate 400k -bufsize 400k -threads 0 -r 30 -f flv rtmp: // my-ip: 1935 / mobile / $;
}

#creates our “mobile” lower-resolution HLS videostream from the ffmpeg-created stream and tells where to put the HLS video manifest and video fragments
application mobile {
allow play all;
live on;
hls on;
hls_nested on;
hls_path / HLS / mobile;
hls_fragment 10s;
}

#allows you to play your recordings of your live streams using a URL like “rtmp: // my-ip: 1935 / vod / filename.flv”
application vod {
play / video_recordings;
}
}
}

http {
include mime.types;
default_type application / octet-stream;

server {
listen 80;
server_name my-ip;

#creates the http-location for our full-resolution (desktop) HLS stream – “http: //my-ip/live/mein-stream-key/index.m3u8”
location / live {
types {
application / vnd.apple.mpegurl m3u8;
}
alias / HLS / live;
add_header Cache-Control no-cache;
}

#creates the http-location for our mobile-device HLS stream – “http: //my-ip/mobile/mein-stream-key/index.m3u8”
location / mobile {
types {
application / vnd.apple.mpegurl m3u8;
}
alias / HLS / mobile;
add_header Cache-Control no-cache;
}

#allows us to see how stats on viewers on our Nginx site using a URL like: “http: // my-ip / stats”
location / stats {
stub_status;
}

#allows us to host some webpages which can show our videos: “http: //my-ip/my-page.html”
location / {
root html;
index index.html index.htm;
}
}
}

13. Start the program OBS (Open Broadcast Studio) and leave the standard settings, except for the entry “URL” and “Stream Key”

Encoder-x264
Variable bit rate (not CBR or Constant Bit Rate), quality highest
Max bit rate-600kbps
Audio Codec AAC
Audio format-44.1khz
Audio bitrate -64kbps
URL “rtmp: // your-ip: 1935 / live”
Stream Key- “my-stream-key”
Resolution-640×480
FPS (frames per second) -30
CFR (Constant Frame Rate) – Yes
Keyframe interval-2 seconds (one keyframe every 2 seconds)
x264 Encoding Profile-baseline (may work with main — depends on player used)
x264 CPU Present-veryfast

a) Select a video source in OBS, e.g. webcam
b) press the button “start streaming”

Result: The label on the button changes to “Stop streaming” and the transfer rate is displayed in the lower status line.

14. Now a test with the VLC media player follows. The menu item of the VLC, “Open media / network stream” and enter the following address:

http: //my-ip/live/mein-stream-key/index.m3u8

If everything went well, the VLC player shows your stream. Congratulations!

15. Embed stream in a website with the media player “Video.js”.

a) Download the video.js player and unzip it in the / usr / local / nginx / html directory.

b) Create the following HTML page with the name e.g. “my-index.html” in the above-mentioned directory.

<! DOCTYPE html>
<html>
<head>
<meta charset = utf-8 />
<title> Welcome to my streaming site! </title>
<link href = “/ video-js.css” rel = “stylesheet”>
<script src = “/ video.js”> </script>
<script src = “/ videojs-contrib-hls.js”> </script>
<script> var player = videojs (‘example-video’);
player.play ();
</script>
</head>

<body>

<video poster = “/ logo.png” id = “example-video” class = “video-js vjs-default-skin” controls preload = “auto” width = “640” height = “268” data-setup = ‘ {} ‘>

<source src = “http: //my-ip/live/mein-streamkey/test.m3u8” type = “application / x-mpegURL”>
<p class = “vjs-no-js”> To view this video please enable JavaScript, and consider upgrading to a web browser that
<a href=”http://videojs.com/html5-video-support/” target=”_blank”> supports HTML5 video </a> </p>
</video>

</body>
</html>

16. Call up the created website in the browser:

http: //my-ip/my-index.html

The website appears with the inserted live player.

Congratulations! You worked with concentration and precision and now you have your own live streaming server.

Further helpful pages for the setup I described:

https://obsproject.com/forum/resources/how-to-set-up-your-own-private-rtmp-server-using-nginx.50/

https://www.vultr.com/docs/setup-nginx-on-Ubuntu-to-stream-live-hls-video

https://www.vultr.com/docs/setup-nginx-rtmp-on-Ubuntu-14-04

Comments: 74 thoughts on how to install ffmpeg on your VPS.

Bernfried Grosse-Venhaus
June 4, 2021 at 1:49 PM

Hello Richard!

I’m almost there, too: When the live feed starts, I can see the videos live with a more or less time delay with the corresponding URL on the PC, tablet and mobile phone in the browser. Happy !! The aim of my RTMP server is that authorized persons can watch the video of a fire brigade copter, which is also working on a test basis within my home network. RTMP transmission is available in the copter control software / app and also works. According to the Config, the videos are saved in the video_recordings directory. The FFmpeg videos are deleted after the RTMP live streaming.
Now I would like to make the content of the permanently stored videos available for selection on the same website and also offer it encoded using FFmpeg. As with the live stream.
If I understand the principle correctly, the stored videos in the video_ recordings directory on the website would have to be transferred to FFmpeg. Are there any ideas and code that I can use?

Thanks and Greetings
Bernie

Darko
May 16, 2021 at 2:13 am

Hello Richard

that was a great guide. I worked with Linux for the first time and everything worked out great. A few things didn’t work out, but I checked with Google and it worked. So now to my problems. i can access the stream from the local network anywhere and stream it from any pc via obs to nginx, but i can’t come from outside (internet) on the server. So from my smartphone (mobile data) I cannot see the stream although I have cleared the port for nginx 1935 in my mikrotik router (TCP) I may have to enter the static ip in the conf file instead of the local ip or agree something the port forwarding not? However, I have to say that I have a shoutcast server running on another pc and have opened port 8000 and it works great there, why does it not work here, is it a setting point or because it is running on a virtual machine. I thank you in advance for your answer.

Bernie
April 27, 2021 at 5:04 pm

Hello Richard!

Compliments on the instructions!
I have two questions: Do the instructions also apply to the installation on a Raspi 4? I read your answer from June 9th, 2020, but maybe the 4 is potent enough? Do you need a license key for video processing? There was something about a Raspi video recorder project …How do I get it so that I can display and select the saved video files via web browser and play them in the Broswer? Thanks for hints!

Richard Detering
April 28, 2021 at 8:32 am

Dear Bernie,

thank you for your questions!
For video processing, the more computing power, the better. There are no upper limits, “A lot helps a lot”! .-) Sure, that would be a great solution with the Raspberry Pi 4 B, but with 4x 1.5 GHz, 4 GB RAM, the single-board computer is not designed for a streaming server. BTW – I love RASPIs

License keys are not needed on the live streaming server, you may mean the codecs. If they are not installed on the server, that should be done. Of course, it depends on the format or quality in which you want to make your stream available to your audience.

In the configuration file you can set whether your live stream should be recorded. In this case, the path or the URL of the cloud must also be specified. An archive is then created and this can be operated like a media library.

I wish you a lot of fun with the setup!

TBF
April 14, 2021 at 12:31 PM

Unfortunately I have the problem that in VLC the picture freezes every few seconds, then runs again for a few seconds what can be the reason?

Sven K
February 23, 2021 at 2:07 am

Hey, unfortunately my installation is unsuccessful. The “make” command cannot be executed. The following error occurs: make: *** No rule to make target ‘build’, needed by ‘default’. Stop. The whole thing should be installed on a KVM server with Ubuntu 18.04.5 LTS. At first I thought it was due to a faulty installation, but a 2nd and 3rd attempt also failed.
I hope someone can help me solve the problem. best regards
Sven

Sasha
May 1, 2021 at 9:12 PM

The same error occurred with me. Is there a solution ?

Markus
January 21, 2021 at 8:03 PM

Nice instructions, but how do I get the video as an HTTPS Url?

Richard Detering
January 22, 2021 at 10:40 am

Dear Markus,

I am glad that you like the instructions. It’s a good idea to add SSL to the description. Switching to the https protocol is basically nothing different than on any website and I think there is enough information on this on the web. I just didn’t want to overload my setup instructions for my own live stream server.

T.Bersch
January 19, 2021 at 7:23 am

Hello,

i have a question, i would like to use this own server for a drone. Which rtmp path do I have to enter there so that it can stream? thanks in advance

Richard Detering
January 19, 2021 at 7:45 AM

Hello Mr. Bersch,

whether USB-Cam, ext. Webcam, studio camera or a “flying eye”, these instructions apply to all video devices.

Mario
January 13, 2021 at 10:50 PM

Good evening, I have successfully installed the server on a VServer. For me I had to deactivate the “Stats” in nginx.config. NGINX did not start with the following code. ” My correct IP is in the URL, I put “x” here in the post.

#allows us to see how stats on viewers on our Nginx site using a URL like: “http://xx.xxx.x.xxx/stats”
#location / stats {
#stub_status;
#}

Does anyone have instructions for a Linux newbie on how to get the status query so that I can see how many users see my stream? Many greetings Mario

jonathan
April 9, 2021 at 11:54 PM

Hello I hope I can help you. You have to add that to the ./configure “–with-http_stub_status_module” then that should work. The command should install the required plugin.
Best regards, Jonathan PS @den ADMIN the captcha system is a disaster to say the least …

Christian
January 13, 2021 at 12:29 AM

Hello, thank you very much for the instructions. I still have 2 problems. Installation on Ubuntu 20.04.1 LTS.
What works:
1. Stream in VLC rtmp: //../live/key
2. Video recorder of the stream .flv
My problems
1. Stream in VLC rtmp: //../mobile/key
2. Stream in the video js player (error message: no video in supported format and MIME type found)
I am grateful for any hints. The stream video js is running on the same server. Can user rights for the HLS folders be an approach?
thanks

hansvanhaga
January 10, 2021 at 11:07 PM

Hello !
Great guide, my question also works with Linux mint cinnamon 20?
Mfg Hans

Richard Detering
January 11, 2021 at 8:27 am

Dear Hans, the core functions of Linux Mint 20 are the same as those of Ubuntu 20, so these instructions also apply to Linux Mint and everything should work as described.

Mario
January 8, 2021 at 1:37 PM

Hello everyone, have a question about nginx.conf

Delete the entire content of the original ngnix.conf and copy and edit the CODE from point 8?

Richard Detering
January 11, 2021 at 8:32 am

Yes, exactly Mario! The entire content of the “nginx.conf” file created with the installation is deleted and overwritten with the content described here. The intended placeholders must of course be replaced afterwards.

Mario Brandt
January 8, 2021 at 12:07 AM

Who can tell me on which VSERVER the Nginx was successfully installed without problems.
I would be interested in the provider and the Ubuntu version.
I currently have Ubuntu 16.04 LTS, a new version or as in the instructions 18.03 is not available there.

Abolouter respect for the excellent manual, I’m looking forward to the installation as a newcomer to Ubuntu 🙂

Thorsten
January 6, 2021 at 12:51 AM

You write one should replace “my-streaming-key” everywhere, but in the config you never used “my-streaming-key”, except in the comments. Do I only have to use it in OBS and in the URI itself and Nginx know what to do? Or did I miss something?

Richard Detering
January 6, 2021 at 9:15 am

Hello, thank you for the question! In fact, the placeholder “my-streaming-key” refers to the relevant entry in the field of the OBS application for the streaming key. I’ve just improved this little flaw in the setup instructions.

Sven Rönnfranz
December 23, 2020 at 5:49 pm

Hello Richard,

I had a few problems at the beginning, had to reset the VPS several times, but everything worked out fine in the end.
However, I have a question:
I would like to integrate the WebPlayer (html-code) on a different homepage than my streaming server.
Simply packing the video script into a folder on the other home page and linking the link to the streaming server did not quite work.
Error: “The media could not be loaded, either because the server or network failed or because the format is not supported.”

Nevertheless, I know that the file works, because everything runs wonderfully via the link http: //my-ip/livestream.html.

Now my question:
how do I forward the streaming link to another homepage.

Greetings Rönne / Sven
P.s .: still very great instructions!

Richard Detering
December 23, 2020 at 5:59 pm

Hi Sven,
that shouldn’t be a problem, please check the links again. Are the ports on the firewall of the external server on which you are installing the player activated?

Sven Rönnfranz
December 27, 2020 at 2:24 pm

Hello Richard,
So I checked again and the port 1935 should be activated.
But I wrote to my website provider again, because the external homepage was rented as web space and does not run on a VPS or the like.

The links are all entered correctly.
Hope you had great holidays.

Greetings Sven

jonathan
April 9, 2021 at 9:06 PM

Hello, I have the same problem. The Video.js goes there everything is loaded. The link also works, if I copy this and paste 1 & 1 into vlc I can see the stream. I completely deactivated the firewall as a test so that all ports are open. Nevertheless, the message “The media could not be loaded, either because the server or network failed or because the format is not supported” appears on the external server. Can someone help me?

jonathan
April 9, 2021 at 10:18 PM

I found the solution.
1. Must be set up https
2. The line “add_header, Access-Control-Allow-Origin‘, * ‘;” must be specified under location / in nginx.conf, otherwise video.js cannot access it.
I had problems with certbot and simply used a different config file to work around this and then added the paths to the certificate.
I hope I could help.
Best regards, Jonathan

PS: 15 – thirteen = 2 as an exam did not work….

Andreas
December 7, 2020 at 2:02 pm

Good day,

Thank you very much for these detailed and really good instructions.
I would like to set up an RMTP server on the Internet in order to stream a stream from the mobile phone over the Internet to a website with an integrated HTML5 player. What do I have to consider when choosing a server (provider)? Is a normal Linux server that can be rented enough, or do I have to pay more attention to RTMP?

Richard Detering
December 8, 2020 at 7:24 am

Hi Andreas,
a rented Linux VPS server meets most standard requirements for live streaming. Of course, special requirements depend directly on your project and the quantity structure. The solution described here, with the fastest web server currently on the market, can already cover a lot and offers you good performance. I would choose an approach that is easily expandable. A detailed documentation of your project is helpful for the operation, maintenance and care.

Have fun and good luck with your project!

Motombo
November 22, 2020 at 8:52 pm

Hello, I would like to access my livestream via my Fritzbox “from outside” (via DynDNS). It was set up and running quickly for my Nextcloud on a Raspi, but I just can’t get the release for OBS (in the LAN the live stream runs flawlessly).

(1) Which protocol (TCP / UDP / ESP / GRE) do I have to select in the Fritzbox share, and which port internally (1935?)? (Example: “: 1234 -> Enable Fritzbox forwards -> 10.10.10.20:1935”)

(2) How does the link for an external VLC look like: “rtmp: //: / live /”?

Motombo
November 22, 2020 at 8:55 pm

Oha, everything in square brackets is unfortunately deleted automatically.
New attempt with round brackets:

(1) Which protocol (TCP / UDP / ESP / GRE) do I have to select in the Fritzbox share, and which port internally (1935?)? (Example: “(MeinDynDns): 1234 -> Enable Fritzbox forwards -> 10.10.10.20:1935”)

(2) How does the link for an external VLC look like: “rtmp: // (MeinDynDns): (MeinFritzboxFreigabePort) / live /”?

Christoph Hammann
October 19, 2020 at 11:49 am

How do I certify the server for HTTPS? The self-created SSL certificate is not sufficient for my app. The stream is running. Thanks. But the link as https: //XY.m3u8.

Stefan
October 25, 2020 at 6:06 pm

Have a look here: This page helped me a lot …
https://www.ustoopia.nl/featured/create-a-secure-adaptive-bit-rate-hls-stream-with-nginx-rtmp-ffmpeg-on-ubuntu-20-04-2021/

Nino
October 4, 2020 at 10:29 am

First of all, thank you very much for these instructions and for the work and your time that went into it.
Except for one thing, everything worked great.
Unfortunately, I could not install ffmpeg from the PPA repository, because apparently there is no corresponding package for Ubuntu 18.04. So I installed ffmpeg from the standard sources. That works too.
When everything was running I tested the same thing again, without any problems, with an Ubuntu 20.04 as a base.

If someone finds it useful, I’ve made a Docker image out of it:

FROM Ubuntu: 04/20
RUN apt-get update && \
apt-get dist-upgrade && \
export DEBIAN_FRONTEND = noninteractive && \
apt-get install build-essential libpcre3 libpcre3-dev libssl-dev wget unzip software-properties-common ffmpeg tzdata -y && \
ln -fs / usr / share / zoneinfo / Europe / Berlin / etc / localtime && \
dpkg-reconfigure –frontend noninteractive tzdata && \
wget http://nginx.org/download/nginx-1.18.0.tar.gz && \
wget https://github.com/sergey-dryabzhinsky/nginx-rtmp-module/archive/dev.zip && \
tar -zxvf nginx-1.18.0.tar.gz && \
unzip dev.zip && \
cd /nginx-1.18.0 && \
./configure –without-http_gzip_module –with-http_stub_status_module –with-http_ssl_module –add-module = .. / nginx-rtmp-module-dev && \
make && \
make install && \
mkdir / HLS && \
mkdir / HLS / live && \
mkdir / HLS / mobile && \
mkdir / video_recordings && \
chmod -R 777 / video_recordings
COPY nginx.conf /usr/local/nginx/conf/nginx.conf
EXPOSE 80
EXPOSE 1935
CMD / usr / local / nginx / sbin / nginx -g ‘daemon off; ‘

Stefan
October 4, 2020 at 2:49 pm

Thank you, Nino! I’ll try that right now …

DJ EDDI
December 29, 2020 at 13:57

First of all, thank you very much for these instructions, as a Ubuntu 20.xx newbie I still have one or the other question.
Quote: If someone finds it useful, I made a Docker image out of it
Is that an install script, so to speak? , that means I create a new file, copy everything in, name it e.g. install-nginx.sh?
Execution would then be ./install.nginx

Richard Detering
December 29, 2020 at 5:03 pm

Hi Eddi,
thanks for the appreciation! Getting started with Ubuntu is definitely worth it. If Windows is no longer running on your computer, Ubuntu works like a turbo. What I want to say, deal with the elementary step-by-step instructions first. I have not tested the very good contributions to the further development of an installation script. Just ask the author, he will surely help you quickly. Good luck with testing!

Steffen Balzert
September 25, 2020 at 12:12 pm

Hello,
Unfortunately, the server-side installation fails for me (on a Strato-VServer with Ubuntu 20.04) on make. I get the error message “No rule to make target ‘build”, needed by “default”. Stop.”
Do you have any ideas?
best regards
Steffen

Sharp Sharpened
September 3, 2020 at 3:19 pm

Another addendum: I have now got everything up and running, with a few adjustments. There were also a few error messages with repositry. It worked in the end, but the bug remains.

I use Unbuntu 20.04.1 LTS (focal)

1. Needed an additional package (libghc-zlib-dev), so
$ sudo apt-get install build-essential libpcre3 libpcre3-dev libssl-dev libghc-zlib-dev

2. Had to change the option “HTTP_STUB_STATUS = NO” to “HTTP_STUB_STATUS = YES” in the / auto / options (in the unpacked nginx directory).

3. $ sudo add-apt-repository ppa: kirillshkrogalev / ffmpeg-next outputs the following:
“This PPA provides backported release ffmpeg for current releases Ubuntu (Trusty, Utopic, etc.)
More information: https://launchpad.net/~kirillshkrogalev/+archive/Ubuntu/ffmpeg-next
Press [ENTER] to continue or Ctrl-c to cancel adding.

Ign: 1 http://ppa.launchpad.net/kirillshkrogalev/ffmpeg-next/Ubuntu focal InRelease
Get: 2 http://security.Ubuntu.com/Ubuntu focal-security InRelease [107 kB]
Miss: 3 http://ppa.launchpad.net/kirillshkrogalev/ffmpeg-next/Ubuntu focal release
404 Not Found [IP: 91.189.95.83 80]
OK: 4 http://de.archive.Ubuntu.com/Ubuntu focal InRelease
OK: 5 http://de.archive.Ubuntu.com/Ubuntu focal-updates InRelease
OK: 6 http://de.archive.Ubuntu.com/Ubuntu focal-backports InRelease
Package lists are read … Done
E: The depot “http://ppa.launchpad.net/kirillshkrogalev/ffmpeg-next/Ubuntu focal Release” does not contain a release file.
N: Updating from such a depot cannot be done in a safe way, so it is disabled by default.
N: Further details on the creation of package repositories and their user configuration can be found in the manual page apt-secure (8). ”

4. It would be nice if I could run all the stuff with “systemctl enable nginx” so that everything comes up again after a restart. I don’t have the experience how to adapt it so that it works.

Otherwise everything works great. Thanks again for the instructions!

Sharp Sharpened
September 3, 2020 at 12:23 pm

First of all, thank you very much for these instructions.

I still needed the libghc-zlib-dev package for the ./configure command, because it complained with the following error message:

“./Configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using -without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using -with-zlib = option. ”

I’m still in the whole installation process and am just wondering where all the directories that are supposed to be created should go. In fact in “/”?

Mario
April 14, 2021 at 12:28 PM

Do “sudo apt install zlib1g-dev”, that should fix your problem. Then again the ./configure command 😉

Onegin
August 14, 2020 at 10:29 am

Hi,

I need an RTMP signal in and an HTTPS:… / xy.m3u8 signal / file so that I don’t get an error message in the browser of users of my APP that the connection is insecure.

How do I do that?

Richard
August 14, 2020 at 12:12 pm

Thank you for your question! How is your specific system structure? It is not a big challenge to establish a secure connection to the live stream server. There are many simple and free solutions. I would just build my own VPN and create a certificate myself. Then you have an https connection and the stream from your live streaming server is safe. The browser no longer throws a notification message, the user is no longer afraid. This means that there are no additional costs, such as when you conclude a contract with a VPN service provider. Another advantage is that your users can receive your live stream worldwide, as this also eliminates the problem with geoblocking. Oh .. was I even allowed to reveal that? :-)) Have a lot of fun ..

Thomas
August 6, 2020 at 6:46 pm

Hello Richard,
I had already played around with nginx.
I’m a little confused, will the .conf also save the stream?
record all + record_unique on indicates for me …

If I recognize it correctly, the incoming rtmp stream is converted and then sent out.
What’s the latency like there?

Greetings Thomas

Thomas
August 6, 2020 at 7:16 pm

Hello Richard again,

Does the manual also work with the current version 1.18?

Greetings Thomas

Richard
August 7, 2020 at 5:31 am

Thanks Thomas for the question. For the setup described here, I recommend that you use the current version of the nginx. Higher versions have been bugfixed and further developments. Simply replace all information about the version that I used in the instructions with the current version of the nginx web server. Of course, the live stream server also runs with the current version. I could actually adapt it so that the instructions remain up-to-date. I wish you a lot of fun and success with the construction!

Richard
August 7, 2020 at 5:15 am

Hi Thomas,
Basically, the stream is just a number of many individual images that are shown one after the other at high speed, like in a flip book. The pictures learn to walk :-). Every single image is cached and converted. For some use cases it makes sense to save the stream, e.g. to offer it to customers later as a can. E.g. to offer the live recording later in a separate media library. These settings can be configured in the .conf. Thomas, as you write, the rtmp stream is converted and then “sent”. With the currently fastest web server of the nginx, you create the best performance. Of course, all other components are relevant for the user experience. I couldn’t find any noteworthy latencies on my live stream server. Of course, the live stream arrives at the consumer with a time lag in relation to real time, but this time lag remains stable. But we also have this behavior with every live broadcast on TV or radio.
What is the specific goal of your question? In my opinion, latencies are only critical in a bidirectional transmission and then have a detrimental effect on the user experience. The live stream server described here can be seen as a broadcaster.

Thomas
August 7, 2020 at 5:46 am

Hello Richard,
thanks for the detailed.
I am an amateur radio operator and am the sysop of an amateur radio television relay. All an ambitious hobby
We stream the radio broadcast on our website in order to give those who are interested outside of the radio range the opportunity to take a look at us.
There is also a bidirectional exchange, where long latencies (> 5 seconds) interfere.
Hence my question.

If I see it correctly, is the transmitted stream no longer an RTMP and therefore not affected by the EOL in November?

I’ll experiment a little then.

We made our pages with WordPress and then a page needs to be set up accordingly.

Thank you for your contribution and the effort.

Greetings Thomas

Lars Franke
July 29, 2020 at 4:02 pm

Hello Richard,
I would like to know how good your experience has been with HEVC and NGINX. Is it even possible to transcode an incoming H256 and output it in other forms than H256?

TINO
July 13, 2020 at 2:04 pm

Thanks for the instructions, great!
Since I have a small Milestone Server on the other end for the viewers, would it be nice to somehow transcode the stream to access it? (Onvif or universal driver?)
I don’t know the rtmp module very well yet … could something be possible there?
Thanks & greetings Martin

Richard Detering
July 16, 2020 at 3:59 pm

Thank you TINO for your question and suggestion. I haven’t dealt with it more intensively, but I am happy to ask this question to the readers of this article. Maybe someone has a link for you?

Ghost
July 12, 2020 at 10:33 pm

Isn’t it a potential security risk to keep the stream key in the player HTML?

Richard Detering
July 16, 2020 at 3:53 pm

It wasn’t necessary for my solution described here. The implementation of further security requirements depends directly on the use cases and of course on all details of the system architecture.

Heiko
July 2, 2020 at 18:12

Thanks for the instructions!
actually everything is going as described, please ask how do I get the stream integrated into an existing website? I have made several attempts, the message hls Video File not found… appears.
Everything works with VLC Player.
thanks

Richard
July 3, 2020 at 6:10 am

Hello Heiko,

thanks for your feedback. So you are almost there, great! In order to be able to answer your question, I would need more circumstantial evidence. What is your specific setup (network configuration, router, CMS, firewall, etc.)? How / who hosts the website on which web server, if applicable? What code did you use to embed the live stream on the website? Are the necessary ports of the firewall open, if applicable? What are the settings for dynamic DNS? Can your live server server be reached over the internet? What’s the url?

Sorry Heiko for all the questions, but you can’t do without them. 🙂 Maybe my questions will help you to find the right configuration yourself.

Best wishes
Richard

Heiko
July 3, 2020 at 16:47

Thanks for your answer !
I have made progress in the meantime, which means that I was able to integrate the stream on my website and it also runs, unfortunately very “jerky”. I think that first of all a lot of questions are answered like firewall, ports etc., because if that is not “free” or open or configured incorrectly, then it would not work “jerky”.
The whole thing is currently a pure “test / experiment” project. I use the provider for my homepage to test “server professionals”. The StreamServer is in a different place, with a 100,000 DSL connection. It is sent “locally” via OBS to the StreamServer and I have integrated FlowPlayer into / on my homepage as a test. But it doesn’t work smoothly….
If you have the time and inclination for tests etc. I could send you all the data, but not here in public. Or you can write to me at shp@freenet.de
I would be very happy to receive help and advice, streaming is new territory for me, but I’m capable of learning
Thanks Heiko

Jerome
June 16, 2020 at 11:38 am

Yes, I wanted to access the alternative with obs first, but opengl 3.2-capable hardware is required for this, the server only provides opengl 3.0 because it is only one vps. For this reason I wanted to use nginx and the associated modules.

Zoltan
October 25, 2020 at 8:12 am

Hi @Jerome
If you have been successful with your project, I am looking for a way to stream 24/7. With my VPS provider I don’t have a GUI, unfortunately only command line (I don’t think I’m a pro when it comes to Linux either) and I want to stream on different platforms at the same time.

I can’t get on by myself like this!

Jerome
June 15, 2020 at 5:18 pm

Hello Richard,

am quite new to nginx and rptm! is it possible to stream videos in mp4 format on the server using nginx (rtpm, hls, ffmpg) to twitch! Would like to set up a 24 hour stream where the mp4 videos that are on the server are played back one after the other. Since it is a vps server, no obs can be used.
Thank you for your help!

Richard Detering
June 16, 2020 at 4:08 am

Hi Jerome,

thank you for your question. What is stopping you from installing OBS on a VPS server? There are tutorials on the internet, so no problem. Of course I would recommend a VPS with Ubuntu Linux. In order to achieve an even greater range of your “transmitter”, you could also broadcast your videos simultaneously and 24/7 on other streaming servers (Facebook, Youtube, Periscope, Vimeo, etc.). I wish you every success with your project.

Florian
June 5, 2020 at 1:20 pm

Hello, would that also work with a Raspberry Pi?

Richard Detering
June 9, 2020 at 12:49 pm

Hi Florian,
Thank you for your inquiry. Installing a web server on the PI is a great idea and works great. This is ideal for many applications, as the PI works silently and consumes hardly any electricity. The small Pi is completely overwhelmed for a streaming server. Its strengths lie in other areas.

Julian
June 5, 2020 at 12:40 pm

I set up a current server (Ubuntu20.04 / nginx1.19 + rtmp module) and got it to work with these instructions. Thanks for that.
Only the mobile stream didn’t want to. The solution was a typing error in the exec ffmpeg command.
I replaced maxrate with -maxrate and / $ at the end with / $ name. Then it worked.

Richard Detering
June 9, 2020 at 12:53 pm

Hello julian,
great, thanks for your feedback, we make a living from it 🙂 I’ll take a look at the instructions in this regard right away, it may be a typo. In any case, your hint is already helpful for the community. Thx

Yannick
February 3, 2021 at 3:57 am

Many thanks for your response.
I looked for the error for a long time and your comment helped me to solve the problem 🙂

Harry Schmidt
May 23, 2020 at 10:55 am

First I had 7.6.5 and then went to the latest 7.8.1, but it hasn’t changed. videojs-contrib-hls is version 5.15.0

I’ll try again then.
Thanks!

Harry Schmidt
May 23, 2020 at 9:19 am

Hello Richard.
First of all, thank you for your efforts!
I followed your instructions (old nginx uninstalled beforehand). With me (Ubuntu Server 18.04.4) I had to install libnginx-mod-rtmp afterwards. It works so far until the test with the vlc. Then I come to Video.js and get the message “The media could not be loaded, either because the server or network failed or because the format is not supported”. The window stays dark.

I couldn’t find the JS module videojs-contrib-hls.js and got it from here: https://github.com/videojs/videojs-contrib-hls/releases/download/v5.15.0/videojs-contrib- hls.js but no change.

Several of these lines can be found in the error.log:
2020/05/23 09:12:40 [debug] 27879 # 0: * 1 hls: update fragment
and in access.log like this:
192.168.178.79 [23 / May / 2020: 09: 15: 27 +0000] PLAY “live” “123” “” – 413 89167 “” “LNX 9,0,124,2” (1s)

Richard
May 23, 2020 at 9:48 am

Hello Harry, please have a look which JS module I used at the time. It sounds to me like it’s an incompatible version. You should actually be able to continue building the required configuration with the system messages. It is well known that every Linux distribution has a different range of functions, so it is also common and often required modules / libraries to be installed. The Linux system messages are often very helpful and indicate missing components. Wish you continued success.

Harry Schmidt
May 23, 2020 at 10:51 am

Correction: I didn’t need to install libnginx-mod-rtmp. However, with ./configure I also have to specify –with-http_stub_status_module.

In the debugger (FF and Chrome) I get the JS message:
TypeError: The element or ID supplied is not valid. (videojs)

But I suspect that it is the mime type? There was also a message in the console that application / x-mpegURL does not support. This is also not in the configuration of nginx. Other types, for example video / mp4, do not work either.

Falk
May 19, 2020 at 4:21 pm

Hello, the setup description was also very helpful for me as a Linux novice. Stream runs smoothly on all devices (including smartphones). Thanks for the cool description. Now it would be good to know how I can access it from “outside” my home network. So far I haven’t managed to do that. I use a V-DSL DS-lite connection and am therefore dependent on third-party providers for IPv6 routing. The Fritzbox – Myfritz – port release has so far not brought any success.

Richard Detering
May 19, 2020 at 4:41 pm

Hi Falk,
Congratulations! Thanks for your feedback and as a Linux newbie – hats off! You did quite a bit of concentrated work there.
I am happy to help you with access from the outside. I tested two third-party providers and am surprised by the free and extremely stable service from Selfhost.de. The Dyn-DNS service is set up quickly. To do this, you have to enable the relevant ports on your router, both TSP and UDP and under the “Dynamic DNS” settings, enter the Selfhost.de access data. If everything works out, the whole world can have your video stream on your own server. I wish you success!

Falk
May 19, 2020 at 5:20 pm

Hey Richard, thanks for your quick reply. My problem is that a Dyn DNS provider probably didn’t help me. I tried a few until I found out that my internet access was via a DS-lite tunnel. I can get around that by sending the DynDNS from MyFritz! Use sharing. Now it would be interesting to know which ports I have to release for it. So also UDP…. I think we’re getting closer to the matter 🙂

Richard Detering
May 20, 2020 at 5:06 am

Exactly, in the Fritzbox you enter the DynDNS access data from your provider and enable ports 80 and 443. You will then drill two holes in your firewall 🙂 Background: You will receive a fixed URL from your DynDNS provider, e.g. mylive-cam.selfhost.co and a user name and password, so that your live streaming server is always accessible via the Internet even if your Internet service provider (ISP) changes your public IP address every 2 days for security reasons. I have already built the setup with a Raspberry Cam and it monitors our property: Raspberry PI2 with motioneyeos

Martin
May 14, 2020 at 9:34 am

Hello, I successfully set up a stream with it, it works very well. The video quality is very good and it’s fluid too.

Richard Detering
May 15, 2020 at 12:11 pm

Thank you for your feedback, I am pleased that this post was helpful to you.

Leave a Comment