RootEncoder for Android(rtmp-rtsp-stream-client-java)

RootEncoder for Android(rtmp-rtsp-stream-client-java)是一款流编码器,可使用 RTMP、RTSP 和 SRT 协议将视频/音频推送至媒体服务器,所有代码均使用 Java/Kotlin 编写。「RootEncoder for Android (rtmp-rtsp-stream-client-java) is a stream encoder to push video/audio to media servers using protocols RTMP, RTSP and SRT with all code written in Java/Kotlin」

Github星跟踪图

RootEncoder for Android

Android Arsenal
Release
Documentation

RootEncoder (rtmp-rtsp-stream-client-java) is a stream encoder to push video/audio to media servers using protocols RTMP, RTSP and SRT with all code written in Java/Kotlin

Note: The library was renamed from rtmp-rtsp-stream-client-java to RootEncoder after add SRT protocol because the name has no sense anymore

If you need a player see this project:

https://github.com/pedroSG94/vlc-example-streamplayer

iOS version (under develop):

https://github.com/pedroSG94/rtmp-rtsp-stream-client-swift

Wiki

https://github.com/pedroSG94/RootEncoder/wiki

Permissions:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />
<!--Only for record video/audio-->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!--Optional for play store-->
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />

Compile

To use this library in your project with gradle add this to your build.gradle:

Version 2.2.6 or less

allprojects {
  repositories {
    maven { url 'https://jitpack.io' }
  }
}
dependencies {
  implementation 'com.github.pedroSG94.RootEncoder:rtplibrary:2.2.6'
}

Version 2.2.7 or more

allprojects {
  repositories {
    maven { url 'https://jitpack.io' }
  }
}
dependencies {
  implementation 'com.github.pedroSG94.RootEncoder:library:2.3.3'
}

Features:

  • Android min API 16.

Encoder:

  • Support camera1 and camera2 API
  • Encoder type buffer to buffer.
  • Encoder type surface to buffer.
  • Audio noise suppressor.
  • Audio echo cancellation.
  • Disable/Enable video and audio while streaming.
  • Switch camera while streaming.
  • Change video bitrate while streaming (API 19+).
  • AV1, H264, H265, G711 and AAC hardware/software encoding.
  • Force video and audio Codec to use hardware/software encoding (Not recommended).
  • Record MP4 file while streaming (API 18+).
  • Set Image, Gif or Text to stream on real time.
  • OpenGL real time filters. More info
  • Stream from video and audio files like mp4, webm, mp3, etc (Limited by device decoders). More info
  • Stream device screen (API 21+).

RTMP:

  • Get upload bandwidth used.
  • RTSP auth (adobe and llnw).
  • H264, AV1, H265 (Using RTMP enhanced), AAC and G711 support.
  • RTMPS (under TLS)
  • RTMPT and RTMPTS (tunneled and tunneled under TLS)
  • AMF0
  • AMF3

RTSP:

  • Get upload bandwidth used.
  • RTMP auth (basic and digest).
  • AV1, H264, H265, AAC and G711 support.
  • TCP/UDP.
  • RTSPS.

SRT (beta):

  • Get upload bandwidth used.
  • H264, H265 and AAC support.
  • Resend lost packets
  • Encrypt (AES128, AES192 and AES256)
  • SRT auth.

https://haivision.github.io/srt-rfc/draft-sharabayko-srt.html

https://github.com/pedroSG94/RTSP-Server

https://github.com/pedroSG94/AndroidReStreamer

https://github.com/pedroSG94/Stream-USB-test

3rd party projects:

Projects related with the library developed by other users.
Contact with user owner if you have any problem or question.

https://github.com/FunnyDevs/rtmp-rtsp-stream-client-java-recordcontrollers

Real time filters:

NOTE:

In library version 2.0.9, the filters was refactored. Check the wiki link to migrate your implementation.

https://github.com/pedroSG94/RootEncoder/wiki/Real-time-filters

Looking for sponsors

This library need sponsors to get new devices or pay platforms to test and debug errors. Any donation or sponsor is welcome!
If you are interested. You can contact me by email or donate directly on Github or Paypal
Thank you!

Use example:

This code is a basic example.
I recommend you go to Activities in app module and see all examples.

RTMP:


//default

//create builder
RtmpCamera1 rtmpCamera1 = new RtmpCamera1(openGlView, connectCheckerRtmp);
//start stream
if (rtmpCamera1.prepareAudio() && rtmpCamera1.prepareVideo()) {
  rtmpCamera1.startStream("rtmp://yourEndPoint");
} else {
 /**This device cant init encoders, this could be for 2 reasons: The encoder selected doesnt support any configuration setted or your device hasnt a H264 or AAC encoder (in this case you can see log error valid encoder not found)*/
}
//stop stream
rtmpCamera1.stopStream();

//with params

//create builder
RtmpCamera1 rtmpCamera1 = new RtmpCamera1(openGlView, connectCheckerRtmp);
//start stream
if (rtmpCamera1.prepareAudio(int bitrate, int sampleRate, boolean isStereo, boolean echoCanceler,
      boolean noiseSuppressor) && rtmpCamera1.prepareVideo(int width, int height, int fps, int bitrate, int rotation)) {
  rtmpCamera1.startStream("rtmp://yourEndPoint");
} else {
 /**This device cant init encoders, this could be for 2 reasons: The encoder selected doesnt support any configuration setted or your device hasnt a H264 or AAC encoder (in this case you can see log error valid encoder not found)*/
}
//stop stream
rtmpCamera1.stopStream();

RTSP:


//default

//create builder
//by default TCP protocol.
RtspCamera1 rtspCamera1 = new RtspCamera1(openGlView, connectCheckerRtsp);
//start stream
if (rtspCamera1.prepareAudio() && rtspCamera1.prepareVideo()) {
  rtspCamera1.startStream("rtsp://yourEndPoint");
} else {
 /**This device cant init encoders, this could be for 2 reasons: The encoder selected doesnt support any configuration setted or your device hasnt a H264 or AAC encoder (in this case you can see log error valid encoder not found)*/
}
//stop stream
rtspCamera1.stopStream();

//with params

//create builder
RtspCamera1 rtspCamera1 = new RtspCamera1(openGlView, connectCheckerRtsp);
rtspCamera1.setProtocol(protocol);
//start stream
if (rtspCamera1.prepareAudio(int bitrate, int sampleRate, boolean isStereo, boolean echoCanceler,
      boolean noiseSuppressor) && rtspCamera1.prepareVideo(int width, int height, int fps, int bitrate, int rotation)) {
  rtspCamera1.startStream("rtsp://yourEndPoint");
} else {
 /**This device cant init encoders, this could be for 2 reasons: The encoder selected doesnt support any configuration setted or your device hasnt a H264 or AAC encoder (in this case you can see log error valid encoder not found)*/
}
//stop stream
rtspCamera1.stopStream();

主要指标

概览
名称与所有者pedroSG94/RootEncoder
主编程语言Kotlin
编程语言Java (语言数: 3)
平台
许可证Apache License 2.0
所有者活动
创建于2017-01-21 19:32:49
推送于2025-04-18 21:04:58
最后一次提交2025-04-18 22:56:06
发布数164
最新版本名称2.5.9 (发布于 )
第一版名称v1.0.0 (发布于 )
用户参与
星数2.7k
关注者数76
派生数815
提交数2k
已启用问题?
问题数1457
打开的问题数135
拉请求数197
打开的拉请求数1
关闭的拉请求数64
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?