Android的如何提高ffmpeg的MP4 perfromance? [英] Android how to increase ffmpeg mp4 perfromance?

查看:239
本文介绍了Android的如何提高ffmpeg的MP4 perfromance?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已检测功能 AV codec_de code_audio3 作品使用MP4格式慢,在这里我的code周期解码音频:

I have detected that function avcodec_decode_audio3 works slow with mp4 format, here my code cycle for decoding audio:

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) {
                    break;
                    return 1;
                }
                if (out_size > 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,它工作正常。 AV codec_de code_audio3 采取解码MP3架约1-2 milisecounds与 out_size = 4608,但随着MP4的解码相同的帧大小大约需要6-7 millisecounds。我接到的这里

But with other formats like flac and mp3 it works fine. avcodec_decode_audio3 take about 1-2 milisecounds for decoding mp3 frame with out_size = 4608 but with the same frame size in mp4 decoding take about 6-7 millisecounds. I got my build script from here.

它是否正常行为?什么办法可以提高解码MP4的表现呢?

Does it normal behavior? Is any way to increase performance of decoding mp4?

推荐答案

ü可以硬件加速搜索...

u could search on hardware acceleration...

H / W加速H.264解码Android上的

"H/W Accelerated H.264 Decoding on Android"

例如:

<一个href=\"http://stackoverflow.com/questions/11321825/how-to-use-hardware-accelerated-video-decoding-on-android\">How在Android上使用硬件加速的视频解码?

http://readlist.com/lists/mplayerhq。胡/ mplayer的用户/ 5 / 26751.html

IMO - ffmpeg的仍主要集中在软件,但在Android的新版本,你可以找到一些stagefright的API提供GPU加速的方式来访问帧缓冲??

IMO - ffmpeg is still mostly in software but on the newer versions of android, you may be able to find some stagefright API's providing GPU accelerated way to access the framebuffer??

这篇关于Android的如何提高ffmpeg的MP4 perfromance?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆