Opened 6 hours ago

Last modified 43 minutes ago

#11363 new defect

[Android] MediaCodec decoders/encoders do not work on Pixel 8 Pro (No output buffer available)

Reported by: bubbleguuum Owned by:
Priority: normal Component: avcodec
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

I cannot get MediaCodec hardware encoders/decoders to work on my Pixel 8 Pro (Android 15), while it works perfectly on my Pixel 4a (Android 13)

At the end of this report is the logs of a failure to decode a simple mp4 file with h264_mediacodec, using a custom build of ffmpeg for Android from the snapshot from Dec 19th.
It fails and get stuck on "No output buffer available, try again later", repeated indefinitely. Speaking of which, exiting with the 'q' key does not work, I have to force kill it with 3 CTRL-C.
The h264 hardware encoder does not work as well, stuck in the same way.

I have tested that hw encoders/decoders work properly with an external tool making use of the MediaCodec API directly: https://github.com/JohanBlome/encapp/

Any hint how I could further troubleshoot this issue ?


130|husky:/data/local/tmp $ ./ffmpeg -v debug  -hwaccel mediacodec -i /sdcard/Movies/oceans.mp4 -f null -                                                                                                                                     
ffmpeg version N-118091-gb38f6f9990-bubblesoftapps.com Copyright (c) 2000-2024 the FFmpeg developers
  built with Android (6875598, based on r399163b) clang version 11.0.5 (https://android.googlesource.com/toolchain/llvm-project 87f1315dfbea7c137aa2e6d362dbb457e388158d)
  configuration: --target-os=android --cross-prefix=/home/bobbie/ffmpeg-android/toolchain-android/bin/aarch64-linux-android- --arch=aarch64 --cpu=armv8-a --sysroot=/home/bobbie/ffmpeg-android/toolchain-android/sysroot --pkg-config=/home/bobbie/ffmpeg-android/ffmpeg-pkg-config --prefix=/home/bobbie/ffmpeg-android/build/arm64-v8a --extra-cflags='-I/home/bobbie/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all -fPIE -fPIC' --extra-ldflags='-Wl,-z,max-page-size=16384 -fuse-ld=gold -L/home/bobbie/ffmpeg-android/toolchain-android/lib64 -L/home/bobbie/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie -Wl,--fix-cortex-a8 -Wl,-z,max-page-size=16384' --extra-libs='-lhogweed -lnettle -lgmp -lvorbis -logg -lm -lz' --extra-cxxflags= --extra-version=bubblesoftapps.com --disable-shared --disable-debug --disable-programs --disable-doc --disable-avdevice --disable-postproc --disable-protocols --disable-protocol='rtp,udp' --disable-encoders --disable-filters --disable-libv4l2 --enable-gpl --enable-version3 --enable-pic --enable-static --enable-ffmpeg --enable-libxml2 --enable-gnutls --enable-protocol='http,https,pipe,crypto,file' --enable-encoder='aac,libmp3lame,libopus,ac3,eac3,pcm_s16le,pcm_s16be,pcm_s24le,pcm_s24be,flac,libvorbis,mjpeg,libx264,srt,wrapped_avframe,h264_mediacodec,png' --enable-filter='aresample,volume,afir,replaygain,scale,setsar,setdar' --enable-demuxer=dash --enable-libmp3lame --enable-libopus --enable-libsoxr --enable-libvorbis --enable-libx264 --enable-jni --enable-mediacodec --enable-hwaccels
  libavutil      59. 51.100 / 59. 51.100
  libavcodec     61. 27.101 / 61. 27.101
  libavformat    61.  9.101 / 61.  9.101
  libavfilter    10.  6.101 / 10.  6.101
  libswscale      8. 12.100 /  8. 12.100
  libswresample   5.  4.100 /  5.  4.100
Splitting the commandline.
Reading option '-v' ... matched as option 'v' (set logging level) with argument 'debug'.
Reading option '-hwaccel' ... matched as option 'hwaccel' (use HW accelerated decoding) with argument 'mediacodec'.
Reading option '-i' ... matched as input url with argument '/sdcard/Movies/oceans.mp4'.
Reading option '-f' ... matched as option 'f' (force container format (auto-detected otherwise)) with argument 'null'.
Reading option '-' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option v (set logging level) with argument debug.
Successfully parsed a group of options.
Parsing a group of options: input url /sdcard/Movies/oceans.mp4.
Applying option hwaccel (use HW accelerated decoding) with argument mediacodec.
Successfully parsed a group of options.
Opening an input file: /sdcard/Movies/oceans.mp4.
[AVFormatContext @ 0xb400007c69094bd0] Opening '/sdcard/Movies/oceans.mp4' for reading
[file @ 0xb400007bb9099050] Setting default whitelist 'file,crypto,data'
[mov,mp4,m4a,3gp,3g2,mj2 @ 0xb400007c69094bd0] Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0xb400007c69094bd0] ISO: File Type Major Brand: isom
[mov,mp4,m4a,3gp,3g2,mj2 @ 0xb400007c69094bd0] Unknown dref type 0x206c7275 size 12
    Last message repeated 1 times
[mov,mp4,m4a,3gp,3g2,mj2 @ 0xb400007c69094bd0] Before avformat_find_stream_info() pos: 17427 bytes read:32768 seeks:0 nb_streams:2
[h264 @ 0xb400007cd9097790] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264 @ 0xb400007cd9097790] Decoding VUI
[h264 @ 0xb400007cd9097790] nal_unit_type: 8(PPS), nal_ref_idc: 3
Transform tree:
    mdct_inv_float_c - type: mdct_float, len: 64, factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only]
        fft32_ns_float_neon - type: fft_float, len: 32, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]
Transform tree:
    mdct_inv_float_c - type: mdct_float, len: 64, factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only]
        fft32_ns_float_neon - type: fft_float, len: 32, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]
Transform tree:
    mdct_pfa_3xM_inv_float_c - type: mdct_float, len: 96, factors[2]: [3, any], flags: [unaligned, out_of_place, inv_only]
        fft16_ns_float_neon - type: fft_float, len: 16, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]
Transform tree:
    mdct_pfa_15xM_inv_float_c - type: mdct_float, len: 120, factors[2]: [15, any], flags: [unaligned, out_of_place, inv_only]
        fft4_fwd_float_neon - type: fft_float, len: 4, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]
Transform tree:
    mdct_inv_float_c - type: mdct_float, len: 128, factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only]
        fft_sr_ns_float_neon - type: fft_float, len: 64, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]
Transform tree:
    mdct_pfa_15xM_inv_float_c - type: mdct_float, len: 480, factors[2]: [15, any], flags: [unaligned, out_of_place, inv_only]
        fft16_ns_float_neon - type: fft_float, len: 16, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]
Transform tree:
    mdct_inv_float_c - type: mdct_float, len: 512, factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only]
        fft_sr_ns_float_neon - type: fft_float, len: 256, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]
Transform tree:
    mdct_pfa_3xM_inv_float_c - type: mdct_float, len: 768, factors[2]: [3, any], flags: [unaligned, out_of_place, inv_only]
        fft_sr_ns_float_neon - type: fft_float, len: 128, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]
Transform tree:
    mdct_pfa_15xM_inv_float_c - type: mdct_float, len: 960, factors[2]: [15, any], flags: [unaligned, out_of_place, inv_only]
        fft32_ns_float_neon - type: fft_float, len: 32, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]
Transform tree:
    mdct_inv_float_c - type: mdct_float, len: 1024, factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only]
        fft_sr_ns_float_neon - type: fft_float, len: 512, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]
Transform tree:
    mdct_fwd_float_c - type: mdct_float, len: 1024, factors[2]: [2, any], flags: [unaligned, out_of_place, fwd_only]
        fft_sr_ns_float_neon - type: fft_float, len: 512, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]
[h264 @ 0xb400007cd9097790] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264 @ 0xb400007cd9097790] Decoding VUI
[h264 @ 0xb400007cd9097790] nal_unit_type: 8(PPS), nal_ref_idc: 3
[h264 @ 0xb400007cd9097790] nal_unit_type: 6(SEI), nal_ref_idc: 0
[h264 @ 0xb400007cd9097790] nal_unit_type: 5(IDR), nal_ref_idc: 3
[h264 @ 0xb400007cd9097790] Format yuv420p chosen by get_format().
[h264 @ 0xb400007cd9097790] Reinit context to 960x400, pix_fmt: yuv420p
[h264 @ 0xb400007cd9097790] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2
    Last message repeated 5 times
[mov,mp4,m4a,3gp,3g2,mj2 @ 0xb400007c69094bd0] All info found
[mov,mp4,m4a,3gp,3g2,mj2 @ 0xb400007c69094bd0] After avformat_find_stream_info() pos: 22976 bytes read:32768 seeks:0 frames:13
[vist#0:0/h264 @ 0xb400007b8908f490] Selecting decoder 'h264_mediacodec' because of requested hwaccel method mediacodec
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/sdcard/Movies/oceans.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 1
    compatible_brands: isomavc1
    track           : 0
    artist          : This is a test
    album           : 
    comment         : 
    date            : 0
    genre           : 
    title           : oceans2.mp4
    creation_time   : 2013-05-03T22:51:07.000000Z
  Duration: 00:00:46.61, start: 0.000000, bitrate: 3950 kb/s
  Stream #0:0[0x1](und), 12, 1/24000: Video: h264 (Constrained Baseline), 1 reference frame (avc1 / 0x31637661), yuv420p(progressive, left), 960x400 [SAR 1:1 DAR 12:5], 0/1, 3859 kb/s, 23.98 fps, 23.98 tbr, 24k tbn (default)
    Metadata:
      creation_time   : 2013-05-03T22:50:47.000000Z
      handler_name    : GPAC ISO Video Handler
      vendor_id       : [0][0][0][0]
  Stream #0:1[0x2](und), 1, 1/48000: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 92 kb/s (default)
    Metadata:
      creation_time   : 2013-05-03T22:51:07.000000Z
      handler_name    : GPAC ISO Audio Handler
      vendor_id       : [0][0][0][0]
Successfully opened the file.
Parsing a group of options: output url -.
Applying option f (force container format (auto-detected otherwise)) with argument null.
Successfully parsed a group of options.
Opening an output file: -.
[out#0/null @ 0xb400007be9097c50] No explicit maps, mapping streams automatically...
[vost#0:0/wrapped_avframe @ 0xb400007c69098730] Created video stream from input stream 0:0
[AVHWDeviceContext @ 0xb400007af909f710] Disable createPersistentInputSurface
[h264_mediacodec @ 0xb400007cd9094c70] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264_mediacodec @ 0xb400007cd9094c70] Decoding VUI
[h264_mediacodec @ 0xb400007cd9094c70] nal_unit_type: 8(PPS), nal_ref_idc: 3
[h264_mediacodec @ 0xb400007cd9094c70] Format mediacodec chosen by get_format().
[h264_mediacodec @ 0xb400007cd9094c70] Both surface and native_window are NULL
[h264_mediacodec @ 0xb400007cd9094c70] Using surface 0x0
[h264_mediacodec @ 0xb400007cd9094c70] No Java virtual machine has been registered
[h264_mediacodec @ 0xb400007cd9094c70] Failed to getCodecNameByType
[h264_mediacodec @ 0xb400007cd9094c70] Parsing MediaFormat android._color-format: int32(2135033992), android._video-scaling: int32(1), rotation-degrees: int32(0), color-standard: int32(0), color-range: int32(0), color-transfer: int32(0), cta861.max-cll: float(0.000000), cta861.max-fall: float(0.000000), sar-height: int32(1), sar-width: int32(1), crop: Rect(0, 0, 959, 399), width: int32(960), height: int32(400), max-height: int32(400), max-width: int32(960), mime: string(video/raw), priority: int32(0), android._dataspace: int32(0), color-format: int32(21)}
[h264_mediacodec @ 0xb400007cd9094c70] Output crop parameters top=0 bottom=399 left=0 right=959, resulting dimensions width=960 height=400
[h264_mediacodec @ 0xb400007cd9094c70] MediaCodec 0xb400007cc9098a30 started successfully
[h264_mediacodec @ 0xb400007cd9094c70] MediaCodec started successfully: codec = c2.exynos.h264.decoder, ret = 0
[h264_mediacodec @ 0xb400007cd9094c70] No Java virtual machine has been registered
[aost#0:1/pcm_s16le @ 0xb400007c69092650] Created audio stream from input stream 0:1
Transform tree:
    mdct_inv_float_c - type: mdct_float, len: 64, factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only]
        fft32_ns_float_neon - type: fft_float, len: 32, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]
Transform tree:
    mdct_inv_float_c - type: mdct_float, len: 64, factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only]
        fft32_ns_float_neon - type: fft_float, len: 32, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]
Transform tree:
    mdct_pfa_3xM_inv_float_c - type: mdct_float, len: 96, factors[2]: [3, any], flags: [unaligned, out_of_place, inv_only]
        fft16_ns_float_neon - type: fft_float, len: 16, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]
Transform tree:
    mdct_pfa_15xM_inv_float_c - type: mdct_float, len: 120, factors[2]: [15, any], flags: [unaligned, out_of_place, inv_only]
        fft4_fwd_float_neon - type: fft_float, len: 4, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]
Transform tree:
    mdct_inv_float_c - type: mdct_float, len: 128, factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only]
        fft_sr_ns_float_neon - type: fft_float, len: 64, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]
Transform tree:
    mdct_pfa_15xM_inv_float_c - type: mdct_float, len: 480, factors[2]: [15, any], flags: [unaligned, out_of_place, inv_only]
        fft16_ns_float_neon - type: fft_float, len: 16, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]
Transform tree:
    mdct_inv_float_c - type: mdct_float, len: 512, factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only]
        fft_sr_ns_float_neon - type: fft_float, len: 256, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]
Transform tree:
    mdct_pfa_3xM_inv_float_c - type: mdct_float, len: 768, factors[2]: [3, any], flags: [unaligned, out_of_place, inv_only]
        fft_sr_ns_float_neon - type: fft_float, len: 128, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]
Transform tree:
    mdct_pfa_15xM_inv_float_c - type: mdct_float, len: 960, factors[2]: [15, any], flags: [unaligned, out_of_place, inv_only]
        fft32_ns_float_neon - type: fft_float, len: 32, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]
Transform tree:
    mdct_inv_float_c - type: mdct_float, len: 1024, factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only]
        fft_sr_ns_float_neon - type: fft_float, len: 512, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]
Transform tree:
    mdct_fwd_float_c - type: mdct_float, len: 1024, factors[2]: [2, any], flags: [unaligned, out_of_place, fwd_only]
        fft_sr_ns_float_neon - type: fft_float, len: 512, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]
Successfully opened the file.
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (h264_mediacodec) -> wrapped_avframe (native))
  Stream #0:1 -> #0:1 (aac (native) -> pcm_s16le (native))
[vost#0:0/wrapped_avframe @ 0xb400007c69098730] Starting thread...
[aost#0:1/pcm_s16le @ 0xb400007c69092650] Starting thread...
[vf#0:0 @ 0xb400007c790afb00] Starting thread...
[af#0:1 @ 0xb400007c790ae3a0] Starting thread...
[vist#0:0/h264 @ 0xb400007b8908f490] [dec:h264_mediacodec @ 0xb400007cc9099110] Starting thread...
[aist#0:1/aac @ 0xb400007b8908d890] [dec:aac @ 0xb400007cc909b370] Starting thread...
[in#0/mov,mp4,m4a,3gp,3g2,mj2 @ 0xb400007c19096f90] Starting thread...
Press [q] to stop, [?] for help
[h264_mediacodec @ 0xb400007cd9094c70] No output buffer available, try again later
^CReceived > 3 system signals, hard exiting

Change History (1)

comment:1 by bubbleguuum, 43 minutes ago

A bit more info with trace logging of the end:

[in#0/mov,mp4,m4a,3gp,3g2,mj2 @ 0xb400007742ea0530] Starting thread...
Press [q] to stop, [?] for help
[h264_mediacodec @ 0xb400007772ea2340] No output buffer available, try again later
[h264_mediacodec @ 0xb400007772ea2340] Queued input buffer 2 size=1246 ts=0
[h264_mediacodec @ 0xb400007772ea2340] No output buffer available, try again later
    Last message repeated 1 times
[h264_mediacodec @ 0xb400007772ea2340] Queued input buffer 3 size=12 ts=41708
[h264_mediacodec @ 0xb400007772ea2340] No output buffer available, try again later

2 input buffers are queued with queueInputBuffer() but still not output buffer available, and no more input buffers are queued.

Note: See TracTickets for help on using tickets.