directory
Environment to prepare
Low Centos system installation: please check my another blog Java back-end road (6) install Linux system low git installation (if not) system: www.cnblogs.com/imyalost/p/… After configuring git, restart the system for the configuration to take effect, or run the source /etc/profile command. ●SRS Streaming server installation (official tutorial) : github.com/ossrs/srs/w… After the installation is complete, you need to open the ports referred to in the srs.conf of the official installation instructions. Low Linux ports open: jingyan.baidu.com/article/0eb… “OBS Studio push flow software download: www.onlinedown.net/soft/637537… Low VLC pull flow software download: www.onlinedown.net/soft/16216….
Live test
●OBS Studio Configuration Push stream: Right-click in the Source window -> Add -> Monitor Capture
Android does push streaming
Here I am using a very useful Android push stream open source library: github.com/begeekmyfri… It’s easy to use by first importing its library and then implementing it in a few lines of code:
<?xml version="1.0" encoding="utf-8"? >
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.itfitness.zhiboapp.MainActivity">
<net.ossrs.yasea.SrsCameraView
android:id="@+id/glsurfaceview_camera"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
Copy the code
The Activity code:
/ / this Activity also need to implement these interfaces: SrsEncodeHandler. SrsEncodeListener, RtmpHandler. RtmpListener, SrsRecordHandler. SrsRecordListener
SrsCameraView cameraView = (SrsCameraView) findViewById(R.id.glsurfaceview_camera);
mPublisher = new SrsPublisher(cameraView);
// Encode state callback
mPublisher.setEncodeHandler(new SrsEncodeHandler(this));
mPublisher.setRecordHandler(new SrsRecordHandler(this));
// RTMP push state callback
mPublisher.setRtmpHandler(new RtmpHandler(this));
// Preview the resolution
mPublisher.setPreviewResolution(1280.720);
// Push stream resolution
mPublisher.setOutputResolution(720.1280);
/ / transfer rate
mPublisher.setVideoHDMode();
// Enable beautification (other filter effects can be viewed in MagicFilterType)
mPublisher.switchCameraFilter(MagicFilterType.BEAUTY);
// Open camera and start preview (without pushing stream)
mPublisher.startCamera();
//mPublisher.switchToSoftEncoder(); // Select soft coding
mPublisher.switchToHardEncoder();// Select hard coding
// Start pushing stream rtmpUrl (IP to server deployment IP)
mPublisher.startPublish("RTMP: / / 192.168.0.102 / live/test");
Copy the code
Next, use VLC to play the pull stream:
www.cutv.com/demo/live_t…