c/c++语言开发共享Android如何增加ffmpeg mp4的性能?

我已经检测到函数avcodec_decode_audio3在mp4格式下运行缓慢,这里是解码音频的代码周期:

 while (av_read_frame(av_format_context, &packet) >= 0 && is_play == 1) { if (av_codec_context->codec_type == AVMEDIA_TYPE_AUDIO && is_play == 1) { int out_size = AVCODEC_MAX_AUDIO_FRAME_SIZE; int size = packet.size; int n; int dataLength = size; int decoded = 0; while (size > 0) { //start measure time gettimeofday(&tvBegin, NULL); int len = avcodec_decode_audio3(av_codec_context, (int16_t *) pAudioBuffer, &out_size, &packet); //stop measure time gettimeofday(&tvEnd, NULL); timeval_subtract(&tvDiff, &tvEnd, &tvBegin); LOGI("%d", tvDiff.tv_usec / 1000); LOGI("len='%d'", len); LOGI("out_size='%d'", out_size); if (len  0) { jbyte *bytes = (*env)->GetByteArrayElements(env, array, NULL); memcpy(bytes, (int16_t *) pAudioBuffer, out_size); (*env)->ReleaseByteArrayElements(env, array, bytes, 0); (*env)->CallVoidMethod(env, obj, play, array, out_size, is_play); } size -= len; } } if (packet.data) av_free_packet(&packet); } 

但是对于像flac和mp3这样的其他格式,它可以正常工作。 avcodec_decode_audio3需要大约1-2个avcodec_decode_audio3用于解码具有out_size = 4608的mp3帧,但是在mp4解码中具有相同的帧大小需要大约6-7毫秒。 我从这里得到了我的构建脚本。

这是正常的行为吗? 有什么方法可以提高解码mp4的性能?

    你可以搜索硬件加速……

    “H / W在Android上加速H.264解码”

    例如:

    如何在Android上使用硬件加速video解码?

    IMO – ffmpeg仍然主要在软件中,但在较新版本的android上,你可能会发现一些stagefright API提供GPU加速方式来访问framebuffer?

      以上就是c/c++开发分享Android如何增加ffmpeg mp4的性能?相关内容,想了解更多C/C++开发(异常处理)及C/C++游戏开发关注计算机技术网(www.ctvol.com)!)。

      本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

      ctvol管理联系方式QQ:251552304

      本文章地址:https://www.ctvol.com/c-cdevelopment/549251.html

      (0)
      上一篇 2021年1月14日
      下一篇 2021年1月14日

      精彩推荐