pedroSG94 / RootEncoder

RootEncoder for Android (rtmp-rtsp-stream-client-java) is a stream encoder to push video/audio to media servers using protocols RTMP, RTSP, SRT and UDP with all code written in Java/Kotlin
Apache License 2.0
2.52k stars 768 forks source link

how to record mp4 files in audio format g711a #1465

Open lhf-Alice opened 4 months ago

pedroSG94 commented 4 months ago

Hello,

Currently the library has 2 ways to record files by default: https://github.com/pedroSG94/RootEncoder/blob/master/library/src/main/java/com/pedro/library/util/AndroidMuxerRecordController.java https://github.com/pedroSG94/RootEncoder/blob/master/library/src/main/java/com/pedro/library/util/AacMuxerRecordController.java The first one is based on MediaMuxer class of Android and the second record AAC data directly in a file.

I think that MediaMuxer can't record with g711a codec. You can check it here (scroll a bit and you have a list of supported codecs): https://developer.android.com/reference/android/media/MediaMuxer#addTrack(android.media.MediaFormat) You can create your own muxer to support g711a. You only need create a class that extends from BaseRecordController class and implement your code in that class. After that you need set this class to the library as the new BaseRecordController like this:

genericStream.setRecordController(CustomRecordController())

This allow you a way to record any codec in any file format with your own implementation

pedroSG94 commented 4 months ago

You have a project developed by other user that maybe help you with that: https://github.com/FunnyDevs/rtmp-rtsp-stream-client-java-recordcontrollers?tab=readme-ov-file Since it is using FFMPEG to record (XugglerReccordController), maybe you can update the implementation to support your required codecs.