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.51k stars 766 forks source link

非常给力! Any thoughts on adding support for H.265 software encoding?Like X265. #1464

Open yunianvh opened 4 months ago

pedroSG94 commented 4 months ago

Hello,

Currently you can use software encoders with MediaCodec class. The library is configured to use hardware encoder if possible but you can force software encoders like this:

genericStream.forceCodecType(CodecUtil.CodecType.SOFTWARE, CodecUtil.CodecType.FIRST_COMPATIBLE_FOUND)

For now, I only have plan to add support to codecs availables in MediaCodec class

yunianvh commented 3 months ago

Valid encoder not found

log

2024-05-11 11:48:26.029 8798-8798 VideoCapabilities com.pedro.streamer W Unrecognized profile/level 1/32 for video/mp4v-es 2024-05-11 11:48:26.030 8798-8798 VideoCapabilities com.pedro.streamer W Unrecognized profile/level 32768/2 for video/mp4v-es 2024-05-11 11:48:26.030 8798-8798 VideoCapabilities com.pedro.streamer W Unrecognized profile/level 32768/64 for video/mp4v-es 2024-05-11 11:48:26.045 8798-8798 VideoCapabilities com.pedro.streamer W Unsupported mime video/x-ms-wmv 2024-05-11 11:48:26.048 8798-8823 BufferQueueProducer com.pedro.streamer I SurfaceTexture-1-8798-0 queueBuffer: slot 2 is dropped, handle=0x7baf2b8c00 2024-05-11 11:48:26.050 8798-8798 VideoCapabilities com.pedro.streamer W Unsupported mime video/xvid 2024-05-11 11:48:26.065 8798-8798 VideoCapabilities com.pedro.streamer W Unrecognized profile/level 1/32 for video/mp4v-es 2024-05-11 11:48:26.082 8798-8823 BufferQueueProducer com.pedro.streamer I SurfaceTexture-1-8798-0 queueBuffer: slot 3 is dropped, handle=0x7baf2b8d80 2024-05-11 11:48:26.114 8798-8823 BufferQueueProducer com.pedro.streamer I SurfaceTexture-1-8798-0 queueBuffer: slot 7 is dropped, handle=0x7baa713d00 2024-05-11 11:48:26.136 8798-8798 AudioEncoder com.pedro.streamer I 2 encoders found 2024-05-11 11:48:26.136 8798-8798 AudioEncoder com.pedro.streamer I Encoder selected c2.android.aac.encoder 2024-05-11 11:48:26.149 8798-8823 BufferQueueProducer com.pedro.streamer I SurfaceTexture-1-8798-0 queueBuffer: slot 5 is dropped, handle=0x7b4da356c0 2024-05-11 11:48:26.176 8798-9077 CCodec com.pedro.streamer D allocate(c2.android.aac.encoder) 2024-05-11 11:48:26.180 8798-9077 Codec2Client com.pedro.streamer I Available Codec2 services: "software" 2024-05-11 11:48:26.180 8798-9077 Codec2Client com.pedro.streamer I Creating a Codec2 client to service "software" 2024-05-11 11:48:26.182 8798-9077 Codec2Client com.pedro.streamer I Client to Codec2 service "software" created 2024-05-11 11:48:26.183 8798-8823 BufferQueueProducer com.pedro.streamer I SurfaceTexture-1-8798-0 queueBuffer: slot 6 is dropped, handle=0x7b4da35840 2024-05-11 11:48:26.188 8798-9077 CCodec com.pedro.streamer I Created component [c2.android.aac.encoder] 2024-05-11 11:48:26.189 8798-9077 CCodecConfig com.pedro.streamer D read media type: audio/mp4a-latm 2024-05-11 11:48:26.192 8798-9077 ReflectedParamUpdater com.pedro.streamer D extent() != 1 for single value type: algo.buffers.max-count.values 2024-05-11 11:48:26.193 8798-9077 ReflectedParamUpdater com.pedro.streamer D extent() != 1 for single value type: output.subscribed-indices.values 2024-05-11 11:48:26.193 8798-9077 ReflectedParamUpdater com.pedro.streamer D extent() != 1 for single value type: input.buffers.allocator-ids.values 2024-05-11 11:48:26.193 8798-9077 ReflectedParamUpdater com.pedro.streamer D extent() != 1 for single value type: output.buffers.allocator-ids.values 2024-05-11 11:48:26.193 8798-9077 ReflectedParamUpdater com.pedro.streamer D extent() != 1 for single value type: algo.buffers.allocator-ids.values 2024-05-11 11:48:26.194 8798-9077 ReflectedParamUpdater com.pedro.streamer D extent() != 1 for single value type: output.buffers.pool-ids.values 2024-05-11 11:48:26.194 8798-9077 ReflectedParamUpdater com.pedro.streamer D extent() != 1 for single value type: algo.buffers.pool-ids.values 2024-05-11 11:48:26.199 8798-9077 CCodecConfig com.pedro.streamer I query failed after returning 9 values (BAD_INDEX) 2024-05-11 11:48:26.199 8798-9077 CCodecConfig com.pedro.streamer D c2 config is Dict { c2::u32 coded.bitrate.value = 64000 c2::u32 coded.pl.level = 0 c2::u32 coded.pl.profile = 8192 c2::u32 coding.aac-sbr-mode.value = 3 c2::u32 input.buffers.max-size.value = 2048 c2::u32 input.delay.value = 0 string input.media-type.value = "audio/raw" string output.media-type.value = "audio/mp4a-latm" c2::u32 raw.channel-count.value = 1 c2::u32 raw.sample-rate.value = 44100 } 2024-05-11 11:48:26.203 8798-9077 MediaCodec com.pedro.streamer I MediaCodec will operate in async mode 2024-05-11 11:48:26.203 8798-9077 CCodecConfig com.pedro.streamer D no c2 equivalents for aac-profile 2024-05-11 11:48:26.203 8798-9077 CCodecConfig com.pedro.streamer D no c2 equivalents for encoder 2024-05-11 11:48:26.205 8798-9077 CCodecConfig com.pedro.streamer D c2 config is Dict { c2::u32 coded.bitrate.value = 65536 c2::u32 coded.pl.level = 0 c2::u32 coded.pl.profile = 8192 c2::u32 coding.aac-sbr-mode.value = 3 c2::u32 input.buffers.max-size.value = 4096 c2::u32 input.delay.value = 0 string input.media-type.value = "audio/raw" string output.media-type.value = "audio/mp4a-latm" c2::u32 raw.channel-count.value = 2 c2::u32 raw.sample-rate.value = 32000 } 2024-05-11 11:48:26.206 8798-9077 Codec2Client com.pedro.streamer W query -- param skipped: index = 1107298332. 2024-05-11 11:48:26.206 8798-9077 CCodec com.pedro.streamer D setup formats input: AMessage(what = 0x00000000) = { int32_t channel-count = 2 int32_t max-input-size = 5120 string mime = "audio/raw" int32_t sample-rate = 32000 } and output: AMessage(what = 0x00000000) = { int32_t bitrate = 65536 int32_t channel-count = 2 int32_t level = 0 int32_t max-bitrate = 65536 string mime = "audio/mp4a-latm" int32_t profile = 2 int32_t sample-rate = 32000 } 2024-05-11 11:48:26.207 8798-8798 AudioEncoder com.pedro.streamer I prepared 2024-05-11 11:48:26.211 8798-8798 VideoEncoder com.pedro.streamer I 0 encoders found 2024-05-11 11:48:26.211 8798-8798 VideoEncoder com.pedro.streamer E Valid encoder not found 2024-05-11 11:48:26.216 8798-8823 BufferQueueProducer com.pedro.streamer I SurfaceTexture-1-8798-0 queueBuffer: slot 0 is dropped, handle=0x7baf2b80c0 2024-05-11 11:48:26.243 8798-8798 ViewRootImpl[Toast] com.pedro.streamer D hardware acceleration = true , fakeHwAccelerated = false, sRendererDisabled = false, forceHwAccelerated = false, sSystemRendererDisabled = false 2024-05-11 11:48:26.252 8798-8798 InputTransport com.pedro.streamer I Create ARC handle: 0x7b553ff180 2024-05-11 11:48:26.286 8798-8798 GraphicExt com.pedro.streamer E GraphicExtModuleLoader::CreateGraphicExtInstance false

pedroSG94 commented 3 months ago

Hello,

In that case you haven't software video encoder in your device. You will have to use hardware encoder. I'm not sure which device you are using because normally Android always provide software encoders.