In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Today, I will talk to you about how to easily build the Android LVB system from 0. Many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something from this article.
Set up a live broadcast system from 0
I put it into practice right away, so first of all, I'd like to share with you the whole process of building:
My operating system is mac. Students of other systems can install the software on their own according to the prompts.
A simple LVB system can be composed of three parts:
Set up a rtmp media server
Push end
Pull end
Now the goal is to build quickly, so of course with open source projects and some software:
Rtmp Media Server: srs is used here
Push end: obs is used here
Pull end: player vlc is used here
Construction of rtmp Media Server
The link to use srs,srs here is:
Https://github.com/ossrs/srs
First, clone to the local directory and enter the trunk directory:
Git clone https://github.com/ossrs/srs.git cd srs/trunk
Then execute:
. / configure-- osx
Note: Centos6.x/Ubuntu12 32/64bits users only need to execute. / configure.
Finally, execute:
Make
After the implementation is successful, you can start our service:
. / etc/init.d/srs start
If it is a mac system, it will fail at this time because the max_connections in srs.conf is too large
The directory is srs/trunk/conf/srs.conf, which can be changed to 248 (other operating systems may not have this problem).
Go back to the trunk directory again:
. / etc/init.d/srs start
At this point, our srs server is set up.
Note:
Centos and Ubuntu can be built by referring to the official website, which is relatively simple.
If you encounter other errors during startup, you can check the log message:
Srs/trunk/objs/srs.log
Other instructions:
Stop. / etc/init.d/srs stop restart. / etc/init.d/srs restart
With the server, we are ready to start our push side.
If you really do not build successfully, you can first test the ip 116.196.121.20. The configuration I built on JD.com Cloud is low, and it is mainly used for temporary testing. It may be unstable. Just take a look at it and turn it off after the resumed session, so try your best to build it successfully.
Use OBS to push streams
Download address: https://obsproject.com/
Download and install it first, and it's easy here.
First of all, select click + select the source, here I selected the window capture, and then click the settings on the right:
Select stream, stream type, select custom, and then url, enter:
Rtmp://, your ip/, your favorite url.
The stream name can be entered freely as described above.
Remember our url and stream names:
Rtmp://192.168.1.102/zhy/mylive
When you are finished, click OK.
Then click start push.
In this way, our OBS push is enabled, and more use of the software can be explored by yourself.
* * all that's left is our pull.
Use VLC to pull streams
Download address: http://www.videolan.org/vlc/
Download and install first, this is even easier.
Click Open Network, enter the name of the url+ stream we just had, and click OK.
In a moment, we will start to play our push content.
On the far left is VLC, in the middle is OBS, and on the right is my window capture object.
Here, even if we build a live broadcast system ~ ~ our own feeling of success, extremely refreshing, but also can greatly stimulate our interest in follow-up learning.
Later, we can choose to learn to pull or push according to our own needs, and gradually replace the software. There are many ways to pull streams, which are supported by many open source players. Here we consider replacing the push, hoping to use mobile phone to push the stream.
Use third-party push SDK
The easiest way is to take advantage of the push SDK of a third party. In most cases, the complete solution of the third party SDK is charged, but their push Android SDK can be downloaded and learned to use without payment.
Here, take Baidu Cloud's LVB SDK as an example, download it at:
Https://cloud.baidu.com/doc/Downloadcenter/Push.html#.E7.89.88.E6.9C.AC.E6.9B.B4.E6.96.B0.E8.AF.B4.E6.98.8E
Just click to download Android SDK, unzip it after the download is complete, and then pour it into AS (this turns out to be an Eclipse project …) Fortunately, AS supports, after import:
Just change mStreamKey to the address of our rtmp.
Note that you need to add the following v7 dependencies to build.gradle
Compile 'com.android.support:appcompat-v7:23.0.0'
Then run it, and the interface can also:
Post the runtime effect picture:
Or to vlc pull can, the whole process is very slow, wait patiently, the effect is not very good, but can run well, mainly learning. Then you can try other SDK by analogy.
Of course, many open source projects are actually better than SDK as learning materials, comparing the source code are available, here is an example of an open source project.
Push streams using open source projects
Use an open source project:
Https://github.com/begeekmyfriend/yasea
Direct clone, import.
This is relatively smooth. After import, modify the rtmp link:
Then run it (import is not successful, think of a way to solve it, basic ability).
Post an effect picture:
In the case of hard decoding, the effect is much better than the previous SDK.
All right, let's see one more way.
Well, ffmpeg is hot and ffmpeg is powerful.
So one way is to see how to use ffmpeg to push streams.
Push streams using ffmpeg
You can download the ffmepg source code, and then according to the online way to compile so, a simple point and more practical, is to compile a so that can execute ffmpeg commands, so you can do a lot of things.
Here, because of the space, we will directly use the projects made up by others.
Https://github.com/WritingMinds/ffmpeg-android-java
Direct import, and the project supports running ffmpeg commands directly.
There are many ffmpeg commands:
For example:
Convert .avi to gif animation (uncompressed)
Ffmpeg-I video_origine.avi gif_anime.gif
Synthesize video and audio
Ffmpeg-I son.wav-I video_origine.avi video_finale.mpg
One of the commands is to support push. Here, the zixia.mp4 on the phone is used as input:
Ffmpeg-re-I / storage/emulated/0/zixia.mp4-vcodec libx264-acodec aac-f flv-strict-2 rtmp://192.168.1.102/zhy/mylive=
So this library supports running ffmpeg commands on mobile phones, and that's simple:
Paste the command we need to execute and run it.
Note here that I am pushing a media file on the memory card. Pay attention to adding relevant permissions. The effect is as follows.
After reading the above, do you have any further understanding of how to easily build an Android live broadcast system from 0? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.