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

Encoding fails with h264_v4l2m2m codec on android. #1114

Open
HyundongHwang opened this issue Feb 24, 2025 · 0 comments
Open

Encoding fails with h264_v4l2m2m codec on android. #1114

HyundongHwang opened this issue Feb 24, 2025 · 0 comments

Comments

@HyundongHwang
Copy link

Description
Hello.
I always use it well with gratitude for creating a good library project.
I have to encode or transcode with h264 on android.

When I checked with ffmpeg -encoders, the h264 video codec is provided as a hardware codec, h264_v4l2m2m, but when I use it, the following error occurs and it does not work.
It is not h264_v4l2m2m, but it works well when I encode with another codec, mpeg4.
Of course, since I want h264 output, I want h264_v4l2m2m or another alternative.
Is it okay if I install an additional codec for h264 encoding if I cannot use h264_v4l2m2m?

[h264_v4l2m2m @ 0xb400007b1ac71d40] Could not find a valid device
[h264_v4l2m2m @ 0xb400007b1ac71d40] can't configure encoder
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

Logs

  • input cmd
ffmpeg -i '/storage/emulated/0/Android/data/app.streamstudio.stream/files/class/class000046_NewJeans_Supernatural_hoois127/class_front_1080p_gop1_crf27.mp4' -c:v h264_v4l2m2m -c:a aac '/storage/emulated/0/Android/data/app.streamstudio.stream/files/out_250224_112854.mp4'
  • out log
ffmpeg version v4.4-dev-416
 Copyright (c) 2000-2020 the FFmpeg developers
  built with Android (6454773 based on r365631c2) clang version 9.0.8 (https://android.googlesource.com/toolchain/llvm-project 98c855489587874b2a325e7a516b99d838599c6f) (based on LLVM 9.0.8svn)
  configuration: --cross-prefix=aarch64-linux-android- --sysroot=/files/android-sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/sysroot --prefix=/home/taner/Projects/mobile-ffmpeg/prebuilt/android-arm64/ffmpeg --pkg-config=/usr/bin/pkg-config --enable-version3 --arch=aarch64 --cpu=armv8-a --cc=aarch64-linux-android21-clang --cxx=aarch64-linux-android21-clang++ --extra-libs='-L/storage/light/projects/mobile-ffmpeg/prebuilt/android-arm64/cpu-features/lib -lndk_compat' --target-os=android --enable-neon --enable-asm --enable-inline-asm --enable-cross-compile --enable-pic --enable-jni --enable-optimizations --enable-swscale --enable-shared --enable-v4l2-m2m --disable-outdev=fbdev --disable-indev=fbdev --enable-small --disable-openssl --disable-xmm-clobber-test --disable-debug --enable-lto --disable-neon-clobber-test --disable-programs --disable-postproc --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disab
  libavutil      56. 55.100 / 56. 55.100
  libavcodec     58. 96.100 / 58. 96.100
  libavformat    58. 48.100 / 58. 48.100
  libavdevice    58. 11.101 / 58. 11.101
  libavfilter     7. 87.100 /  7. 87.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/Android/data/app.streamstudio.stream/files/class/class000046_NewJeans_Supernatural_hoois127/class_front_1080p_gop1_crf27.mp4':
  Metadata:
    major_brand     : 
isom
    minor_version   : 
512
    compatible_brands: 
isomiso2avc1mp41
    encoder         : 
Lavf60.3.100
  Duration: 
00:00:25.01
, start: 
0.000000
, bitrate: 
14924 kb/s
    Stream #0:0
(und)
: Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709), 1080x1920, 14789 kb/s
, 
30 fps, 
30 tbr, 
15360 tbn, 
60 tbc
 (default)
    Metadata:
      handler_name    : 
Core Media Video
      encoder         : 
Lavc60.3.100 libx264
    Stream #0:1
(und)
: Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 131 kb/s
 (default)
    Metadata:
      handler_name    : 
Core Media Audio
Stream mapping:
  Stream #0:0 -> #0:0
 (h264 (native) -> h264 (h264_v4l2m2m))
  Stream #0:1 -> #0:1
 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[graph 0 input from stream 0:0 @ 0xb400007c8a93c110] sws_param option is deprecated and ignored
[h264_v4l2m2m @ 0xb400007b1ac71d40] Could not find a valid device
[h264_v4l2m2m @ 0xb400007b1ac71d40] can't configure encoder
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
[aac @ 0xb400007b1ac6edd0] Qavg: 152.892
[aac @ 0xb400007b1ac6edd0] 2 frames left in the queue on closing
Conversion failed!
ffmpeg version v4.4-dev-416
 Copyright (c) 2000-2020 the FFmpeg developers
  built with Android (6454773 based on r365631c2) clang version 9.0.8 (https://android.googlesource.com/toolchain/llvm-project 98c855489587874b2a325e7a516b99d838599c6f) (based on LLVM 9.0.8svn)

  configuration: --cross-prefix=aarch64-linux-android- --sysroot=/files/android-sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/sysroot --prefix=/home/taner/Projects/mobile-ffmpeg/prebuilt/android-arm64/ffmpeg --pkg-config=/usr/bin/pkg-config --enable-version3 --arch=aarch64 --cpu=armv8-a --cc=aarch64-linux-android21-clang --cxx=aarch64-linux-android21-clang++ --extra-libs='-L/storage/light/projects/mobile-ffmpeg/prebuilt/android-arm64/cpu-features/lib -lndk_compat' --target-os=android --enable-neon --enable-asm --enable-inline-asm --enable-cross-compile --enable-pic --enable-jni --enable-optimizations --enable-swscale --enable-shared --enable-v4l2-m2m --disable-outdev=fbdev --disable-indev=fbdev --enable-small --disable-openssl --disable-xmm-clobber-test --disable-debug --enable-lto --disable-neon-clobber-test --disable-programs --disable-postproc --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --disable-sndio --disable-schannel

  libavutil      56. 55.100 / 56. 55.100

  libavcodec     58. 96.100 / 58. 96.100

  libavformat    58. 48.100 / 58. 48.100

  libavdevice    58. 11.101 / 58. 11.101

  libavfilter     7. 87.100 /  7. 87.100

  libswscale      5.  8.100 /  5.  8.100

  libswresample   3.  8.100 /  3.  8.100

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/Android/data/app.streamstudio.stream/files/class/class000046_NewJeans_Supernatural_hoois127/class_front_1080p_gop1_crf27.mp4':

  Metadata:

    major_brand     : 
isom
    minor_version   : 
512
    compatible_brands: 
isomiso2avc1mp41
    encoder         : 
Lavf60.3.100
  Duration: 
00:00:25.01
, start: 
0.000000
, bitrate: 
14924 kb/s
    Stream #0:0
(und)
: Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709), 1080x1920, 14789 kb/s
, 
30 fps, 
30 tbr, 
15360 tbn, 
60 tbc
 (default)
    Metadata:

      handler_name    : 
Core Media Video
      encoder         : 
Lavc60.3.100 libx264
    Stream #0:1
(und)
: Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 131 kb/s
 (default)
    Metadata:

      handler_name    : 
Core Media Audio
Stream mapping:

  Stream #0:0 -> #0:0
 (h264 (native) -> h264 (h264_v4l2m2m))
  Stream #0:1 -> #0:1
 (aac (native) -> aac (native))
Press [q] to stop, [?] for help

[graph 0 input from stream 0:0 @ 0xb400007c8a93c110] sws_param option is deprecated and ignored

[h264_v4l2m2m @ 0xb400007b1ac71d40] Could not find a valid device

[h264_v4l2m2m @ 0xb400007b1ac71d40] can't configure encoder

Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

[aac @ 0xb400007b1ac6edd0] Qavg: 152.892

[aac @ 0xb400007b1ac6edd0] 2 frames left in the queue on closing

Conversion failed!

Environment

  • Platform: Android (samsung galaxy s22 ultra)
  • Architecture: arm64-v8a
  • Version: LTS
  • Source branch: main
  • Android Studio version: LTS
  • Android NDK version: LTS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant