Introduction: This article is mainly aimed at the foolproof installation and simple mobile phone online streaming browsing operation. It’s just a process and considerations without any particularly high technical difficulties.

Step 1: Installationnginx

Brew will need to be installed on your computer first, which I’m sure you all have, if you don’t run the following command to install (uninstall)

/ / install $/ usr/bin/ruby - e "$(curl - fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" / / unloading $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"Copy the code

Install Nginx using BREW

// The latest installation path $brew tap denji/homebrew-nginxCopy the code
$brew install nginx-full --with-rtmp-moduleCopy the code
Start nginx $nginxCopy the code

Enter http://localhost:8080 in the address bar as follows:

Ok, nginx is up and running.

For other nginx commands, the RTMP configuration needs to be modified, so you need to use the nginx -s reload command to reload the configuration file.

$brew info nginx-full // Reload configuration file $Nginx -s reload // Reopen configuration file $Nginx -s reopen server $Nginx -s stop $nginx -s quitCopy the code

Step 2: Modify itrtmpconfiguration

Go to the folder and enter the following path

/usr/local/etc/nginx/nginx.conf
Copy the code

Find the nginx.conf file

Open the nginx.conf file in a text editor and add the following configuration at the end of the content

rtmp { server { listen 1935; Application live1 {//live on; record off; }}}Copy the code

After modification, see figure

Reload the nginx configuration in terminal, where 1.19.10 is located. Note that you need to enter the current local version number

/ usr/local/Cellar/nginx - full / 1.19.10 / bin/nginx -s reloadCopy the code

Step 3: Install FFMPEG

Run the following terminal command (the volume is about 50M) and wait until the installation is complete.

brew install ffmpeg
Copy the code

Step 4. Prepare the push flow

Here, I’m going to record a video and save it in a temporary folder called Push,

CD To the current folder, run the following command

ffmpeg -re -i ./test.mov -vcodec copy -f flv rtmp://localhost:1935/live1/room
Copy the code

The above command is to push flow,. / test. The mov file is saved in the folder record screen, RTMP: / / localhost: 1935 / live1 / room, pull flow generated address, before the live1 here is in nginx configuration file to remember the name, The room in the back, as you like, the address in the back of the pull flow can be kept the same.

Run the following

After pushing the stream to the end of the recorded video, the streaming operation will stop automatically.

In order to judge whether the stream is really pushed successfully, download a VLC tool and play the stream address.

You can see that with the VLC tool, it’s ready to play.

Step 5. Pull the mobile phone

Here iOS is using the Tencent Cloud pull stream SDK. Add the following dependencies to your podfile

pod 'TXLiteAVSDK_Professional'
Copy the code

Declare pull flow properties

@property (nonatomic,strong) V2TXLivePlayer * livePlayer;

@property (nonatomic,strong) TXView * txView;
Copy the code

To pull flow

Self.txview = [[TXView alloc] init]; self.txView = [[TXView alloc] init]; self.txView.frame = CGRectMake(0, 100, self.view.width, 300); [self.view addSubview:self.txView]; // Self. livePlayer = [[V2TXLivePlayer alloc] init]; V2TXLiveCode fillLiveCode = [self.livePlayer setRenderFillMode:(V2TXLiveFillModeFit)]; NSLog(@"fillLiveCode = %ld",(long)fillLiveCode); [self.livePlayer setObserver:self]; / / streaming video mount V2TXLiveCode renderCode = [self. LivePlayer setRenderView: self. TxView]; NSLog(@"renderCode = %ld",renderCode); / / pull flow address, local address (local area net) nsstrings * url = @ "RTMP: / / 10.10.60.20:1935 / live1 / room". V2TXLiveCode liveCode = [self.livePlayer startPlay:url]; NSLog(@"liveCode = %ld",liveCode);Copy the code

Run, find a blank screen, no video stream, as shown in the figure. This requires the MAC to turn off the firewall.

White screen warning!

Disabling the Firewall

Try again:

Okay, so the demo can get a pull stream.

There’s nothing complicated here, so write down the rundown and familiarize yourself with the process. Don’t laugh at bad code.