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

Problems on compile decoder_ffmpeg extension #2071

Closed
lonewolf73 opened this issue Jan 23, 2025 · 6 comments
Closed

Problems on compile decoder_ffmpeg extension #2071

lonewolf73 opened this issue Jan 23, 2025 · 6 comments
Assignees
Labels

Comments

@lonewolf73
Copy link

Hello everyone,

I am trying to compile decoder_ffmpeg extension to obtain a libffmpegJNI.so in all architectures or even a libffmpegJNI.aar , to include in my android java project on Ubuntu 20.04LTS platform but I encounter some problems....

  1. Platform : Ubuntu 20.04LTS
  2. CMake : 3.31.4 (I even tried before with version 3.22.6)
  3. I downloaded NDK r26b as suggested by README.md ( 26.1.10909125 ) and I downloaded and installed also the latest r27c ( 27.2.12479018 ) due I encountered during Android Studio "Make Module androidx.media3.lib-decoder-ffmpeg" a problem about iconv library not found...
  4. I installed Opus 1.5.2 from opus-codec.org (I did ./configure , sudo make , sudo make install) to have latest libopus which could decode pure opus audio.
  5. I installed first Ffmpeg following the readme and running git checkout release/6.0 (running ffmpeg -version I obtained a 6.0.2 version compiled by native gcc 9 of Ubuntu 9.4.0-1ubuntu1-20.04.2 ) but once encountering problems, maybe because CMake 3.31.4 is quite new, then I reinstalled latest Ffmpeg 7.1 (ffmpeg version N-118350-ge20ee9f9ae Copyright (c) 2000-2025 the FFmpeg developers) , both versions applying --enable-libopus parameter;
  6. I have set Gradle 8.6 and AGP 8.4.2 on Android Studio
  7. I set ANDROID_ABI to 28 so I set minSdk in gradle files to 28 because having most recent opus and ffmpeg should be more compatible with recent Android app versions
  8. I set in build.gradle of ffmpeg extension as like :
/ Copyright (C) 2016 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
apply from: "$gradle.ext.androidxMediaSettingsDir/common_library_config.gradle"

android {
    namespace 'androidx.media3.decoder.ffmpeg'
    compileSdk project.ext.compileSdkVersion
    ndkVersion "26.1.10909125"
    //ndkVersion "27.2.12479018"
    // TODO(Internal: b/372449691): Remove packagingOptions once AGP is updated
    // to version 8.5.1 or higher.
    packagingOptions {
        jniLibs {
            useLegacyPackaging true
        }
    }
    defaultConfig {
        //minSdkVersion project.ext.minSdkVersion
        minSdk project.ext.minSdkVersion
    }
}

// Configure the native build only if ffmpeg is present to avoid gradle sync
// failures if ffmpeg hasn't been built according to the README instructions.
if (project.file('src/main/jni/ffmpeg').exists()) {
    android.externalNativeBuild.cmake.path = 'src/main/jni/CMakeLists.txt'
    // Should match cmake_minimum_required.
    android.externalNativeBuild.cmake.version = '3.31.4'
    //android.externalNativeBuild.cmake.version = '3.21.0+'
}

dependencies {
    implementation project(modulePrefix + 'lib-decoder')
    // TODO(b/203752526): Remove this dependency.
    implementation project(modulePrefix + 'lib-exoplayer')
    implementation 'androidx.annotation:annotation:' + androidxAnnotationVersion
    compileOnly 'org.checkerframework:checker-qual:' + checkerframeworkVersion
    compileOnly 'org.jetbrains.kotlin:kotlin-annotations-jvm:' + kotlinAnnotationsVersion
    testImplementation project(modulePrefix + 'test-utils')
    testImplementation 'org.robolectric:robolectric:' + robolectricVersion
}

In both cases with NDK r26b and r27c if I ran build_ffmpeg.sh ( sudo ./build_ffmpeg.sh "${FFMPEG_MODULE_PATH}" "${NDK_PATH}" "${HOST_PLATFORM}" "${ANDROID_ABI}" "${ENABLED_DECODERS[@]}" ) with those options (in particular for audio, I had to modify a bit the sh with COMMON_OPTIONS="${COMMON_OPTIONS} --enable-decoder=opus --enable-decoder=libopus --enable-decoder=pcm_alaw" ) due I included libopus in the linked ffmpeg .... it completed but it didn't produced any .so / .aar files... I encountered indeed :

WARNING: /home/user/DevTools/Android/ndk/26.1.10909125/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android28-pkg-config not found, library detection may fail.
WARNING: Disabled libopus_decoder because not all dependencies are satisfied: libopus

so I think those two messages are just warnings but probably they are mandaroty.
I tried to create local toolchain using make_standalone_toolchain.py in ../26.1.10909125/build/tools but once created I searched inside for that pkg-config but wasn't present so for this part , shall I have to modify something somewhere to make it complete the build_ffmpeg.sh creating those .so / .aar file correctly?

Instead if I try to build using ./gradlew lib-decoder-ffmpeg:assembleRelease from media3 root directory ( it installed the gradle 8.6-all ) I get those errors:

> Task :lib-decoder-ffmpeg:processReleaseManifest
package="androidx.media3.decoder.ffmpeg" found in source AndroidManifest.xml: /home/user/projects/media3/libraries/decoder_ffmpeg/src/main/AndroidManifest.xml.
Setting the namespace via the package attribute in the source AndroidManifest.xml is no longer supported, and the value is ignored.
Recommendation: remove package="androidx.media3.decoder.ffmpeg" from the source AndroidManifest.xml: /home/user/projects/media3/libraries/decoder_ffmpeg/src/main/AndroidManifest.xml.

> Task :lib-exoplayer:compileReleaseJavaWithJavac
/home/user/projects/media3/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/LoudnessCodecController.java:21: error: package android.media.LoudnessCodecController does not exist
import android.media.LoudnessCodecController.OnLoudnessCodecUpdateListener;
                                            ^
/home/user/projects/media3/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/LoudnessCodecController.java:53: error: cannot find symbol
  @Nullable private android.media.LoudnessCodecController loudnessCodecController;
                                 ^
  symbol:   class LoudnessCodecController
  location: package android.media
/home/user/projects/media3/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/MediaCodecInfo.java:685: error: cannot find symbol
        && capabilities.isFeatureSupported(CodecCapabilities.FEATURE_DetachedSurface);
                                                            ^
  symbol:   variable FEATURE_DetachedSurface
  location: class CodecCapabilities
/home/user/projects/media3/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/LoudnessCodecController.java:81: error: cannot find symbol
    android.media.LoudnessCodecController loudnessCodecController =
                 ^
  symbol:   class LoudnessCodecController
  location: package android.media
/home/user/projects/media3/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/LoudnessCodecController.java:85: error: cannot find symbol
            new OnLoudnessCodecUpdateListener() {
                ^
  symbol:   class OnLoudnessCodecUpdateListener
  location: class LoudnessCodecController
/home/user/projects/media3/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/LoudnessCodecController.java:86: error: method does not override or implement a method from a supertype
              @Override
              ^
/home/luigip/projects/media3/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/LoudnessCodecController.java:82: error: cannot find symbol
        android.media.LoudnessCodecController.create(
                     ^
  symbol:   class LoudnessCodecController
  location: package android.media
/home/user/projects/media3/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/SynchronousMediaCodecAdapter.java:58: error: cannot find symbol
          flags |= MediaCodec.CONFIGURE_FLAG_DETACHED_SURFACE;
                             ^
  symbol:   variable CONFIGURE_FLAG_DETACHED_SURFACE
  location: class MediaCodec
/home/user/projects/media3/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/SynchronousMediaCodecAdapter.java:200: error: cannot find symbol
    codec.detachOutputSurface();
         ^
  symbol:   method detachOutputSurface()
  location: variable codec of type MediaCodec
/home/user/projects/media3/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/AsynchronousMediaCodecAdapter.java:126: error: cannot find symbol
          flags |= MediaCodec.CONFIGURE_FLAG_DETACHED_SURFACE;
                             ^
  symbol:   variable CONFIGURE_FLAG_DETACHED_SURFACE
  location: class MediaCodec
/home/user/projects/media3/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/AsynchronousMediaCodecAdapter.java:322: error: cannot find symbol
    codec.detachOutputSurface();
         ^
  symbol:   method detachOutputSurface()
  location: variable codec of type MediaCodec
warning: unknown enum constant Level.FULL
  reason: class file for com.google.j2objc.annotations.ReflectionSupport$Level not found
/home/user/projects/media3/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/video/MediaCodecVideoRenderer.java:1889: error: cannot find symbol
      codecParameters.putInt(MediaFormat.KEY_IMPORTANCE, max(0, -rendererPriority));
                                        ^
  symbol:   variable KEY_IMPORTANCE
  location: class MediaFormat
/home/user/projects/media3/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/video/MediaCodecVideoRenderer.java:2034: error: cannot find symbol
      mediaFormat.setInteger(MediaFormat.KEY_IMPORTANCE, max(0, -rendererPriority));
                                        ^
  symbol:   variable KEY_IMPORTANCE
  location: class MediaFormat
/home/user/projects/media3/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/DefaultSuitableOutputChecker.java:96: error: cannot find symbol
    int transferReason = router.getSystemController().getRoutingSessionInfo().getTransferReason();
                                                                             ^
  symbol:   method getTransferReason()
  location: class RoutingSessionInfo
/home/user/projects/media3/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/DefaultSuitableOutputChecker.java:97: error: cannot find symbol
    boolean wasTransferInitiatedBySelf = router.getSystemController().wasTransferInitiatedBySelf();
                                                                     ^
  symbol:   method wasTransferInitiatedBySelf()
  location: class MediaRouter2.RoutingController
/home/user/projects/media3/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/DefaultSuitableOutputChecker.java:108: error: cannot find symbol
    int suitabilityStatus = routeInfo.getSuitabilityStatus();
                                     ^
  symbol:   method getSuitabilityStatus()
  location: variable routeInfo of type MediaRoute2Info
/home/user/projects/media3/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/DefaultSuitableOutputChecker.java:110: error: cannot find symbol
    if (suitabilityStatus == MediaRoute2Info.SUITABILITY_STATUS_SUITABLE_FOR_MANUAL_TRANSFER) {
                                            ^
  symbol:   variable SUITABILITY_STATUS_SUITABLE_FOR_MANUAL_TRANSFER
  location: class MediaRoute2Info
/home/user/projects/media3/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/DefaultSuitableOutputChecker.java:111: error: cannot find symbol
      return (transferReason == RoutingSessionInfo.TRANSFER_REASON_SYSTEM_REQUEST
                                                  ^
  symbol:   variable TRANSFER_REASON_SYSTEM_REQUEST
  location: class RoutingSessionInfo
/home/user/projects/media3/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/DefaultSuitableOutputChecker.java:112: error: cannot find symbol
              || transferReason == RoutingSessionInfo.TRANSFER_REASON_APP)
                                                     ^
  symbol:   variable TRANSFER_REASON_APP
  location: class RoutingSessionInfo
/home/luigip/projects/media3/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/DefaultSuitableOutputChecker.java:116: error: cannot find symbol
    return suitabilityStatus == MediaRoute2Info.SUITABILITY_STATUS_SUITABLE_FOR_DEFAULT_TRANSFER;
                                               ^
  symbol:   variable SUITABILITY_STATUS_SUITABLE_FOR_DEFAULT_TRANSFER
  location: class MediaRoute2Info
/home/user/projects/media3/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/audio/MediaCodecAudioRenderer.java:1014: error: cannot find symbol
      mediaFormat.setInteger(MediaFormat.KEY_IMPORTANCE, max(0, -rendererPriority));
                                        ^
  symbol:   variable KEY_IMPORTANCE
  location: class MediaFormat
/home/user/projects/media3/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/audio/MediaCodecAudioRenderer.java:1034: error: cannot find symbol
      codecParameters.putInt(MediaFormat.KEY_IMPORTANCE, max(0, -rendererPriority));
                                        ^
  symbol:   variable KEY_IMPORTANCE
  location: class MediaFormat
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
22 errors
1 warning

> Task :lib-exoplayer:compileReleaseJavaWithJavac FAILED

FAILURE: Build failed with an exception.
  • What went wrong:
    Execution failed for task ':lib-exoplayer:compileReleaseJavaWithJavac'.

Compilation failed; see the compiler error output for details.

  • Try:

Run with --info option to get more log output.
Run with --scan to get full insights.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/8.6/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.

BUILD FAILED in 38s

In this case , does maybe depend from the Gradle version itself and maybe shall I have to upgrade to Gradle 8.9 with AGP 8.7.x since they are anyway supported by Java 17 which is currently installed ?

Thanks in advance to all!
Cheers
Luigi

@tonihei
Copy link
Collaborator

tonihei commented Jan 24, 2025

Instead if I try to build using ./gradlew lib-decoder-ffmpeg:assembleRelease from media3 root directory ( it installed the gradle 8.6-all ) I get those errors

These errors indicate the compileSdk in your project is set to less than 35. That's the reason it can't find the symbols.

I haven't looked into your ffmpeg build problems, but if your goal is to bundle support for OPUS specifically, I'd recommend to use the opus extension directly without going through ffmpeg. Our instructions also don't include downloading libopus specifically. Did you follow the steps in the README exactly and did they work?

@tonihei tonihei self-assigned this Jan 24, 2025
@lonewolf73
Copy link
Author

Hi @tonihei and everyone here ! Thanks for your answer...

  • on Ubuntu Linux I installed Opus codec from opus-codec.org because I wanted to be sure to play pure opus (not the one incapsulated in ogg) .
  • so I installed also Ffmpeg 7.1 (ffmpeg version N-118350-ge20ee9f9ae Copyright (c) 2000-2025 the FFmpeg developers) , applying --enable-libopus parameter;
  • I checked build.gradles and in fact about previous errors it was about some gradle settings so I reached to compile everything in debug and release too.

Then I took those libffmpegJNI.so files for different architectures from /buildout/cxx/... and the lib_decoder_ffmpeg.aar file from /outputs/aar. I put them in my Java app, precisely:

in a jniLibs directory I put those directories with .so files and I added in build.gradle :

	sourceSets {
		main {
			jniLibs.srcDir('src/main/jniLibs')
		}
	}

then I added in MainActivity:

    static {
        try {
            System.loadLibrary("ffmpegjni");
        } catch (java.lang.UnsatisfiedLinkError e ) {
            Log.d("MainActivity", "Couldn't load external libraries");
            e.printStackTrace();
        }
    }

and I added also under /app/libs the lib-decoder-ffmpeg.aar and added in build.gradle

implementation fileTree(dir: 'libs', include: ['*.aar'], exclude: [])

and when I run on debug I see in Logcat :

Load /data/app/~~C9a-lbWrsGJvAQdfZlh1Jw==/xxxxxxxxxxx-AyASJ2U8W-WSouWGUsRj3Q==/base.apk!/lib/arm64-v8a/libffmpegjni.so using ns clns-4 from class loader (caller=/data/app/~~C9a-lbWrsGJvAQdfZlh1Jw==/xxxxxxxxx-AyASJ2U8W-WSouWGUsRj3Q==/base.apk!classes3.dex): ok
Loaded FfmpegVideoRenderer.
Loaded FfmpegAudioRenderer.

but it looks like that opus audio I am receiving through RTSP doesn't play even if I added in the code of exoplayer :

mediaItem = new MediaItem.Builder()
		.setUri(Uri.parse(url_nedia.toString()))
		.build();

defaultDataSource = new DefaultDataSource.Factory(
		this.getContext()
);

Uri uri = Uri.parse(url_nedia.toString());
rtspMediaSource = new RtspMediaSource.Factory()
		.setTimeoutMs(1000)
		.createMediaSource(MediaItem.fromUri(uri));

DefaultRenderersFactory defaultRenderersFactory = new DefaultRenderersFactory(this.getContext())
		.setExtensionRendererMode(DefaultRenderersFactory.EXTENSION_RENDERER_MODE_PREFER);

scaleAndRotateTransformation = new ScaleAndRotateTransformation.Builder().setRotationDegrees(parseFloat(degreesRTSP)).build();

customLoadControl = new DefaultLoadControl.Builder()
		.setBufferDurationsMs(32 * 1024, 64 * 1024, 1024, 1024)
		.build();

mediaPlayer = new ExoPlayer.Builder(this.getContext())
		.setLoadControl(customLoadControl)
		.setRenderersFactory(defaultRenderersFactory)
		.build();
playerView = getView().findViewById(R.id.playerView);
playerView.setPlayer(mediaPlayer);

mediaPlayer.addAnalyticsListener(new EventLogger());
mediaPlayer.setMediaItem(mediaItem);
mediaPlayer.setVideoScalingMode(C.VIDEO_SCALING_MODE_DEFAULT);
mediaPlayer.setVideoEffects(ImmutableList.of(scaleAndRotateTransformation));
mediaPlayer.prepare();
mediaPlayer.setPlayWhenReady(true);
mediaPlayer.play();

where if it uses defaultRenderersFactory it should prefer ffmpeg elaborating the opus decoder.... maybe is there a way to check if it is really elaborating the audio using the ffmpeg ?
Thanks in advance to all !!

@tonihei
Copy link
Collaborator

tonihei commented Jan 27, 2025

Just to reiterate - could you please follow the steps in the ffmpeg readme instead of wiring up the classes yourself via some aar logic? This will ensure the issue is not related to your special build setup.

maybe is there a way to check if it is really elaborating the audio using the ffmpeg ?

This should be visible in logcat or you attach a debugger to see which renderer class is used.

@lonewolf73
Copy link
Author

lonewolf73 commented Jan 27, 2025

hello again @tonihei , thanks for your answer .... you mean using build_ffmpeg.sh ?...
I thought even building using Android Studio could compile the same library.... .

anyway trying another test, in Logcat I see now :

Load /data/app/~~C9a-lbWrsGJvAQdfZlh1Jw==/xxxxxxxxxxx-AyASJ2U8W-WSouWGUsRj3Q==/base.apk!/lib/arm64-v8a/libffmpegjni.so using ns clns-4 from class loader (caller=/data/data/xxxxxxxxxx/code_cache/.overlay/base.apk/classes3.dex): ok
Loaded FfmpegVideoRenderer.
Loaded FfmpegAudioRenderer.
Load libffmpegJNI.so using ns clns-4 from class loader (caller=/data/app/~~C9a-lbWrsGJvAQdfZlh1Jw==/xxxxxxxxxxxx-AyASJ2U8W-WSouWGUsRj3Q==/base.apk): ok

where should mean it would call the ffmpeg renderer... but once RTSP stream starts it returns instead :

  Playback error
	androidx.media3.exoplayer.ExoPlaybackException: Unexpected runtime error
		at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:720)
		at android.os.Handler.dispatchMessage(Handler.java:107)
		at android.os.Looper.loopOnce(Looper.java:238)
		at android.os.Looper.loop(Looper.java:357)
		at android.os.HandlerThread.run(HandlerThread.java:85)
		Caused by: java.lang.IndexOutOfBoundsException: Index: 0
		at java.util.Collections$EmptyList.get(Collections.java:4888)
		at androidx.media3.decoder.ffmpeg.FfmpegAudioDecoder.getExtraData(FfmpegAudioDecoder.java:188)
		at androidx.media3.decoder.ffmpeg.FfmpegAudioDecoder.<init>(FfmpegAudioDecoder.java:65)
		at androidx.media3.decoder.ffmpeg.FfmpegAudioRenderer.createDecoder(FfmpegAudioRenderer.java:127)
		at androidx.media3.decoder.ffmpeg.FfmpegAudioRenderer.createDecoder(FfmpegAudioRenderer.java:40)
		at androidx.media3.exoplayer.audio.DecoderAudioRenderer.maybeInitDecoder(DecoderAudioRenderer.java:748)
		at androidx.media3.exoplayer.audio.DecoderAudioRenderer.onInputFormatChanged(DecoderAudioRenderer.java:801)
		at androidx.media3.exoplayer.audio.DecoderAudioRenderer.render(DecoderAudioRenderer.java:299)
		at androidx.media3.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:1136)
		at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:561)
		at android.os.Handler.dispatchMessage(Handler.java:107) 
		at android.os.Looper.loopOnce(Looper.java:238) 
		at android.os.Looper.loop(Looper.java:357) 
	at android.os.HandlerThread.run(HandlerThread.java:85) 
 audioDisabled [eventTime=1.18, mediaPos=0.00, window=0, period=0]
 playerFailed [eventTime=1.20, mediaPos=0.00, window=0, period=0, errorCode=ERROR_CODE_UNSPECIFIED
	androidx.media3.exoplayer.ExoPlaybackException: Unexpected runtime error
		at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:720)
	at android.os.Handler.dispatchMessage(Handler.java:107)
	at android.os.Looper.loopOnce(Looper.java:238)
	at android.os.Looper.loop(Looper.java:357)
	at android.os.HandlerThread.run(HandlerThread.java:85)
	Caused by: java.lang.IndexOutOfBoundsException: Index: 0
	at java.util.Collections$EmptyList.get(Collections.java:4888)
	at androidx.media3.decoder.ffmpeg.FfmpegAudioDecoder.getExtraData(FfmpegAudioDecoder.java:188)
	at androidx.media3.decoder.ffmpeg.FfmpegAudioDecoder.<init>(FfmpegAudioDecoder.java:65)
	at androidx.media3.decoder.ffmpeg.FfmpegAudioRenderer.createDecoder(FfmpegAudioRenderer.java:127)
	at androidx.media3.decoder.ffmpeg.FfmpegAudioRenderer.createDecoder(FfmpegAudioRenderer.java:40)
	at androidx.media3.exoplayer.audio.DecoderAudioRenderer.maybeInitDecoder(DecoderAudioRenderer.java:748)
	at androidx.media3.exoplayer.audio.DecoderAudioRenderer.onInputFormatChanged(DecoderAudioRenderer.java:801)
	at androidx.media3.exoplayer.audio.DecoderAudioRenderer.render(DecoderAudioRenderer.java:299)
	at androidx.media3.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:1136)
	at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:561)
	at android.os.Handler.dispatchMessage(Handler.java:107) 
	at android.os.Looper.loopOnce(Looper.java:238) 
	at android.os.Looper.loop(Looper.java:357) 
	at android.os.HandlerThread.run(HandlerThread.java:85) 

should maybe that Caused by: java.lang.IndexOutOfBoundsException: Index: 0 means that audio packet is empty when it is playing audio with RTSP stream?
Eventually is there a way to ignore empty or late audio packet?.... I mean something like applying libvlc's parameters --drop-late-frames , --no-audio-time-stretch, --network-caching=1000 ?

Investigating more on logcat result, which I report here, I see there are probably some parameters that aren't recognized... eventually is there a way to pass some parameters to ffmpegdecoder / libopus?...

tagSocket(129) with statsTag=0xffffffff, statsUid=-1
tagSocket(134) with statsTag=0xffffffff, statsUid=-1
tagSocket(199) with statsTag=0xffffffff, statsUid=-1
timeline [eventTime=0.52, mediaPos=0.00, window=0, period=0, periodCount=1, windowCount=1, reason=SOURCE_UPDATE
tagSocket(200) with statsTag=0xffffffff, statsUid=-1
  period [?]
  window [?, seekable=false, dynamic=false]
]
getParameters() io 0, keys offloadVariableRateSupported, calling pid 16070
adev_get_parameters:offloadVariableRateSupported
audio_extn_sound_trigger_get_parameters input string<offloadVariableRateSupported=>
extract_sm_handle input string <offloadVariableRateSupported=> param string <offloadVariableRateSupported=>
audio_extn_get_parameters: returns 
adev_get_parameters: exit: returns - 
videoEnabled [eventTime=0.54, mediaPos=0.00, window=0, period=0]
audioEnabled [eventTime=0.54, mediaPos=0.00, window=0, period=0]
tracks [eventTime=0.54, mediaPos=0.00, window=0, period=0
  group [
    [X] Track:0, id=null, mimeType=video/avc, codecs=avc1.4D4029, res=1280x720, color=NA/NA/NA/8/8, supported=YES
  ]
  group [
    [X] Track:0, id=null, mimeType=audio/opus, channels=2, sample_rate=48000, supported=YES
  ]
]
Creating an asynchronous MediaCodec adapter for track type video
(0xb4000072f9355de0) init name(c2.qti.avc.decoder)
allocate(c2.qti.avc.decoder)
setting up 'default' as default (vendor) store
Missing dependency coding.temporal-layering
missing struct descriptor #Param::CoreIndex(-Vc010) for field window of struct #Param::CoreIndex(FV1c00d)
missing struct descriptor #Param::CoreIndex(-Vc01a) for field misr_info_top_field of struct #Param::CoreIndex(-Vc01b)
missing struct descriptor #Param::CoreIndex(-Vc01a) for field misr_info_bottom_field of struct #Param::CoreIndex(-Vc01b)
missing struct descriptor #Param::CoreIndex(--002) for field mastering of struct #Param::CoreIndex(--180a)
Create: Allocated component[2335] for name c2.qti.avc.decoder : [32 bit]
Created component(c2.qti.avc.decoder) id(2335)
Created component [c2.qti.avc.decoder]
Failed to query parameters
read media type: video/avc
extent() != 1 for single value type: vendor.qti-ext-dec-info-misr.misr_info_top_field.misr_dpb_luma
extent() != 1 for single value type: vendor.qti-ext-dec-info-misr.misr_info_top_field.misr_dpb_chroma
extent() != 1 for single value type: vendor.qti-ext-dec-info-misr.misr_info_top_field.misr_opb_luma
extent() != 1 for single value type: vendor.qti-ext-dec-info-misr.misr_info_top_field.misr_opb_chroma
extent() != 1 for single value type: vendor.qti-ext-dec-info-misr.misr_info_bottom_field.misr_dpb_luma
extent() != 1 for single value type: vendor.qti-ext-dec-info-misr.misr_info_bottom_field.misr_dpb_chroma
extent() != 1 for single value type: vendor.qti-ext-dec-info-misr.misr_info_bottom_field.misr_opb_luma
extent() != 1 for single value type: vendor.qti-ext-dec-info-misr.misr_info_bottom_field.misr_opb_chroma
extent() != 1 for single value type: output.buffers.pool-ids.values
ignored struct field vendor.qti-ext-dec-panscan.window
ignoring local param raw.size (0xd2001800) as it is already supported
ignoring local param default.color (0x5200180b) as it is already supported
ignoring local param raw.hdr-static-info (0xd200180a) as it is already supported
Failed to query parameters
query failed after returning 17 values (BAD_INDEX)
c2 config diff is Dict {
  c2::i32 algo.priority.value = 0
  c2::float algo.rate.value = 30
  c2::u32 algo.secure-mode.value = 0
  c2::float coded.frame-rate.value = 30
  c2::u32 coded.pl.level = 0
  c2::u32 coded.pl.profile = 20484
  c2::u32 coded.vui.color.matrix = 255
  c2::u32 coded.vui.color.primaries = 0
  c2::u32 coded.vui.color.range = 0
  c2::u32 coded.vui.color.transfer = 255
  c2::u32 default.color.matrix = 0
  c2::u32 default.color.primaries = 0
  c2::u32 default.color.range = 0
  c2::u32 default.color.transfer = 0
  c2::u32 input.buffers.max-size.value = 13271040
  c2::u32 input.delay.value = 0
  string input.media-type.value = "video/avc"
  c2::u32 output.delay.value = 1
  string output.media-type.value = "video/raw"
  c2::u32 raw.color.matrix = 255
  c2::u32 raw.color.primaries = 0
  c2::u32 raw.color.range = 0
  c2::u32 raw.color.transfer = 255
  c2::float raw.hdr-static-info.mastering.blue.x = 0
  c2::float raw.hdr-static-info.mastering.blue.y = 0
  c2::float raw.hdr-static-info.mastering.gr
expected specified color aspects (0:0:255:255)
(0xb4000072f9355de0) Component Allocated (c2.qti.avc.decoder)
MediaCodec will operate in async mode
(0xb4000072f9355de0) configure surface(0xb40000732918d320) crypto(0x0) flags(0)
(0xb4000072f9355de0) configure format: AMessage(what = 0x00000000) = {
      Buffer csd-1 = {
        00000000:  00 00 00 01 68 ee 38 80  00                       ....h.8..
      }
      int32_t max-height = 720
      string log-session-id = "fZHk8TKdhh-QJ8Yq"
      int32_t max-width = 1280
      int32_t allow-frame-drop = 0
      string mime = "video/avc"
      int32_t width = 1280
      int32_t priority = 0
      int32_t rotation-degrees = 0
      int32_t max-input-size = 691200
      int32_t height = 720
      Buffer csd-0 = {
        00000000:  00 00 00 01 67 4d 40 29  96 54 02 80 2d c8        ....gM@).T..-.
      }
    }
flushMediametrics
connecting to surface 0xb40000732918d330, reason connectToSurface
[c2.qti.avc.decoder] setting surface generation to 16455683
disconnecting from surface 0xb40000732918d330, reason connectToSurface(reconnect)
Surface::disconnect
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) disconnect: api 3
connecting to surface 0xb40000732918d330, reason connectToSurface(reconnect)
legacy buffer drop disabled: target sdk (34)
[c2.qti.avc.decoder] buffers are bound to CCodec for this session
no c2 equivalents for csd-1
no c2 equivalents for log-session-id
no c2 equivalents for allow-frame-drop
no c2 equivalents for native-window
no c2 equivalents for flags
c2 config diff is   c2::u32 input.buffers.max-size.value = 3133440
  c2::u32 raw.max-size.height = 720
  c2::u32 raw.max-size.width = 1280
  c2::u32 raw.size.height = 720
  c2::u32 raw.size.width = 1280
Failed to query parameters
query -- param skipped: index = 1107298332.
client requested max input size 691200, which is smaller than what component recommended (3133440); overriding with component recommendation.
This behavior is subject to change. It is recommended that app developers double check whether the requested max input size is in reasonable range.
encoding statistics level = 0
setup formats input: AMessage(what = 0x00000000) = {
  int32_t feature-secure-playback = 0
  int32_t frame-rate = 30
  int32_t height = 720
  int32_t max-input-size = 3133440
  string mime = "video/avc"
  int32_t priority = 0
  int32_t profile = 8
  int32_t width = 1280
  Rect crop(0, 0, 1279, 719)
}
setup formats output: AMessage(what = 0x00000000) = {
  int32_t android._color-format = 0
  int32_t android._video-scaling = 1
  int32_t android._dataspace = 260
  int32_t color-standard = 130817
  int32_t color-range = 2
  int32_t color-transfer = 65791
  int32_t sar-height = 1
  int32_t rotation-degrees = 0
  Buffer hdr-static-info = {
    00000000:  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
    00000010:  00 00 00 00 00 00 00 00  00                       .........
  }
  int32_t sar-width = 1
  Rect crop(0, 0, 1279, 719)
  int32_t width = 1280
  int32_t feature-secure-playback = 0
  int32_t frame-rate = 30
  int32_t height = 720
  int32_t max-height = 720
  int32_t max-width = 1280
  string mime = "video/raw"
  int32_t priority = 0
  int32_t color-format = 2130708361
}
Failed to query parameters
query failed after returning 17 values (BAD_INDEX)
(0xb4000072f9355de0) start
keep callback message for reclaim
Build pipelined codec for session
Getting stages for pipelined codec
Pipelining not enabled
Doesn't support pipelining. Create standalone codec
[avcD_2335] Device /dev/video32 opened with fd: 7
[avcD_2335] unknown/unsupported param raw.max-size index = 0x52002003
[avcD_2335] unknown/unsupported param input.buffers.max-size index = 0xC200081E
[avcD_2335]  ? is not a supported pixel format!
use shared ref tracker
Reconfig: clearing from 0 bufs. Peak mem=0 MB
Reconfig: clearing from 0 bufs. Peak mem=0 MB
Failed to query parameters
query -- param skipped: index = 1342179345.
query -- param skipped: index = 2415921170.
query -- param skipped: index = 1610614798.
Failed to query parameters
[c2.qti.avc.decoder#569] Query input allocators returned 0 params => BAD_INDEX (6)
ProcessIbsCmd: Received IBS_WAKE_IND: 0xFD
SerialClockVote: vote for UART CLK ON
[c2.qti.avc.decoder#569] Created input block pool with allocatorID 16 => poolID 18 - OK (0)
[c2.qti.avc.decoder#569] start: max output delay 12
Failed to query parameters
[c2.qti.avc.decoder#569] Query output allocators returned 0 params => BAD_INDEX (6)
Acquire wakelock is acquired 
ProcessIbsCmd: Writing IBS_WAKE_ACK
Failed to query parameters
[c2.qti.avc.decoder#569] Query output surface allocator returned 0 params => BAD_INDEX (6)
[c2.qti.avc.decoder#569] Created output block pool with allocatorID 18 => poolID 2023 - OK
[c2.qti.avc.decoder#569] Configured output block pool ids 2023 => OK
remote graphic buffer migration 0/0
Few parameters failed to configure
setOutputSurface -- failed to set consumer usage (6/BAD_INDEX)
setOutputSurface -- generation=16455683 consumer usage=0x900
Falling back to default YUV format - no camera/video specific format defined, usage 0x100
Falling back to default YUV format - no camera/video specific format defined, usage 0x100
bool parse_adv_audio_uuids_from_adv_pkt(const uint8_t *, size_t, uint8_t): tmap_cap_pts: false
local generation change 16455683 , bqId: 69020124446730 migrated buffers # 0
Surface configure completed
[c2.qti.avc.decoder#569] start: updating output delay 1
(0xb4000072f9355de0) kWhatStartCompleted
Failed to query parameters
Ignoring request to add new resource entry with value <= 0
bufferpool2 0xb40000728919b318 : 0(0 size) total buffers - 0(0 size) used buffers - 5/10 (recycle/alloc) - 2/3 (fetch/transfer)
Destruction - bufferpool2 0xb40000728919b318 cached: 0/0M, 0/0% in use; allocs: 10, 50% recycled; transfers: 3, 33% unfetched
grantorIdx must be less than 3
use shared ref tracker
Reconfig: clearing from 0 bufs. Peak mem=0 MB
Reconfig: clearing from 0 bufs. Peak mem=0 MB
videoDecoderInitialized [eventTime=0.61, mediaPos=0.00, window=0, period=0, c2.qti.avc.decoder]
c2 config diff is   c2::u32 output.delay.value = 10
videoInputFormat [eventTime=0.61, mediaPos=0.00, window=0, period=0, id=null, mimeType=video/avc, codecs=avc1.4D4029, res=1280x720, color=NA/NA/NA/8/8]
[c2.qti.avc.decoder#569] onWorkDone: updating output delay 10
[c2.qti.avc.decoder#569] onWorkDone: updating max output delay 17
set max dequeue count 17 from update
Playback error
  androidx.media3.exoplayer.ExoPlaybackException: Unexpected runtime error
      at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:720)
      at android.os.Handler.dispatchMessage(Handler.java:107)
      at android.os.Looper.loopOnce(Looper.java:238)
      at android.os.Looper.loop(Looper.java:357)
      at android.os.HandlerThread.run(HandlerThread.java:85)
  Caused by: java.lang.IndexOutOfBoundsException: Index: 0
      at java.util.Collections$EmptyList.get(Collections.java:4888)
      at androidx.media3.decoder.ffmpeg.FfmpegAudioDecoder.getExtraData(FfmpegAudioDecoder.java:188)
      at androidx.media3.decoder.ffmpeg.FfmpegAudioDecoder.<init>(FfmpegAudioDecoder.java:65)
      at androidx.media3.decoder.ffmpeg.FfmpegAudioRenderer.createDecoder(FfmpegAudioRenderer.java:127)
      at androidx.media3.decoder.ffmpeg.FfmpegAudioRenderer.createDecoder(FfmpegAudioRenderer.java:40)
      at androidx.media3.exoplayer.audio.DecoderAudioRenderer.maybeInitDecoder(DecoderAudioRenderer.java:748)
      at androidx.media3.exoplayer.audio.DecoderAudioRenderer.onInputFormatChanged(DecoderAudioRenderer.java:801)
      at androidx.media3.exoplayer.audio.DecoderAudioRenderer.render(DecoderAudioRenderer.java:299)
      at androidx.media3.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:1136)
      at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:561)
      at android.os.Handler.dispatchMessage(Handler.java:107) 
      at android.os.Looper.loopOnce(Looper.java:238) 
      at android.os.Looper.loop(Looper.java:357) 
      at android.os.HandlerThread.run(HandlerThread.java:85) 
(0xb4000072f9355de0) flush
[c2.qti.avc.decoder#569] no linear codec config data found
[c2.qti.avc.decoder#569] no linear codec config data found
(0xb4000072f9355de0) start
keep callback message for reclaim
Failed to query parameters
query failed after returning 17 values (BAD_INDEX)
Failed to query parameters
query -- param skipped: index = 1342179345.
query -- param skipped: index = 2415921170.
query -- param skipped: index = 1610614798.
[c2.qti.avc.decoder#569] start: updating output delay 10
Failed to query parameters
videoDisabled [eventTime=0.61, mediaPos=0.00, window=0, period=0]
connecting to surface 0xb4000073291a8e00, reason connectToSurface
[c2.qti.avc.decoder] setting surface generation to 16455684
disconnecting from surface 0xb4000073291a8e00, reason connectToSurface(reconnect)
Surface::disconnect
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) disconnect: api 3
connecting to surface 0xb4000073291a8e00, reason connectToSurface(reconnect)
legacy buffer drop disabled: target sdk (34)
videoSize [eventTime=0.61, mediaPos=0.00, window=0, period=0, 0, 0]
remote graphic buffer migration 0/0
audioDisabled [eventTime=0.61, mediaPos=0.00, window=0, period=0]
Few parameters failed to configure
setOutputSurface -- failed to set consumer usage (6/BAD_INDEX)
setOutputSurface -- generation=16455684 consumer usage=0x900
Falling back to default YUV format - no camera/video specific format defined, usage 0x100
Falling back to default YUV format - no camera/video specific format defined, usage 0x100
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 1 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 2 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 3 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 4 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 5 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 6 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 7 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 8 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 9 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 10 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 11 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 12 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 13 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 14 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 15 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 16 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 17 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 18 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 19 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 20 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 21 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 22 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 23 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 24 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 25 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 26 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 27 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 28 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 29 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 30 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 31 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 32 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 33 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 34 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 35 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 36 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 37 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 38 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 39 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 40 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 41 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 42 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 43 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 44 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 45 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 46 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 47 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 48 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 49 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 50 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 51 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 52 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 53 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 54 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 55 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 56 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 57 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 58 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 59 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 60 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 61 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 62 is not owned by the producer (state = FREE)
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) detachBuffer: slot 63 is not owned by the producer (state = FREE)
local generation change 16455684 , bqId: 69020124446731 migrated buffers # 1
Surface configure completed
disconnecting from surface 0xb40000732918d330, reason disconnectFromSurface
Surface::disconnect
[SurfaceTexture-1-16070-1](id:3ec60000000a,api:3,p:16070,c:16070) disconnect: api 3
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 1 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 2 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 3 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 4 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 5 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 6 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 7 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 8 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 9 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 10 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 11 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 12 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 13 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 14 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 15 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 16 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 17 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 18 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 19 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 20 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 21 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 22 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 23 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 24 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 25 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 26 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 27 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 28 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 29 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 30 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 31 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 32 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 33 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 34 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 35 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 36 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 37 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 38 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 39 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 40 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 41 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 42 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 43 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 44 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 45 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 46 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 47 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 48 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 49 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 50 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 51 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 52 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 53 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 54 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 55 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 56 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 57 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 58 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 59 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 60 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 61 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 62 is not owned by the producer (state = FREE)
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) detachBuffer: slot 63 is not owned by the producer (state = FREE)
invalid producer producer(0), generation(0)
[c2.qti.avc.decoder#569] MediaCodec discarded an unknown buffer
[c2.qti.avc.decoder#569] MediaCodec discarded an unknown buffer
[c2.qti.avc.decoder#569] MediaCodec discarded an unknown buffer
[c2.qti.avc.decoder#569] MediaCodec discarded an unknown buffer
[avcD_2335] Stats: Pending(0) i/p-done(0) Works: Q: 2/Done 3|Work-Rate: Q(29.5/s Avg=29.5/s) Done(44.295/s Avg=44.295/s)| Stream: 30.00fps 0.0Kbps
Mem-usage:  [In-1D - 2 bufs 5.977 MB] [1D-0 - 1 bufs 0.016 MB] [2D-2023 - 2 bufs 2.844 MB]
Total Mem-usage: 8.836 MB
comp.release() is called without comp.stop()
videoDecoderReleased [eventTime=0.62, mediaPos=0.00, window=0, period=0, c2.qti.avc.decoder]
timeline [eventTime=0.62, mediaPos=0.00, window=0, period=0, periodCount=1, windowCount=1, reason=SOURCE_UPDATE
  period [?]
  window [?, seekable=false, dynamic=false]
]
applyPolicy: UpdateRefreshRate 120 to 60 of group 0: [touch=0:0 scroll=0:0 idle=1:1]
setDesiredActiveMode({id=0, hwcId=0, resolution=1080x2400, refreshRate=60.00 Hz, dpi=397.57x395.84, group=0x0})
playerFailed [eventTime=0.62, mediaPos=0.00, window=0, period=0, errorCode=ERROR_CODE_UNSPECIFIED
  androidx.media3.exoplayer.ExoPlaybackException: Unexpected runtime error
      at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:720)
      at android.os.Handler.dispatchMessage(Handler.java:107)
      at android.os.Looper.loopOnce(Looper.java:238)
      at android.os.Looper.loop(Looper.java:357)
      at android.os.HandlerThread.run(HandlerThread.java:85)
  Caused by: java.lang.IndexOutOfBoundsException: Index: 0
      at java.util.Collections$EmptyList.get(Collections.java:4888)
      at androidx.media3.decoder.ffmpeg.FfmpegAudioDecoder.getExtraData(FfmpegAudioDecoder.java:188)
      at androidx.media3.decoder.ffmpeg.FfmpegAudioDecoder.<init>(FfmpegAudioDecoder.java:65)
      at androidx.media3.decoder.ffmpeg.FfmpegAudioRenderer.createDecoder(FfmpegAudioRenderer.java:127)
      at androidx.media3.decoder.ffmpeg.FfmpegAudioRenderer.createDecoder(FfmpegAudioRenderer.java:40)
      at androidx.media3.exoplayer.audio.DecoderAudioRenderer.maybeInitDecoder(DecoderAudioRenderer.java:748)
      at androidx.media3.exoplayer.audio.DecoderAudioRenderer.onInputFormatChanged(DecoderAudioRenderer.java:801)
      at androidx.media3.exoplayer.audio.DecoderAudioRenderer.render(DecoderAudioRenderer.java:299)
      at androidx.media3.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:1136)
      at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:561)
      at android.os.Handler.dispatchMessage(Handler.java:107) 
      at android.os.Looper.loopOnce(Looper.java:238) 
      at android.os.Looper.loop(Looper.java:357) 
      at android.os.HandlerThread.run(HandlerThread.java:85) 
]
loading [eventTime=0.63, mediaPos=0.00, window=0, period=0, false]
state [eventTime=0.63, mediaPos=0.00, window=0, period=0, IDLE]
setVsyncEnabled: 1
[avcD_2335] Closed device driver with fd: 7
NOTE: handleStopCodec returning: 0 (OK=0)
Missing dependency coding.temporal-layering
missing struct descriptor #Param::CoreIndex(-Vc010) for field window of struct #Param::CoreIndex(FV1c00d)
missing struct descriptor #Param::CoreIndex(-Vc01a) for field misr_info_top_field of struct #Param::CoreIndex(-Vc01b)
missing struct descriptor #Param::CoreIndex(-Vc01a) for field misr_info_bottom_field of struct #Param::CoreIndex(-Vc01b)
missing struct descriptor #Param::CoreIndex(--002) for field mastering of struct #Param::CoreIndex(--180a)
NOTE: Release returning: 0 (OK=0)
setActiveModeInHwcIfNeeded changing active mode to 0(60.00 Hz) for display 4630947043778501762
disconnecting from surface 0xb4000073291a8e00, reason disconnectFromSurface
Surface::disconnect
[MediaCodec.release](id:3ec60000000b,api:3,p:16070,c:16070) disconnect: api 3

And the screen remains black without shownig any video...

Thanks again to all!

@lonewolf73
Copy link
Author

Doing another little investigation , this time changing audio format to G711_alaw and debugging with Logcat I get this :

Audio sink error
  androidx.media3.exoplayer.audio.AudioSink$UnexpectedDiscontinuityException: Unexpected audio track timestamp discontinuity: expected 1000000302375, got 1000000002375
      at androidx.media3.exoplayer.audio.DefaultAudioSink.handleBuffer(DefaultAudioSink.java:997)
      at androidx.media3.exoplayer.audio.DecoderAudioRenderer.drainOutputBuffer(DecoderAudioRenderer.java:464)
      at androidx.media3.exoplayer.audio.DecoderAudioRenderer.render(DecoderAudioRenderer.java:324)
      at androidx.media3.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:1136)
      at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:561)
      at android.os.Handler.dispatchMessage(Handler.java:107)
      at android.os.Looper.loopOnce(Looper.java:238)
      at android.os.Looper.loop(Looper.java:357)
      at android.os.HandlerThread.run(HandlerThread.java:85)

which it doesn't make playing audio either, even in this decoding seems it is not using FFmpegAudioRenderer....
At least using G711_alaw audio I can see the video on surface, with opus I see black screen on surface instead...
Any suggestion?...

Thanks again!
Cheers!

@tonihei
Copy link
Collaborator

tonihei commented Jan 28, 2025

Glad you solved the build problem.

Caused by: java.lang.IndexOutOfBoundsException: Index: 0 at java.util.Collections$EmptyList.get(Collections.java:4888)

This indicates the stream doesn't set up the initialization data correctly. This is different from your original issue though, so if you have reproduction steps and want us to have a look, please file a new issue and attach the media file causing the problem.

(I'll close this issue given the original problem was resolved)

@tonihei tonihei closed this as completed Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants