[FFmpeg-trac] #10666(avcodec:new): [Android] MediaCodec h264 decoder is much slower than native h264 decoder
FFmpeg
trac at avcodec.org
Fri Nov 17 12:09:13 EET 2023
#10666: [Android] MediaCodec h264 decoder is much slower than native h264 decoder
-------------------------------------+-------------------------------------
Reporter: bubbleguuum | Type: defect
Status: new | Priority: normal
Component: avcodec | Version:
| unspecified
Keywords: | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
-------------------------------------+-------------------------------------
I've been benchmarking MediaCodec decoder performance for various codecs
and although most MediaCodec decoders are faster than native, the
h264_mediacodec decoder is noticeably slower, as in 2 to 3 times slower.
I'm using a custom FFmpeg 6.1 Android build, benchmark realized on a
Google Pixel 4a
running latest Android 13
Benchmark result on a test h264 video with characteristics:
{{{
Duration: 00:09:56.50, start: 0.000000, bitrate: 4421 kb/s
Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive),
1920x1080 [SAR 1:1 DAR 16:9], 4087 kb/s, 24 fps, 24 tbr, 90k tbn (default)
}}}
With native h264 decoding:
{{{
% ffmpeg -benchmark -i /sdcard/Movies/bigbuckbunny1080p.mp4 -an -f null -
...
[out#0/null @ 0xb4000075e4c27a90] video:6710kB audio:0kB subtitle:0kB
other streams:0kB global headers:0kB muxing overhead: unknown
frame=14315 fps=216 q=-0.0 Lsize=N/A time=00:09:56.41 bitrate=N/A
speed=8.99x
bench: utime=375.794s stime=10.060s rtime=66.314s
bench: maxrss=131580kB
}}}
With h264_mediacodec decoder:
{{{
% ./ffmpeg -benchmark -c:v h264_mediacodec -i
/sdcard/Movies/bigbuckbunny1080p.mp4 -an -f null -
...
[out#0/null @ 0xb400007530d54f90] video:6710kB audio:0kB subtitle:0kB
other streams:0kB global headers:0kB muxing overhead: unknown
frame=14315 fps=104 q=-0.0 Lsize=N/A time=00:09:56.41 bitrate=N/A
speed=4.33x
bench: utime=60.108s stime=23.083s rtime=137.887s
bench: maxrss=132824kB
}}}
So 8.99x speed for native vs 4.33x for h264_mediacodec.
Also, it seems the lower the resolution of the input video, the wider the
gap is: on a 1024x436 video I observe a x3 difference!
Seems surprising there is such a gap in performance, especially since
other decoders are faster (except also vp9_mediacodec which is a tiny bit
slower than native).
Maybe it is due to the h264 native decoder being super optimized, but I
thought I would report it for reference.
--
Ticket URL: <https://trac.ffmpeg.org/ticket/10666>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list