arthenica / ffmpeg-kit

FFmpeg Kit for applications. Supports Android, Flutter, iOS, Linux, macOS, React Native and tvOS. Supersedes MobileFFmpeg, flutter_ffmpeg and react-native-ffmpeg.
https://arthenica.github.io/ffmpeg-kit
GNU Lesser General Public License v3.0
4.52k stars 603 forks source link

MediaCodec & Android: crashes with generic error #1027

Open filnik opened 2 months ago

filnik commented 2 months ago

I've tried to compile by hand the ffmpeg-kit adding the mediacodec. The build should be successful since I'm able to use libopenh264 correctly.

However, if I set the codec to h264_mediacodec I got a generic error :

[amediacodec @ 0xb400007947296700] android.media.MediaCodec$CodecException: Error 0xffffffc3
[h264_mediacodec @ 0xb4000079e3740800] MediaCodec configure failed, Generic error in an external library

and I cannot find a way to make it work. The command I'm using is the following:

val VIDEO_WIDTH = 1080
val VIDEO_HEIGHT = 1920
val BITRATE_MBS = 7 * 1000000 // 7 Mbps
val cmd = mutableListOf(
    "-y",
    "-i", tempInputFile.absolutePath,
    "-vf", "scale=w=$VIDEO_WIDTH:h=$VIDEO_HEIGHT:force_original_aspect_ratio=decrease",
    "-c:v", "h264_mediacodec",
    "-b:v", "$BITRATE_MBS",
    outputPath
)

Any idea to solve the issue would be really appreaciated! Thank you :)

HitRoxxx commented 2 months ago

ffmpeg CLI does not support h264_mediacodec or any mediacodec encoder/decoder.

cinemast commented 1 month ago

Do you have any reference ffmpeg CLI not supporting h264_mediacodec?

Here is an excerpt from ffmpeg -codecs from a Nokia 7.2

DEV.L. h261                 
 DEV.L. h263                  (decoders: h263 h263_v4l2m2m ) (encoders: h263 h263_v4l2m2m )
 D.V.L. h263i                
 DEV.L. h263p                
 DEV.LS h264                  (decoders: h264 h264_v4l2m2m h264_mediacodec ) (encoders: h264_mediacodec h264_v4l2m2m )
 DEVIL. hap                  
 DEVIL. hdr                  
 DEV.L. hevc                  (decoders: hevc hevc_v4l2m2m hevc_mediacodec ) (encoders: hevc_mediacodec hevc_v4l2m2m libkvazaar )
 D.V.L. hnm4video            
tanersener commented 3 weeks ago

I suggest checking the logcat logs. MediaCodec logs are printed to logcat.