In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how nginx uses nginx-rtmp-module module to achieve live room function". In daily operation, I believe many people have doubts about how nginx uses nginx-rtmp-module module to achieve live room function. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the question of "how nginx uses nginx-rtmp-module module to achieve live room function". Next, please follow the editor to study!
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 ()
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)
At this point, the study on "how to use the nginx-rtmp-module module to achieve the live room function of nginx" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.