Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Nginx uses nginx-rtmp-module module to realize the function of broadcasting room.

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

System environment

Wujianjun@wujianjun-work ~ $uname-aLinux wujianjun-work 4.10.0-37-generic # 41~16.04.1-Ubuntu SMP Fri Oct 6 22:42:59 UTC 2017 x86 "64 GNU/Linux

Software environment

OBS (Open Broadcaster Software) v20.0.1 (Linux)

Nginx version: nginx/1.13.6

Built by gcc 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.5)

Built with OpenSSL 1.0.2g 1 Mar 2016

TLS SNI support enabled

Configure arguments:-with-pcre=pcre-8.38-add-module=nginx-rtmp-module-1.1.11

Nginx+obs installation and configuration installation obs

Wujianjun@wujianjun-work ~ $sudo add-apt-repository ppa:kirillshkrogalev/ffmpeg-nextwujianjun@wujianjun-work ~ $sudo apt-get update & & sudo apt-get install ffmpegwujianjun@wujianjun-work ~ $sudo apt-get install obs-studiowujianjun@wujianjun-work ~ $sudo add-apt-repository ppa:obsproject/obs-studiowujianjun@wujianjun-work ~ $sudo apt-get update & & sudo apt-get install obs-studio

Add rtmp module to nginx

Nginx-rtmp-module (https://github.com/arut/nginx-rtmp-module)

Wujianjun@wujianjun-work ~ $sudo apt-get install build-essentialwujianjun@wujianjun-work ~ $wget wget http://nginx.org/download/nginx-1.13.6.tar.gzwujianjun@wujianjun-work ~ / nginx-1.13.6$ wget https://github.com/arut/nginx-rtmp-module/archive/v1.1.11.tar.gzwujianjun@wujianjun-work ~ / nginx-1.13.6$ tar-xvf v1.1.11.tar.gzwujianjun@wujianjun-work ~ / nginx- 1.13.6$ wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.38/pcre-8.38.tar.gzwujianjun@wujianjun-work ~ / nginx-1.13.6$ tar-xvf pcre-8.38.tar.gzwujianjun@wujianjun-work ~ / nginx-1.13.6$ ls-all Total amount 748drwxr-xr-x 9 wujianjun wujianjun 4096 October 15 11:39. Drwxr-xr-x 63 wujianjun wujianjun 4096 October 15 11:33.. drwxr-xr -x 6 wujianjun wujianjun 4096 October 15 11:33 auto-rw-r--r-- 1 wujianjun wujianjun 282456 October 10 23:22 CHANGES-rw-r--r-- 1 wujianjun wujianjun 430416 October 10 23:22 CHANGES.rudrwxr-xr-x 2 wujianjun wujianjun 4096 October 15 11:33 conf-rwxr-xr-x 1 wujianjun wujianjun 2502 October 10 23:22 configuredrwxr-xr-x 4 wujianjun wujianjun 4096 October 15 11:33 contribdrwxr-xr-x 2 wujianjun wujianjun 4096 October 15 11:33 html-rw- RMurray wujianjun wujianjun-1 wujianjun wujianjun 1397 October 10 23:22 LICENSEdrwxr-xr-x 2 wujianjun wujianjun 4096 October 15 11:33 mandrwxrwxr-x 6 wujianjun wujianjun 4096 February 13 2017 nginx-rtmp-module-1.1.11drwxr-xr-x 7 wujianjun wujianjun 4096 November 23 2015 pcre-8.38-rw-r--r-- 1 wujianjun wujianjun 49 October 10 23:22 READMEdrwxr-xr-x 9 wujianjun wujianjun 4096 October 15 11:33 srcwujianjun@wujianjun-work ~ / nginx-1.13.6 $. / configure-- with-pcre=pcre-8.38-- add-module=nginx-rtmp-module-1.1.11wujianjun@wujianjun-work ~ / nginx-1.13.6$ make & & sudo make installwujianjun@wujianjun-work ~ / nginx-1.13.6$ ls-all / usr/local/nginx/ Total amount 24drwxr-xr-x 6 root root 4096 October 15 16:11. Drwxr-xr-x 11 root root 4096 October 15 16:11.. drwxr-xr-x 2 root root 4096 October 15 16: 11 confdrwxr-xr-x 2 root root 4096 October 15 16:11 htmldrwxr-xr-x 2 root root 4096 October 15 16:11 logsdrwxr-xr-x 2 root root 4096 October 15 16:11 sbin

Add rtmp protocol configuration

Wujianjun@wujianjun-work ~ / nginx-1.13.6$ sudo vi / usr/local/nginx/conf/nginx.conf

Add the following rtmp protocol configuration at the end of the nginx.conf file

Rtmp {server {listen 1935; chunk_size 4096; application live {live on; record off;}

Start & Test

Start nginx

Wujianjun@wujianjun-work ~ / nginx-1.13.6$ sudo / usr/local/nginx/sbin/nginx

Start OBS

Open the newly installed OBS software, configure the push source of the image at the source (I choose window capture here), click "Settings" in the lower right corner, and configure the stream push address as shown below.

When the configuration is complete, click "start push"

Start a video player that supports network streaming (demonstrate using a vlc player)

Configure the address for network stream playback, as shown below:

When you click "play" and wait a few seconds, you can see that the player displays the image captured by obs.

Because the video stream needs to be transmitted over the network, the live image will have a delay of several seconds.

Http visits live video

1. Change the configuration in nginx.conf, add the hls configuration (hls is the folder used to store streaming media in the streaming media server), and set the directory where hls resides to the http protocol access directory again. The changed configuration is as follows:

Rtmp {server {listen 1935; chunk_size 4096; application live {live on; hls on; hls_path / usr/share/nginx/html/hls; hls_fragment 5s;} http {server {listen 80;. Location / {# root html; root / usr/share/nginx/html; index index.html index.htm;}. }}

Note: the user of the directory nginx where hls resides must have write permission.

2. Obs software configuration recording stream name

At the bottom of configuring obs push stream URL, there is a place to set "stream name". Here you can fill in a name at will (for my example, fill in "test")

3. Restart the nginx and obs software, and we can enter http://ip/hls/test.m3u8 into the mobile browser to play live videos on the phone. (the LVB delay is a bit large, and the subsequent articles will be optimized)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report