Software developers at work.

Using OpenSDK Android RTMP Features

This article will demonstrate how you can use the various features of the Android RTMP OpenSDK tool.

Camera View

Make sure you call the start method on the camera view before streaming. The start method will enable the frames from the camera to get rendered to the user and will send the actual data to the encoder part.

If the start method is not called, the encoder will have no frames to publish.


Start and Stop Publishing

To start publishing a video via Android RTMP, call the startPublish method on the StreamaxiaPublisher instance. The method requires the URL of the endpoint. Note that you need to provide your own media server or CDN, like AWS.


To stop publishing just call the stopPublish method on the StreamaxiaPublisher instance.


Start, Stop, Pause and Resume Recording

To start recording (saving locally) the video, just call startRecord on the StreamaxiaPublisher instance.


The method requires as a parameter the patch where to save the video. For example:

private static final String recPath = 
                       Environment.getExternalStorageDirectory().getPath() + "/test.mp4";

To stop the recording just call stopRecord on the object.


To pause the recording just call pauseRecord on the object.


The difference between pause and stop is that when you call stopRecord, the video will be ended and saved locally on the given path. If you paused a video, you can resume (continue) the video with the resumeRecord method.


Handling Configuration Changes (API 18+)

The Android RTMP SDK also supports orientation changes before the streaming is started. In order for this to be possible, you need to declare inside your Activity field in the AndroidManifest.xml file the following:


Then in the Activity override the on configuration changed method as follows:

public void onConfigurationChanged(Configuration newConfig) {

    //Update the orientation for stream


    //The new orientation might not support the current resolution

    Size supportedRes = mStreamaxiaPublisher.getSupportedPictureSizes(newConfig.orientation).get(0);


By doing so, the user will be able to choose the orientation of the stream(portrait or landscape) by rotating the device, before the streaming is started

While streaming, the Activity will be locked on the current position and after finishing the streaming, it will be unlocked and the orientation can be changed again.

This feature can be disabled and you can choose only one orientation, as follows:





By doing so, you will need to lock also the activity’s orientation from the AndroidManifest.xml file as follows:





You can also take screenshots at any point using the following code:

mCameraView.takeSnapshot(new CameraPreview.SnapshotCallback() {


     public void onSnapshotTaken(Bitmap image) {

         //Do something with the snapshot




Realtime zooming in/out is also supported, you can use the following API:

// Get zoom range

int[] range = mCameraView.getZoomRange();

// Set max zoom


Framerate and keyframe interval can be set BEFORE starting the Android RTMP stream using:

// Set the framerate to 30fps, we can also use the getter to check the value


// Set the keyframe interval to 5 seconds, we can also use the getter to check the value


NOTE : we do not support reverse landscape nor reverse portrait!

Share This Story, Choose Your Platform!