Android Streamer for Pushing RTMP Stream


We recommend using KSYLive Android SDK for pushing RTMP stream as it's oepn source and enhanced streaming SDK. In this section, we will introduce how to integrate with KSY Android Live SDK.

Preparation

Please download souce code of latest release from KSY github.

https://github.com/ksvc/KSYLive_Android

Once you have downloaded the source code, please import the source code to your app via android studio.

Parameters Setting

1. Rtmp server address
General RTMP server address consists of three parts:host + appName + streamName(E.g   rtmp://test.uplive.ksyun.com/live/888)

Set interface: setUrl
2. Encode type
The following three encoding modes are supported:
ENCODE_METHOD_SOFTWARE
ENCODE_METHOD_HARDWARE
ENCODE_METHOD_SOFTWARE_COMPAT

Set interface: setEncodeMethod
3. Video encoding mode
AVConst.CODEC_ID_AVC  //Use H264 encoding
AVConst.CODEC_ID_HEVC   //Use H265 encoding

Set interface: setVideoCodecId(int)
4. Preview resolution

The resolution of video will show on streamer side.

VIDEO_RESOLUTION_36OP
VIDEO_RESOLUTION_480P
VIDEO_RESOLUTION_540P
VIDEO_RESOLUTION_720P

Set interface: setPreviewResolution (int width, int height)

Recommendation: VIDEO_RESOLUTION_480P

5. Push stream resolution

The resolution of video will be pushed to streaming server.

VIDEO_RESOLUTION_36OP
VIDEO_RESOLUTION_480P
VIDEO_RESOLUTION_540P
VIDEO_RESOLUTION_720P

Set interface: setTargetResolution (int width, int height)

Recommendation: VIDEO_RESOLUTION_480P

6. Video bitrate and bitrate adaptation
Set the video bitrate and turn off rate adaptation:
setVideoKBitrate(int kbps) or setVideoBitrate(int bps)  //500 kbps

Set the video three bitrate and turn on the bitrate adaptation:
setVideoKBitrate(int initVideoKbps, int maxVideoKbps, int minVideoKbps)  
or 
setVideoBitrate(int initVideoBps, int maxVideoBps, int minVideoBps)   //500kbps,800 kbps、200kbps

Recommend using bitrate adaption for mobile app streaming push.

7. Maximum keyframe interval
Set interface: setIFrameInterval(float)

Recommend using 2 seconds as keyframe interval. If FPS is 20, keyframe interval will be 40.

8. Audio coding parameter
Audio sample rate:setAudioSampleRate(int)   //44100 Hz
Audio bit rate:setAudioKBitrate(int kbps)   //48 kbps
Number of audio channels:setAudioChannels(int)
Audio encoding profile settings:setAudioEncodeProfile
9. FPS
setPreviewFps   //20 fps
setTargetFps    //20 fps
10. Rotation
setRotateDegrees

Horizontal screen: 90/270; vertical screen: 0/180

© 2018 Conversant Solutions Pte Ltd. All rights reserved.            Updated 2021-12-09 06:49:11

results matching ""

    No results matching ""