Opened 20 months ago

Closed 4 weeks ago

Last modified 4 weeks ago

#11368 closed defect (fixed)

Mediacodec encoding not working

Reported by: RandomPerson Owned by:
Priority: normal Component: ffmpeg
Version: 7.1 Keywords:
Cc: MasterQuestionable Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
How to reproduce:

% ffmpeg -i video_input -c:v hevc_mediacodec output_video
ffmpeg version 7.1
built on r522817c) clang version 18.0.3 (https://android.googlesource.com/toolchain/llvm-project d8003a456d14a3deb8054cdaa529ffbf02d9b262)

Encoding with mediacodec is the problem, decoding works just fine

Attachments (3)

ffmpeg-log-part-1.log (1.9 MB ) - added by RandomPerson 20 months ago.
ffmpeg-log-part-2.log (1.9 MB ) - added by RandomPerson 20 months ago.
ffmpeg-log-part-3.log (1.8 MB ) - added by RandomPerson 20 months ago.

Change History (16)

by RandomPerson, 20 months ago

Attachment: ffmpeg-log-part-1.log added

by RandomPerson, 20 months ago

Attachment: ffmpeg-log-part-2.log added

by RandomPerson, 20 months ago

Attachment: ffmpeg-log-part-3.log added

comment:1 by MasterQuestionable, 20 months ago

Cc: MasterQuestionable added

͏    Simple description of the exact problem? (what failed exactly)
͏    Parsing your huge log wouldn't be enjoyable...

in reply to:  1 comment:2 by RandomPerson, 20 months ago

Replying to MasterQuestionable:

͏    Simple description of the exact problem? (what failed exactly)
͏    Parsing your huge log wouldn't be enjoyable...

So mediacodec encoding just does not work, reaches EOF before even starting according to ffmpeg and exits with a very large negative exit code, no output stream due to that

Last edited 20 months ago by RandomPerson (previous) (diff)

comment:3 by RandomPerson, 20 months ago

So I was wrong about the exit code it seems like

This is the default output when starting

[vost#0:0/hevc_mediacodec @ 0x7f39e7b600] Error while opening encoder - maybe incorrect parameters such as bit_rate, rate, width or height. [vf#0:0 @ 0x7f39ea24c0] Error sending frames to consumers: Bitstream filter not found [vf#0:0 @ 0x7f39ea24c0] Task finished with error code: -1179861752 (Bitstream filter not found) [vf#0:0 @ 0x7f39ea24c0] Terminating thread with return code -1179861752 (Bitstream filter not found) [vost#0:0/hevc_mediacodec @ 0x7f39e7b600] Could not open encoder before EOF [vost#0:0/hevc_mediacodec @ 0x7f39e7b600] Task finished with error code: -22 (Invalid argument) [vost#0:0/hevc_mediacodec @ 0x7f39e7b600] Terminating thread with return code -22 (Invalid argument) [out#0/mp4 @ 0x7f39e06cc0] Nothing was written into output file, because at least one of its streams received no packets. frame= 0 fps=0.0 q=0.0 Lsize= 0KiB time=N/A bitrate=N/A speed=N/A Conversion failed!

comment:4 by quinkblack, 19 months ago

I guess this is the issue fixed by 4c0ef3bfae1473902f8ec8ee0a1a95607827b390, which is on branch the 7.1 branch and master branch, but not released in a new tag yet. Can you test the master branch? Or check whether specify a resolution which isn't aligned to 16 work, like:

ffmpeg -i video_input -c:v hevc_mediacodec -s 1920x1080 output_video

comment:5 by RandomPerson, 19 months ago

Yeah it's gone further than last time buuuuuut it's stuck

Output #0, mp4, to '../test.mp4':

Metadata: COMPATIBLE_BRANDS: iso6avc1mp41 MAJOR_BRAND : dash

MINOR_VERSION : 0 encoder : Lavf61.9.104

Stream #0:0, 0, 1/30000: Video: hevc, 1 reference frame (hev1 / 0x31766568), yuv420p(tv, smpte170m/bt470bg/bt709, progressive, left), 1280x720 [SAR 1:1 DAR 16:9], 0/1, q=2-31, 200 kb/s, 29.97 fps, 30k tbn (default)

Metadata:

encoder : Lavc61.29.100 hevc_mediacodec HANDLER_NAME : ISO Media file produced by Google Inc. VENDOR_ID : [0][0][0][0] DURATION : 00:01:05.098000000 Stream #0:1(eng), 0, 1/48000: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, delay 1024, 128 kb/s (default)

Metadata:

encoder : Lavc61.29.100 aac DURATION : 00:01:05.108000000 [out#0/mp4 @ 0x7dca435f00] Starting thread... [out#0/mp4 @ 0x7dca435f00] sq: send 0 ts 0.0333667 [out#0/mp4 @ 0x7dca435f00] sq: receive 0 ts 0.0333667 queue head -1 ts N/A [vf#0:0 @ 0x7dca6126c0] Clipping frame in rate conversion by 0.010979 [out#0/mp4 @ 0x7dca435f00] sq: send 0 ts 0.0667333

[out#0/mp4 @ 0x7dca435f00] sq: receive 0 ts 0.0667333 queue head -1 ts N/A [out#0/mp4 @ 0x7dca435f00] sq: send 0 ts 0.1001 [out#0/mp4 @ 0x7dca435f00] sq: receive 0 ts 0.1001 queue head -1 ts N/A [vf#0:0 @ 0x7dca6126c0] Clipping frame in rate conversion by 0.002983 [out#0/mp4 @ 0x7dca435f00] sq: send 0 ts 0.133467
[out#0/mp4 @ 0x7dca435f00] sq: receive 0 ts 0.133467 queue head -1 ts N/A [vf#0:0 @ 0x7dca6126c0] Clipping frame in rate conversion by 0.013969 [out#0/mp4 @ 0x7dca435f00] sq: send 0 ts 0.166833
[out#0/mp4 @ 0x7dca435f00] sq: receive 0 ts 0.166833 queue head -1 ts N/A [h264 @ 0x7dca43d300] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 0 [out#0/mp4 @ 0x7dca435f00] sq: send 0 ts 0.2002
[out#0/mp4 @ 0x7dca435f00] sq: receive 0 ts 0.2002 queue head -1 ts N/A [vf#0:0 @ 0x7dca6126c0] Clipping frame in rate conversion by 0.005974 [out#0/mp4 @ 0x7dca435f00] sq: send 0 ts 0.233567
[out#0/mp4 @ 0x7dca435f00] sq: receive 0 ts 0.233567 queue head -1 ts N/A
[out#0/mp4 @ 0x7dca435f00] sq: send 0 ts 0.266933 [out#0/mp4 @ 0x7dca435f00] sq: receive 0 ts 0.266933 queue head -1 ts N/A [out#0/mp4 @ 0x7dca435f00] sq: send 0 ts 0.3003
[out#0/mp4 @ 0x7dca435f00] sq: receive 0 ts 0.3003 queue head -1 ts N/A
[vf#0:0 @ 0x7dca6126c0] Clipping frame in rate conversion by 0.008995 [out#0/mp4 @ 0x7dca435f00] sq: send 0 ts 0.333667
[out#0/mp4 @ 0x7dca435f00] sq: receive 0 ts 0.333667 queue head -1 ts N/A
[h264 @ 0x7dca43d680] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 0
[h264 @ 0x7dca43da00] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 1
[h264 @ 0x7dca43dd80] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 0
[h264 @ 0x7dca43e100] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 0
[out#0/mp4 @ 0x7dca435f00] sq: send 0 ts 0.367033 [out#0/mp4 @ 0x7dca435f00] sq: receive 0 ts 0.367033 queue head -1 ts N/A
[h264 @ 0x7dca43e480] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 0
[h264 @ 0x7dca43e800] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 0
[h264 @ 0x7dca43eb80] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 1 [h264 @ 0x7dca43cf80] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 0 [h264 @ 0x7dca43d300] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 0
[out#0/mp4 @ 0x7dca435f00] sq: send 1 ts 0.9005 [out#0/mp4 @ 0x7dca435f00] sq: receive 1 ts 0.881667 queue head -1 ts N/A [out#0/mp4 @ 0x7dca435f00] sq: send 1 ts 0.9205 [out#0/mp4 @ 0x7dca435f00] sq: receive 1 ts 0.903 queue head -1 ts N/A [out#0/mp4 @ 0x7dca435f00] sq: send 1 ts 0.9405
[out#0/mp4 @ 0x7dca435f00] sq: receive 1 ts 0.924333 queue head -1 ts N/A
[out#0/mp4 @ 0x7dca435f00] sq: send 1 ts 0.9605
[out#0/mp4 @ 0x7dca435f00] sq: receive 1 ts 0.945667 queue head -1 ts N/A [out#0/mp4 @ 0x7dca435f00] sq: send 1 ts 0.9805
[out#0/mp4 @ 0x7dca435f00] sq: receive 1 ts 0.967 queue head -1 ts N/A
[out#0/mp4 @ 0x7dca435f00] sq: send 1 ts 1.0005 [out#0/mp4 @ 0x7dca435f00] sq: receive 1 ts 0.988333 queue head -1 ts N/A [out#0/mp4 @ 0x7dca435f00] sq: send 1 ts 1.0205 [out#0/mp4 @ 0x7dca435f00] sq: receive 1 ts 1.009667 queue head -1 ts N/A
[out#0/mp4 @ 0x7dca435f00] sq: send 1 ts 1.0405
[out#0/mp4 @ 0x7dca435f00] sq: receive 1 ts 1.031 queue head -1 ts N/A
[out#0/mp4 @ 0x7dca435f00] sq: send 1 ts 1.0605 [out#0/mp4 @ 0x7dca435f00] sq: receive 1 ts 1.052333 queue head -1 ts N/A [vf#0:0 @ 0x7dca6126c0] Clipping frame in rate conversion by 0.000999 [h264 @ 0x7dca43d680] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 0 [out#0/mp4 @ 0x7dca435f00] sq: send 1 ts 1.0805 [out#0/mp4 @ 0x7dca435f00] sq: receive 1 ts 1.073667 queue head -1 ts N/A [out#0/mp4 @ 0x7dca435f00] sq: send 1 ts 1.1005
[out#0/mp4 @ 0x7dca435f00] sq: receive 1 ts 1.095 queue head -1 ts N/A
[out#0/mp4 @ 0x7dca435f00] sq: send 1 ts 1.1205
[out#0/mp4 @ 0x7dca435f00] sq: receive 1 ts 1.116333 queue head -1 ts N/A
[out#0/mp4 @ 0x7dca435f00] sq: send 1 ts 1.1405 [out#0/mp4 @ 0x7dca435f00] sq: receive 1 ts 1.137667 queue head -1 ts N/A
[out#0/mp4 @ 0x7dca435f00] sq: send 1 ts 1.1605 [out#0/mp4 @ 0x7dca435f00] sq: receive 1 ts 1.159 queue head -1 ts N/A [out#0/mp4 @ 0x7dca435f00] sq: send 1 ts 1.1805 [out#0/mp4 @ 0x7dca435f00] sq: receive 1 ts 1.180333 queue head -1 ts N/A [out#0/mp4 @ 0x7dca435f00] sq: send 1 ts 1.2005
[out#0/mp4 @ 0x7dca435f00] sq: send 1 ts 1.2205 [out#0/mp4 @ 0x7dca435f00] sq: receive 1 ts 1.201667 queue head -1 ts N/A
[out#0/mp4 @ 0x7dca435f00] sq: send 1 ts 1.2405
[out#0/mp4 @ 0x7dca435f00] sq: receive 1 ts 1.223 queue head -1 ts N/A [out#0/mp4 @ 0x7dca435f00] sq: send 0 ts 0.4004 [out#0/mp4 @ 0x7dca435f00] sq: receive 0 ts 0.4004 queue head -1 ts N/A [vf#0:0 @ 0x7dca6126c0] Clipping frame in rate conversion by 0.011986
[out#0/mp4 @ 0x7dca435f00] sq: send 0 ts 0.433767 [out#0/mp4 @ 0x7dca435f00] sq: receive 0 ts 0.433767 queue head -1 ts N/A
[out#0/mp4 @ 0x7dca435f00] sq: send 0 ts 0.467133
[out#0/mp4 @ 0x7dca435f00] sq: receive 0 ts 0.467133 queue head -1 ts N/A
[vf#0:0 @ 0x7dca6126c0] Clipping frame in rate conversion by 0.003990
[out#0/mp4 @ 0x7dca435f00] sq: send 0 ts 0.5005 [h264 @ 0x7dca43da00] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 0 [h264 @ 0x7dca43dd80] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 1 [h264 @ 0x7dca43e100] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 0
[out#0/mp4 @ 0x7dca435f00] sq: receive 0 ts 0.5005 queue head -1 ts N/A
[out#0/mp4 @ 0x7dca435f00] sq: send 1 ts 1.2605 [out#0/mp4 @ 0x7dca435f00] sq: receive 1 ts 1.244333 queue head -1 ts N/A [out#0/mp4 @ 0x7dca435f00] sq: send 1 ts 1.2805 [out#0/mp4 @ 0x7dca435f00] sq: receive 1 ts 1.265667 queue head -1 ts N/A [out#0/mp4 @ 0x7dca435f00] sq: send 1 ts 1.3005 [out#0/mp4 @ 0x7dca435f00] sq: receive 1 ts 1.287 queue head -1 ts N/A [h264 @ 0x7dca43e480] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 0 [out#0/mp4 @ 0x7dca435f00] sq: send 1 ts 1.3205
[out#0/mp4 @ 0x7dca435f00] sq: receive 1 ts 1.308333 queue head -1 ts N/A [out#0/mp4 @ 0x7dca435f00] sq: send 1 ts 1.3405
[out#0/mp4 @ 0x7dca435f00] sq: receive 1 ts 1.329667 queue head -1 ts N/A
[out#0/mp4 @ 0x7dca435f00] sq: send 0 ts 0.533867 [out#0/mp4 @ 0x7dca435f00] sq: receive 0 ts 0.533867 queue head -1 ts N/A [out#0/mp4 @ 0x7dca435f00] sq: send 0 ts 0.567233
[out#0/mp4 @ 0x7dca435f00] sq: receive 0 ts 0.567233 queue head -1 ts N/A
[vf#0:0 @ 0x7dca6126c0] Clipping frame in rate conversion by 0.006981 [out#0/mp4 @ 0x7dca435f00] sq: send 0 ts 0.6006
[out#0/mp4 @ 0x7dca435f00] sq: receive 0 ts 0.6006 queue head -1 ts N/A
[out#0/mp4 @ 0x7dca435f00] sq: send 0 ts 0.633967 [out#0/mp4 @ 0x7dca435f00] sq: receive 0 ts 0.633967 queue head -1 ts N/A [out#0/mp4 @ 0x7dca435f00] sq: send 0 ts 0.667333
[out#0/mp4 @ 0x7dca435f00] sq: receive 0 ts 0.667333 queue head -1 ts N/A
[h264 @ 0x7dca43e800] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 0
[h264 @ 0x7dca43eb80] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 0
[h264 @ 0x7dca43cf80] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 1 [h264 @ 0x7dca43d300] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 0 frame= 0 fps=0.0 q=0.0 size= 0KiB time=N/A bitrframe= 0 fps=0.0 q=0.0 size= 0KiB time=N/A bitrframe= 0 fps=0.0 q=0.0 size= 0KiB time=N/A bitrframe= 0 fps=0.0 q=0.0 size= 0KiB time=N/A bitrframe= 0

in reply to:  5 ; comment:6 by quinkblack, 19 months ago

Replying to RandomPerson:

Yeah it's gone further than last time buuuuuut it's stuck

What's the Android OS version? Is it Android 15? Google break mediacodec decoding/encoding without JVM on Android 15, ref. https://trac.ffmpeg.org/ticket/11363

comment:7 by Balling, 4 weeks ago

Resolution: fixed
Status: newclosed

in reply to:  6 comment:8 by RandomPerson, 4 weeks ago

Replying to quinkblack:

Replying to RandomPerson:

Yeah it's gone further than last time buuuuuut it's stuck

What's the Android OS version? Is it Android 15? Google break mediacodec decoding/encoding without JVM on Android 15, ref. https://trac.ffmpeg.org/ticket/11363

oh sorry, forgot to check in here ever since, i don't check my email often, anyways i was running Android 13 running OneUI 5.1 at the time on my Samsung XCover Pro when i was made this ticket.

comment:9 by Balling, 4 weeks ago

Then it is some different bug from #11363?

"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)"

comment:10 by RandomPerson, 4 weeks ago

Perhaps, looking at issue #11363 closer, the termux output from the OP also showed the device was using an Exynos GPU, so looks like an Exynos GPU decoder problem, considering it worked fine in Chrome. Not sure if the eccbbd528ef63f17575f11a644d549da80bf4b30 fix fixes that since i do not have a mobile device with an Exynos GPU to test on right now.

comment:11 by RandomPerson, 4 weeks ago

Oops i meant encoder problem, not decoder problem, my bad.

comment:12 by Balling, 4 weeks ago

Termux 13 does not work, this is the limitation of Termux? Does this work now for ypu on android 13 or no, or did you update to new android?

Last edited 4 weeks ago by Balling (previous) (diff)

comment:13 by RandomPerson, 4 weeks ago

Can't test right now, do not have a mobile device right now since it broke due to water damage.

Note: See TracTickets for help on using tickets.