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

[Bug]: ffmpeg mediacodec decoder outputs wrong dimensions #23014

Open
urain39 opened this issue Jan 24, 2025 · 1 comment
Open

[Bug]: ffmpeg mediacodec decoder outputs wrong dimensions #23014

urain39 opened this issue Jan 24, 2025 · 1 comment
Labels
bug report Something is not working properly untriaged

Comments

@urain39
Copy link
Contributor

urain39 commented Jan 24, 2025

Problem description

This bug may cause ffmpeg to fail to perform hardware-accelerated decoding of the input video during the conversion operation.

Command:

ffmpeg -v verbose -hwaccel mediacodec -i Video_01.mp4 -f null -

Output:

[h264 @ 0xb400007811282a80] Reinit context to 832x1280, pix_fmt: yuv420p
Selecting decoder 'h264_mediacodec' because of requested hwaccel method mediacodec
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Video_01.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.20.100
    description     : Tencent CAPD MTS (T-tech)
  Duration: 00:00:05.10, start: 0.000000, bitrate: 2015 kb/s
  Stream #0:0[0x1](und): Video: h264 (High), 1 reference frame (avc1 / 0x31637661), yuv420p(tv, bt709, progressive, left), 832x1280, 2011 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
      Metadata:
        handler_name    : VideoHandler
        vendor_id       : [0][0][0][0]
[out#0/null @ 0xb40000781127ccc0] No explicit maps, mapping streams automatically...
[vost#0:0/wrapped_avframe @ 0xb40000781138e000] Created video stream from input stream 0:0
[h264_mediacodec @ 0xb400007811283500] Both surface and native_window are NULL
[h264_mediacodec @ 0xb400007811283500] Using surface 0x0
[h264_mediacodec @ 0xb400007811283500] No Java virtual machine has been registered
[h264_mediacodec @ 0xb400007811283500] Failed to getCodecNameByType
[h264_mediacodec @ 0xb400007811283500] Output crop parameters top=0 bottom=238 left=0 right=318, resulting dimensions width=319 height=239
[h264_mediacodec @ 0xb400007811283500] MediaCodec started successfully: codec = c2.mtk.avc.decoder, ret = 0
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (h264_mediacodec) -> wrapped_avframe (native))
[vost#0:0/wrapped_avframe @ 0xb40000781138e000] Starting thread...
[vf#0:0 @ 0xb4000078113701a0] Starting thread...
[vist#0:0/h264 @ 0xb40000781127f900] [dec:h264_mediacodec @ 0xb4000078113408c0] Starting thread...
[in#0/mov,mp4,m4a,3gp,3g2,mj2 @ 0xb4000078112fc900] Starting thread...
Press [q] to stop, [?] for help
[h264_mediacodec @ 0xb400007811283500] Output MediaFormat changed to android._color-format: int32(2135033992), android._video-scaling: int32(1), sar-width: int32(1), color-standard: int32(1), color-range: int32(2), color-transfer: int32(3), android._dataspace: int32(260), width: int32(832), rotation-degrees: int32(0), sar-height: int32(1), max-width: int32(832), max-height: int32(1280), priority: int32(-1), mime: string(video/raw), crop: Rect(0, 0, 831, 1279), hdr-static-info: data, frame-rate: int32(30), height: int32(1280), color-format: int32(19), image-data: data, stride: int32(832), slice-height: int32(1280)}
[h264_mediacodec @ 0xb400007811283500] Output crop parameters top=0 bottom=238 left=0 right=318, resulting dimensions width=319 height=239
[graph -1 input from stream 0:0 @ 0xb400007718c3a180] w:319 h:239 pixfmt:yuv420p tb:1/15360 fr:30/1 sar:0/1 csp:bt709 range:tv
[graph -1 input from stream 0:0 @ 0xb400007718c3a180] video frame properties congruent with link at pts_time: 0

What steps will reproduce the bug?

See the command above.

What is the expected behavior?

Output should be like:

[h264 @ 0xb400007915f23a80] Reinit context to 832x1280, pix_fmt: yuv420p
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Video_01.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.20.100
    description     : Tencent CAPD MTS (T-tech)
  Duration: 00:00:05.10, start: 0.000000, bitrate: 2015 kb/s
  Stream #0:0[0x1](und): Video: h264 (High), 1 reference frame (avc1 / 0x31637661), yuv420p(tv, bt709, progressive, left), 832x1280, 2011 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
      Metadata:
        handler_name    : VideoHandler
        vendor_id       : [0][0][0][0]
[out#0/null @ 0xb400007915f1dcc0] No explicit maps, mapping streams automatically...
[vost#0:0/wrapped_avframe @ 0xb40000791602e000] Created video stream from input stream 0:0
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> wrapped_avframe (native))
[vost#0:0/wrapped_avframe @ 0xb40000791602e000] Starting thread...
[vf#0:0 @ 0xb4000079160111a0] Starting thread...
[vist#0:0/h264 @ 0xb400007915f20900] [dec:h264 @ 0xb400007915fe18c0] Starting thread...
[in#0/mov,mp4,m4a,3gp,3g2,mj2 @ 0xb400007915f9d900] Starting thread...
Press [q] to stop, [?] for help
[h264 @ 0xb400007915f24880] Reinit context to 832x1280, pix_fmt: yuv420p
[graph -1 input from stream 0:0 @ 0xb400007827cfc0c0] w:832 h:1280 pixfmt:yuv420p tb:1/15360 fr:30/1 sar:0/1 csp:bt709 range:tv
[graph -1 input from stream 0:0 @ 0xb400007827cfc0c0] video frame properties congruent with link at pts_time: 0

^^^ Generated by command:

ffmpeg -v verbose -i Video_01.mp4 -f null -

Main diff:

< [graph -1 input from stream 0:0 @ 0xb400007718c3a180] w:319 h:239 pixfmt:yuv420p tb:1/15360 fr:30/1 sar:0/1 csp:bt709 range:tv
---
> [graph -1 input from stream 0:0 @ 0xb400007827cfc0c0] w:832 h:1280 pixfmt:yuv420p tb:1/15360 fr:30/1 sar:0/1 csp:bt709 range:tv

See also: Can AVCodec provide more crop information when decoding via MediaCodec?

System information

Termux Variables:
TERMUX_APK_RELEASE=GITHUB
TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_APP_PID=20916
TERMUX_IS_DEBUGGABLE_BUILD=1
TERMUX_MAIN_PACKAGE_FORMAT=debian
TERMUX_VERSION=0.118.0
TERMUX__USER_ID=0
Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://mirrors.zju.edu.cn/termux/apt/termux-main stable main
# root-repo (sources.list.d/root.list)
deb https://mirrors.zju.edu.cn/termux/apt/termux-root root stable
# tur-repo (sources.list.d/tur.list)
deb https://tur.kcubeterm.com tur-packages tur tur-on-device tur-continuous
Updatable packages:
All packages up to date
termux-tools version:
1.44.6
Android version:
14
Kernel build information:
Linux localhost 5.10.209-android12-9-00019-g4ea09a298bb4-ab12292661 #1 SMP PREEMPT Wed Aug 28 22:16:09 UTC 2024 aarch64 Android
Device manufacturer:
Xiaomi
Device model:
22041216C
LD Variables:
LD_LIBRARY_PATH=
LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so
@urain39 urain39 added bug report Something is not working properly untriaged labels Jan 24, 2025
@Biswa96
Copy link
Member

Biswa96 commented Jan 24, 2025

There are some issues with mediacodec https://github.com/termux/termux-packages/issues?q=mediacodec%20%20

@urain39 urain39 changed the title [Bug]: ffmpeg mediacodec decoder outputs wrong dimension [Bug]: ffmpeg mediacodec decoder outputs wrong dimensions Jan 24, 2025
@termux termux deleted a comment from ayleth177 Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Something is not working properly untriaged
Projects
None yet
Development

No branches or pull requests

2 participants