RootEncoder Documentation

repository·master·Indexed 25 days ago

https://github.com/pedrosg94/rootencoder

An Android library written in Java/Kotlin for encoding and pushing video and audio streams to media servers. It supports protocols including RTMP, RTSP, SRT, UDP, and WHIP (beta), with support for various codecs such as H264, H265, AV1, and AAC.

Tokens
807
Snippets
2
Records
5
Agent score
34%

What's inside RootEncoder

  1. Configure Android Permissions for RootEncoder

    master

    RootEncoder requires the following permissions in your AndroidManifest.xml to access the internet, microphone, and camera:

    • android.permission.INTERNET
    • android.permission.RECORD_AUDIO
    • android.permission.CAMERA
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.CAMERA" />
  2. View RootEncoder Usage Examples

    master

    The repository provides several implementation examples for different use cases:

    • Rotation Example: Recommended for handling screen rotation, stream orientation (vertical/horizontal), filters, and switching sources on the fly.
    • Screen Example: For streaming the device screen using a service to allow background streaming.
    • From File Example: For streaming video and audio files (e.g., mp4, webm, mp3).
    • Old API Example: For supporting low API devices (Android API 16+).
  3. Install RootEncoder via Gradle

    master

    To use RootEncoder in your Android project, add the JitPack repository to your allprojects block and include the library dependencies in your dependencies block.

    For the latest version (2.8.0), include the library dependency. If you need support for CameraXSource or CameraUvcSource, you must also include the extra-sources dependency.

    allprojects {
      repositories {
        maven { url 'https://jitpack.io' }
      }
    }
    dependencies {
      implementation "com.github.pedroSG94.RootEncoder:library:2.8.0"
      //Optional, allow use CameraXSource and CameraUvcSource 
      implementation "com.github.pedroSG94.RootEncoder:extra-sources:2.8.0"
    }
  4. Supported Streaming Protocols

    master

    RootEncoder supports pushing video/audio to media servers using several protocols:

    • RTMP: Supports RTMPS (under TLS), RTMPT, and RTMPTS (tunneled under TLS). Supports AV1, H265 (via enhanced RTMP), H264, VP8, VP9, AAC, HE-AAC, and G711.
    • RTSP: Supports TCP/UDP and RTSPS. Supports AV1, H264, H265, AAC, HE-AAC, G711, and OPUS.
    • SRT: Supports H264, H265, AAC, HE-AAC, and OPUS. Includes packet resending and encryption (AES128, AES192, AES256).
    • UDP: Supports Unicast, Multicast, and Broadcast. Supports MPEG2-TS.
    • WHIP (beta): Supports H264, H265, AV1, VP8, VP9, G711, and OPUS. Uses bearer token authentication.
  5. Configure AAC audio specific settings with AacAudioSpecificConfig

    master

    Use the AacAudioSpecificConfig class to generate the necessary configuration byte array for AAC audio encoding (ISO 14496-3). This is used to define the audio object type, sampling frequency, and channel configuration for the encoder.

    Supported types include:

    • AudioObjectType.AAC_LC: Standard AAC Low Complexity.
    • AudioObjectType.AAC_SBR: AAC with Spectral Band Replication extension.

    The calculate() method returns a ByteArray containing the configuration bits required by the encoder.