This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] SK-AM62A-LP:android mediaodec 编码错误。

Guru**** 2422680 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1517317/sk-am62a-lp-android-mediacodec-encode-error

器件型号:SK-AM62A-LP


工具/软件:

您好、

当我使用 mediacodec 编码图像时、出现错误  

2025年03月15日 08:15:40.474 CocodeBufferChannel com.css.testvid D [C2.v4l2.avc.encoder#742]创建了带有分配器 ID 的输入块池 23 => poolID 18 - OK (0)
2025年03月15日 08:15:40.482 CCodecBufferChannel com.css.testvid i [C2.v4l2.avc.encoder#742]创建了带有分配器 ID 的输出块池 23 => poolID 17 - OK
2025年03月15日 08:15:40.483 CocodeBufferChannel com.css.testvid D [C2.v4l2.avc.encoder#742]已配置输出块池 ID 17 =>确定
2025年03月15日 08:15:40.484 CCodecBuffers com.css.testvid D 获取图形块失败:14
2025年03月15日 08:15:40.484 CCodecBufferChannel com.css.testvid W [C2.v4l2.avc.encoder#742] start:根本无法分配内存
2025年03月15日 08:15:40.484 编解码器 com.css.testvid E 输入缓冲区的初始准备失败
2025年03月15日 08:15:40.484 MediaCodec com.css.testvid E 编解码器报告错误 0xfffffff4/no_memory、actionCode 0、处于状态 5/启动时

我的 Android 版本: am62p-userdebug 15 AP4A.250105.002.A1 eng.root test-keys

bellow 是我的代码,它可以在其他设备上工作。

字符串 MimeType = MediaFormat.MimeType_VIDEO_AVC
MediaCodecList codecList =新的 MediaCodecList(MediaCodecList.ormal_codecs)
MediaFormat 格式= MediaFormat.createVideoFormat(MimeType,1,280,720);
字符串编码 CodecName = codecList.findEncoderForFormat (format);
请尝试
MediaCodec 编码器= MediaCodec.createByCodecName (encodeCodecName);
// Log.i(“testEncode",“,"codece、"codece info“ info:\n“+ MediaCodecInfoToString (encoder.getCodecInfo ()));
整型颜色格式= 0
MediaCodecInfo.CodecCapabilities = encoder.getCodecInfo().getCapabilitiesForType(MimeType);
对于 (int i = 0;i < Capabilities.colorFormats.length /*&& colorFormat == 0*/;i++){
Int fmt = Capabilities.colorFormats[i]
开关 (fmt){
CASE MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420Planar
CASE MediaCodecInfo.codecCapability.COLOR_FormatYUV420PackedPlanar
CASE MediaCodecInfo.codecCapabilities.COLOR_FormatYUV420SemiPlanar
CASE MediaCodecInfo.codecCapability.COLOR_FormatYUV420PackedSemiPlanar
CASE MediaCodecInfo.CodecCapability.COLOR_TI_FormatYUV420PackedSemiPlanar
if (colorFormat == 0)
颜色格式= fmt;
休息
默认值
休息
}
}
if (colorFormat=0)

log.e(“testEncode",“,"no、"no supported“ supported color format“)
返回
}
format.setInteger(MediaFormat.KEY_COLOR_FORMAT,颜色格式)
format.setInteger(MediaFormat.KEY_BIT_RATE,1024000 );
format.setInteger(MediaFormat.KEY_FRAME_RATE15);
// format.setInteger(MediaFormat.KEY_BITRATE_MODE、bitrate_mode_VBR);
format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL5);

ENCODER.CONFIGURE(格式,null、null、MediaCodec。configure_flag_encode)
ENCODER.START ();
} catch(例外 e){
e.printStackTrace();
}
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Zheng:

    我已将您的查询转至 Android 专家以获得支持。 请期待尽快答复。

    此致、

    Suren

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、

    您能否确认您正尝试编码的内容? (图像,视频等)  
    我们不测试此用例、只测试播放视频或编码 UI 屏幕。
    您是否有独立的应用程序可以与我共享、以便能够重现您的问题并进行调试? 如果你能提供一个你试图编码的例子。

    谢谢。
    Guillaume

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    你(们)好

    您可以使用 Android Studio 新建程序,并复制我的代码。 运行到 ENCODER.START () 时、出现错误。 无法开始编码。

    由于此代码可在其他设备上运行、我认为原因是缺少一些配置参数。 您能给我一个工作示例吗?

    谢谢。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、

    我会尝试您的代码。
    当我们使用 screenrecord 命令时,例如当您执行以下操作时:  

    adb root
    adb shell 'screenrecord /data/screenrecord.mp4' # Do some screen activity, then hit Ctrl-C
    adb pull /data/screenrecord.mp4


    screenrecord 仅在检测到某种用户活动时记录帧。 确保生成一些活动以避免视频文件为空。

    Guillaume

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    你(们)好

    Screenrecord 为 OK。 我的代码在哪里?

    谢谢。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、

    您是否尝试过我的代码并重现问题?

    谢谢。