Set up a Streaming Media Server

Source: Internet
Author: User
Tags flv file

Set up a Streaming Media Server

Requirement: now we need to build a Streaming Media Server. In order to broadcast the desktop screen and sound of the speaker to remote users for real-time viewing, the latency is required to be around 5 seconds. Theoretically, RTSP, RTMP, and HTTP can both be used for live broadcast and on-demand broadcast. However, RTSP and RTMP are generally used for live broadcast and HTTP is used for Vod. During video conferencing, we used the SIP protocol, which is basically replaced by the RTMP protocol.

The two solutions are as follows:

1) rtsp is currently popular with open-source software such as live555, vlc, and DarwinStreamingSrvr5.5.5.

2) rtmp can only be used to load the rtmp module with nginx to build the server.

First, we need to think about the following issues:

1. Is the live stream pull or push?

2. Is it actively pulled by the server? Or is streaming software installed on the live broadcasting end based on tools?

3. Can the server receive streaming messages? How to test whether the streaming is successful?

4. What is the receiver's acceptance test? Tool or browser?

Required environment and tools:

1. One Laptop (the server is also a live video client, and it is best to connect to the public network and the ubuntu System)

2. One Flv video file (test the on-demand video file)

3. One vlc client (used by the receiver) or one computer that can access the Internet

4. One obs client (live video)

Solution 1,

First try the first solution rtsp. There are only three online search solutions:

1. Use live555 as the server (a bunch of methods on the network, the deployment is also very simple)

Result: only the on-demand video effect is achieved. The source code needs to be modified and discarded to implement the live video through online query based on the protocol unknown to the obs streaming report.

2. Use vlc as the server (a bunch of methods on the network, the deployment is also very simple)

Result: The implementation process is quite simple, but it can only stream mp3 audio files. It does not seem to work if you have tried desktop streaming. In addition, the high concurrency is not sure whether there are performance problems. And discard it.

3. Use DarwinStreamingSrvr5.5.5 as the server (a bunch of methods are deployed on the network, which is also very simple)

Result: No video-on-demand video can be used, not to mention live video. Of course, I do not doubt whether there is a problem with the deployment. Finally, I will discard it.

Conclusion:

RTSP give up! Despite the low latency and high real-time performance, the deployment fails. So I am going to use RTMP as the server.

How to Use vlc and obs:

Vlc can only be used as the server and receiver, and cannot be used as the live streaming end to push data streams to the server.

Obs can only push data streams to the server as the live video end, and cannot be used as the server end or the receiving end.

To sum up, answer the following questions:

1. Is the live stream pull or push?

A: Push

2. Is it actively pulled by the server? Or is streaming software installed on the live broadcasting end based on tools?

A: It is streaming using obs on the live broadcasting end.

3. Can the server receive streaming messages? How to test whether the streaming is successful?

A: The server can accept streaming. The server can use the pangu live broadcasting server to register an account in pangu live broadcasting and remember the url and stream key of the Streaming Media Server, in the obs software settings, enter this parameter to test whether the streaming is successful.

4. What is the receiver's acceptance test? Tool or browser?

A: The receiver can use vlc to receive tests. However, I personally suggest using a player in the browser for testing. The latency is lower, but it must be accessible to the public network. The address is as follows:

Http://www.ossrs.net/players/srs_player.html. Enter the address of your Streaming Media Server in url!

As follows:


Solution 2,

I. server operations:

1. Install ubuntu in a notebook (Procedure omitted)

2. Install the obs software. Note that the linux version on the obs official website only supports ubuntu installation, so now you know why the above instructions require the ubuntu system! Of course, windows is fine, because I still need some php environment to run some other services.

 
 
  1. sudo add-apt-repository ppa:obsproject/obs-studio
  2. sudo apt-get update && sudo apt-get install obs-studio

3. Install nginx and rtmp modules

 
 
  1. Wget http://nginx.org/nginx-1.11.8.tar.gz
  2. Unzip nginx-rtmp-module-master.zip (this module goes online to search for download)
  3. Tar zxvf nginx-1.11.8.tar.gz
  4. Cd nginx-1.11.8
  5. ./Configure -- prefix =/usr/local/nginx -- add-module =/root/nginx-rtmp-module-master
  6. Make
  7. Make install

Modify the nginx. conf file and add the following content to the server segment:

 
 
  1. rtmp {
  2. server {
  3. listen 1935;
  4. application live {
  5. live on;
  6. record off;
  7. }
  8. }
  9. }

Note that multiple applications can be added, and live is equivalent to the meaning of the channel. You only need to set the address to be the same as that of the receiver during live streaming.

Start the nginx service and listen to ports 80 and 1935 normally. Ensure that the live broadcasting end and the receiving end can access the two ports of the server.

The following red fonts can be ignored

Simple Test on-demand video (note that the following operations are performed on the centos7.2 system ):

Find a flv file first! Therefore, you need to install an ffmpeg software to simulate streaming operations.

 
 
  1. rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm
  2. yum –y install ffmpeg
  3. ffmpeg -re -i test.flv -f flv rtmp://192.168.1.1/live
The normal output is as follows:

Find a window that can access the Internet as the receiving end, enter the following url, enter rtmp: // 192.168.1.1/live, and click the play button. The following picture shows that the VOD is normal. In fact, this test on-demand video can be completely omitted. Here I will easily record the ffmpeg streaming.


The server then performs the following operations:

1. Open the terminal and directly enter the obs command. The obs interface will pop up. Then, click streaming-choose Custom Streaming Media Server-enter rtmp: // server IP Address/live in URL-and click OK.


2. Place the mouse pointer in the blank area of the source and click Add-screen capture

3. Place the mouse pointer in the blank area of the source and click "add"-audio input capture

4. Click OK. The screen capture and audio input capture appear at the source.

Click Start streaming, and click OK! If there is a time to start timing and move around, it means that the data stream can be pushed to the server normally.

Iii. acceptor operations

Enter the following url in the browser, enter rtmp: // 192.168.1.1/live/, and click the play button. The ubuntu Desktop indicates that the live broadcast is normal. After the test, the delay is generally about 2 seconds, but about 4 seconds for the vlc test. So if your acceptor can access the Internet, use a browser. If not, use vlc. The usage is as follows:

Open vlc, click media-Open Network streaming, enter the address of your server, and click the play button to receive live streaming data in real time.






Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.