Recently I have been learning Android live broadcast, so there is no doubt that ffmpeg and WebRTC are the two big players in the audio and video industry.
The basic use of ffmpeg: https://blog.csdn.net/huangliniqng/article/details/81842273
I have seen many tutorials explaining how to build a live broadcast environment, most of which are built on a mac environment. It is more cumbersome for windows users. At this time yesterday, I tried to build a Nginx-rtmp live server locally in windows, and it finally worked successfully. . The effect diagram is shown below.
But we will not explain how to build a live server on windows today. If you have any questions, you can discuss it together. Today I will explain how to build a live server on the ubuntu server. (We don’t build wheels here, just to make it easier to build later)
RTMP stands for Real Time Messaging Protocol (Real Time Messaging Protocol), rmtp is a communication protocol. This protocol is based on TCP and is a protocol family, including RTMP basic protocol and RTMPT/RTMPS/RTMPE and other variants. RTMP is a network protocol designed for real-time data communication. It is mainly used for audio, video and data communication between the Flash/AIR platform and a streaming media/interactive server that supports the RTMP protocol.
If you are not familiar with linux operation commands, you can move to my linux series articles:
https://mp.csdn.net/postedit/82469566
** First create a directory for source code compilation and enter. **
** $ mkdir nginx-src**** $ cd nginx-src**
Download the source code** $ git clone https://github.com/nginx/nginx.git**** $ git clone https://github.com/arut/nginx-rtmp-module.git**** $ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz**** $ tar -xzvf pcre-8.39.tar.gz**** $ cd nginx$ git checkout release-1.9.9**
Compile and install
# Encapsulate the configure command into a script **** $ vim cfg.sh
auto/configure --prefix=/usr/local/nginx
--with-pcre=../pcre-8.39
--with-http_ssl_module
--with-http_v2_module
--with-http_flv_module
--with-http_mp4_module
--add-module=../nginx-rtmp-module/
$ chmod a+x cfg.sh
$ ./cfg.sh
$ make
$ make install
After the installation is complete, modify the configuration file to perform the following operations:
Enter cd /usr/local/nginx/conf
Edit nginx.conf, if you are prompted that there is no permission, execute sudo chmod 777 nginx.conf to get all permissions
Edit the nginx.conf file, mainly to add rtmp service
After the configuration is complete, save the file.
Execute the following command to restart nginx:
sudo /usr/local/nginx/sbin/nginx -s stop
sudo /usr/local/nginx/sbin/nginx
If there is no error, the rtmp streaming media has been successfully built at this time,
Then we use the tool to test, you can also use the webrtc-android terminal to test, here we use the tool SmarterStreaming, download address: https://github.com/daniulive/SmarterStreaming
Before testing, we must first push a video stream
We use the command ffmpeg -re -i soft/2.mp4 -c copy -f flv rtmp://localhost:1935/live/film
soft/2.mp4 is the video address on the server. If the following figure appears when running, it means that there is no problem with the above environment.
We use the testing tool to test, enter the address rtmp://123.207.55.74:1935/live/film
Results as shown below:
When the push is over, the playback ends (think carefully about pushing like a TV station and then ending and then pushing ads, etc.)
Sharing technical articles, submitting and sharing, unlimited technical types, unlimited technical depth, so that more people can benefit from sharing.
Recommended Posts