1. What is a media server
The term media server originally comes from NGN (Next Generation Network), which provides various media resource management functions on the IP network under the control of softswitch equipment , including video, audio, pictures, graphic messages, and so on.
Later, it gradually evolved into a streaming media server, which provided streaming media resources, especially real-time and quasi-real-time audio and video resources, to push, store, and pull media resources.
Application areas include live video, video on demand, short video, video conferencing, distance education, telemedicine, etc.
Well- known open source media servers, including Red5 Server , Live555 , EasyDarwin , Open Streaming Server , Nginx+RTMP, etc.
Second, what is Nginx
Currently ( 2020 ), a large number of web services use Nginx as a reverse proxy server.
Nginx was originally developed by Russian Igor Sesoyev in 2004 under the BSD license.
In addition to the reverse proxy, Nginx is a lightweight Web Server , is the Apache web server replacement, the number of concurrent connections can reach 5 million or more.
In addition, Nginx can also be used to build load balancing servers and mail proxy servers.
More importantly, nginx with RTMP plug-in can adapt to the live broadcast trend and become a streaming media server with excellent performance.
Three, compile nginx under Windows
1. Official website download address: http://nginx.org/en/download.html , you need to download the source code and compile it yourself.
2. Ready-made compiled release version:
http://nginx-win.ecsds.eu/download/nginx%201.7.11.3%20Gryphon.zip
After decompression, put it into D:\nginx-1.7.11.3-Gryphon
3. Start: Double-click to start or enter start nginx under cmd
4. Verification:
( 1 ) Enter http://localhost/ in the browser
(2)tasklist /fi "imagename eq nginx.exe"
(3)netstat -ano | findstr "80"
5. Modify the configuration
The configuration file is conf\nginx.conf , if not, copy nginx-win.conf and rename it to nginx.conf
For example, modify the listening port to 8080 (default 80 ):
Use nginx -s reload to refresh after modifying the configuration :
Fourth, set up streaming services
Re nginx.conf named nginx-old.conf , the nginx-win-rtmp.conf copy renamed nginx.conf .
Check the following configuration:
Restart:
nginx.exe -s stop
start nginx
You can also use the following command:
nginx.exe -s quit
Start nginx
In addition, it is also feasible to directly terminate the process and restart:
verification:
Five, FFMPEG streaming
1. What is FFMPEG
slightly
2. Download
Unzip to: D:\ffmpeg
3. Settings
Set environment variables, first set FFMPEG_HOME
Then modify Path :
4. Push streaming
( 1 ) Modify the nginx configuration file and change the server_name from localhost to the local IP address (this will solve the problem that the player cannot pull the stream normally and cannot play the video)
( 2 ) The local video streaming instruction is:
ffmpeg.exe -re -i Videos\orange.mp4 -f flv rtmp://127.0.0.1:1935/live/edison
注意:以上指令中最后是rtmp://127.0.0.1:1935/live/edison,其中,rtmp是媒体传输协议,192.168.41.3是媒体服务器地址,1935是媒体服务器侦听端口,live是RTMP媒体服务名称,edison是应用名称,每次推流应用名称应不同才行。
使用VLC Media Player测试:
(3)本地摄像头和麦克风推流指令
ffmpeg -f dshow -i video="Integrated Camera" -f dshow -i audio="麦克风阵列 (英特尔® 智音技术)" -vcodec libx264 -preset:v ultrafast -tune:v zerolatency -f flv rtmp://192.168.41.3:1935/live/home
注意:以上指令中最后是rtmp://192.168.41.3:1935/live/home,其中,rtmp是媒体传输协议,192.168.41.3是媒体服务器地址,1935是媒体服务器侦听端口,live是RTMP媒体服务名称,home是应用名称,每次推流应用名称应不同才行。
5,查询本地麦克风和摄像头的方法:
(1)使用ffmpeg指令
ffmpeg -list_devices true -f dshow -i dummy
(2)“计算机管理”查设备属性
当ffmpeg指令查询结果有乱码时,可以使用“计算机管理”的设备属性来查看和拷贝:
选“友好名称”,拷贝下面的值。
(3)查询指定摄像头信息指令
ffmpeg -list_options true -f dshow -i video="Integrated Camera"
(4)查询指定麦克风信息的指令
ffmpeg -list_options true -f dshow -i audio = " microphone array ( Intel ® chi sound technology )"
( 5 ) Test whether the specified camera is available
ffplay -f dshow -i video="Integrated Camera" (或者ffplay -f vfwcap -i 0)
Six, VLC player and streaming
The relationship between pull and push is as follows:
The player is a PC , and VLS Media Player can be used . The download address is:
The player is Android , ijkplayer can be used
You can also use a JavaScript player, for example: jwplayer ,
jwplayer官 网 :
Jwplayer download address:
https://webscripts.softpedia.com/script/Multimedia/Video/JW-FLV-Media-Player-41172.html