ios--Fast Integration iOS rtmp-based video push stream

Source: Internet
Author: User
Tags sublime text

Itools a bit of a card, but pushing to the server is fast.


Preface to push Flow

This blog is a supplement to the:< Meow app> for iOS video broadcast. Because there is no push stream for integrated video on projects that were previously uploaded to GitHub. There are a lot of friends 简信 and 微博 ask me how to push the flow this part of how to achieve. So, I've re-integrated RTMP the push flow and merged it into the previous project.

Download link

GitHub (full version video live)

Blog details (suggested that you join this article to see together)

Mac Build Nginx+rtmp Server

I built a server in my personal computer a long time ago, nginx+rtmp but yesterday in the company's computer construction, when manually entered the command, or there is a bug (so, we recommend that you directly copy the command, do not enter the command manually). So record a detailed set of steps to prevent the jump pit again ...
This tutorial refers to self-propelled cool: Mac build nginx+rtmp Server

      1. Open terminal to see if it is already installed Homebrew , direct terminal input command
man brew

If your Mac is already installed, it displays help for some commands. Enter Q to exit and go directly to the second step.
Conversely, if not installed, execute the command

-e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

If after installation, you want to uninstall

-e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
    • 2. Installing Nginx

Clone Nginx Project first to local

brew tap homebrew/nginx

To perform the installation:

install nginx-full --with-rtmp-module

At this point, the Nginx and rtmp modules are installed
Enter the command:

nginx

Open http://localhost:8080 in the browser
If present, the installation is successful


Installation Successful

If you are prompted on the terminal

Nginx: [Emerg] bind () to 0.0.0.0:8080 failed (48:address already on use)
Nginx: [Emerg] bind () to 0.0.0.0:8080 failed (48:address already on use)
Nginx: [Emerg] bind () to 0.0.0.0:8080 failed (48:address already on use)
Nginx: [Emerg] bind () to 0.0.0.0:8080 failed (48:address already on use)
.....

Indicates 8080 that the port is occupied, view the port PID

lsof -i tcp:8080

Based on the port PID, kill (Here's the 9603 pid for your own 8080 port)

kill 9603

Then re nginx -execute, open http://localhost:8080

    • 3. Configuring Nginx and Ramp
      First we look nginx at where it's installed.
brew info nginx-full

To find the nginx.conf location of your file


Nginx.conf

vim Finder 前往 前往文件夹 输入/usr/local/etc/nginx/nginx.conf Open with Notepad tool (recommended Sublime Text ), nginx.conf or by clicking on it.

Roll directly to the last line, and add it after the last } (that is, the last space, without any {} )

# 在http节点后面加上rtmp配置:rtmp {    server {        listen 1935;        application rtmplive {            live on;            record off;        }    }}

Then restart the Nginx (where the 1.10.1 to replace your own installed nginx version number, check the version number with the nginx -v command)

/usr/local/Cellar/nginx-full/1.10.1/bin/nginx -s reload

Yesterday, at the time of the execution of this order, the pit appeared. (If your command succeeds, the reboot succeeds, no exception, please jump to the next step directly)
When the command is executed, the report is abnormal.

in /usr/local/etc/nginx/nginx.conf:119

rtmphas become an unknown instruction. I hurried to Google, the answer has been tried again, the bug is still the sound. Finally there is no way, brew list look at all the installed modules, only to find that their own manual knocking command, will nginx-full become nginx -full .

On the solution:
Unloadingnginx

uninstall nginx

Install againnginx

install nginx-full --with-rtmp-module
      1. Installing FFmpeg

Execute command

install ffmpeg

ffmpegthe installation time will be a little longer. If the speed is too slow, it is recommended to FQ. But it's just over 50 m, just be patient. Wait time, install a video player that supports RTMP protocolVLC

      1. FFmpeg Push Stream
        Take one of my desktops loginmovie.mp4 (prepare a video file yourself, or use Resource the two video files in my GitHub project) as an example to perform a push-flow command

Ffmpeg-re-i/users/sunlin/desktop/loginmovie.mp4-vcodec Libx264-acodec aac-strict-2-F FLV Rtmp://localhost:1935/rtm Plive/room

After the video is pushed to the server, open VLC, and then File->open network-> input:

Rtmp://localhost:1935/rtmplive/room

Effect


Push stream fast integrated live push stream

Prerequisites:

    • Go to GitHub to download the latest Meow project.
    • Configure the NGINX+RTMP server according to the tutorial above.

Originally prepared to achieve their own live streaming, but today in the technology group chat, a friend recommended Youku Tudou 来疯直播 shortly before the open source iOS push stream framework Lflivekit. is written in OC, it is suitable for learning (I am also ready to delve into this framework, what questions you can discuss together) , the integration is also very simple, a few lines of code is OK.

Download good I write after the meow, in the lower left of Xcode direct search ShowTimeViewController , enter ShowTimeViewController.m . Search - (IBAction)living:(UIButton *)sender , replace the inside with stream.url your own rtmp address.

Tip: LFLiveKit already integrated, GPUImage if there is integration in the project GPUImage , you need to remove the previous one. and the integration LFLiveKit needs to be closed Bitcode .

Closing submissions

Now meow is a relatively complete video live project, although the use of a lot of third parties, but also save the development time, improve the development efficiency.
Later this project I will continue to improve, if you have any good idea or effect, you can micro-blog private messages to me, if I can fix, I will add as soon as possible.

GitHub

Full video Live: Meow



Wen/monkey_alin (author of Jane's book)
Original link: http://www.jianshu.com/p/8ea016b2720e
Copyright belongs to the author, please contact the author to obtain authorization, and Mark "book author".

ios--Fast Integration iOS rtmp-based video push stream

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.