Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid AudioEncoder initialization on an Video only stream #1714

Open
hdralexandru opened this issue Feb 10, 2025 · 1 comment
Open

Avoid AudioEncoder initialization on an Video only stream #1714

hdralexandru opened this issue Feb 10, 2025 · 1 comment

Comments

@hdralexandru
Copy link

Is it possible to avoid the MediaCodec's initialization when using NoAudioSource?

I am trying to implement the RTSP-Server on a custom Android OS. When I call prepareAudio, I get the following error:

02-10 17:34:14.300 25930 26066 I MediaCodec: MediaCodec will operate in async mode
02-10 17:34:14.301 25930 25930 E AudioEncoder: Create AudioEncoder failed.
02-10 17:34:14.301 25930 25930 E AudioEncoder: android.media.MediaCodec$CodecException: Error 0x80001001
02-10 17:34:14.301 25930 25930 E AudioEncoder: 	at android.media.MediaCodec.native_configure(Native Method)
02-10 17:34:14.301 25930 25930 E AudioEncoder: 	at android.media.MediaCodec.configure(MediaCodec.java:2176)
02-10 17:34:14.301 25930 25930 E AudioEncoder: 	at android.media.MediaCodec.configure(MediaCodec.java:2092)
02-10 17:34:14.301 25930 25930 E AudioEncoder: 	at com.pedro.encoder.audio.AudioEncoder.prepareAudioEncoder(AudioEncoder.java:95)
02-10 17:34:14.301 25930 25930 E AudioEncoder: 	at com.pedro.library.base.StreamBase.prepareAudio(StreamBase.kt:142)

My stream is video only. For VideoSource, am I using a clone of BitmapSource, but instead of a single image, I am looping through 20 bitmaps.

When I init the server, I do

 RtspServerStream(
    context = context,
    port = 1935,
    connectChecker = connectChecker,
    audioSource = NoAudioSource(),
    videoSource = BitmapSource(context),
)
rtspServer.setOnlyVideo(true)
prepareAudio(
    sampleRate = 0, isStereo = false, bitrate = 0,
    echoCanceler = false, noiseSuppressor = false
)

However, the project works perfectly on a normal mobile AndroidOS (tested on Android 15 on a Samsung and Android 14 on a Pixel5, tested on an Pixel8 emulator - all work). I can connect to them through VLC flawlessly.

Basically I'm trying to disable audio altogether.
Is it possible to avoid the call to prepareAudioEncode ?

@pedroSG94
Copy link
Owner

pedroSG94 commented Feb 10, 2025

Hello,

I have no plan to do it because the idea is be able to change the audio source on fly so the audio codec initialization is required to work.
I recommend you use a real value in the prepareAudio parameters instead of set invalid values. Try with samplerate 32000 and bitrate 128000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants