RootEncoder icon indicating copy to clipboard operation
RootEncoder copied to clipboard

Is there any code sample to use it with android audio recording and broadcast to RTSP server

Open rescue1155 opened this issue 1 year ago • 10 comments

Hey there,

Is there any code sample in JAVA to use it with android audio recording and broadcast to RTSP server ?

thanks

rescue1155 avatar Apr 16 '24 13:04 rescue1155

Hello,

If you only want audio you can try this way:

        int bitrate = 128 * 1000;
        int samplerate = 44100;
        boolean isStereo = true;
        RtspOnlyAudio rtspOnlyAudio = new RtspOnlyAudio(connectChecker);
       //start stream
        if (rtspOnlyAudio.prepareAudio(bitrate, samplerate, isStereo)) {
            rtspOnlyAudio.startStream(url);
        }
       //stop stream
        rtspOnlyAudio.stopStream();

pedroSG94 avatar Apr 16 '24 13:04 pedroSG94

Hello Pedro, I used RtspOnlyAudio with the Opus codec. The streaming works perfectly, but the audio file produced by the startRecord method is not playable. Is there a specific setting I need to adjust? Thanks!

legosaro avatar Sep 23 '24 14:09 legosaro

Hello,

Record a file using opus is not allowed. The app should crash if you try to record using g711 or opus. This is a bug.

pedroSG94 avatar Sep 23 '24 16:09 pedroSG94

The reason is that the currents record controller implementations don't support g711 or opus.

You can create your own implementation to support it.

pedroSG94 avatar Sep 23 '24 16:09 pedroSG94

Maybe I can add an implementation for it. Maybe using a media muxer to create a webm or ogg file this can works

pedroSG94 avatar Sep 23 '24 17:09 pedroSG94

Hello,

I added a RecordController to allow record webm files that support Opus codec: https://github.com/pedroSG94/RootEncoder/commit/a069fa6438339a922ff81befc5a9eaeeeb72bd75

This will be available in the next version. Meanwhile you can copy that class and set the record controller using setRecordController. Remember save the file with name extension webm.

pedroSG94 avatar Sep 23 '24 18:09 pedroSG94

Hello,

Thank you very much, Pedro. The new RecordController solves my problem. Will it be possible to use Opus for video recording in the future?

legosaro avatar Sep 24 '24 10:09 legosaro

Hello,

Webm only supports VP8 and VP9 video codecs so It will be possible only when I add support for those codecs.

I have plans to support at least VP9 in RTMP and RTSP but it is not a priority.

pedroSG94 avatar Sep 24 '24 10:09 pedroSG94

Hello, I was wondering if there have been any developments regarding VP9 support over RTSP since we last spoke. Even an experimental implementation would be of great interest.

Best regards

legosaro avatar May 29 '25 08:05 legosaro

Hello,

No, it is not under development yet.

pedroSG94 avatar May 29 '25 13:05 pedroSG94