VP8编码的Nexus 5返回空/ 0帧 [英] VP8 Encoding Nexus 5 returns empty/0-Frames

查看:786
本文介绍了VP8编码的Nexus 5返回空/ 0帧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图连接code我的相机饲料VP8。现在的问题是:当我得到的输出缓冲器的帧,字节数组始终是不同的大小,但所有的条目都为0

I'm trying to encode my camera feed to VP8. The problem is: when I get the frame from the output buffer, the byte array is always different size but all entries are 0.

这里的code其中我抢框架和打印:

Here's the code where I grab the frame and print it:

while (true) {
    try {
        encoderIndex = mEncoder.dequeueOutputBuffer(encoderOutputInfo, timeOut);
    } catch (Exception e) {
        e.printStackTrace();
    }
    switch (encoderIndex) {
    case MediaCodec.INFO_OUTPUT_BUFFERS_CHANGED:
        // something
        break;
    case MediaCodec.INFO_OUTPUT_FORMAT_CHANGED:
        // something else
        break;
    case MediaCodec.INFO_TRY_AGAIN_LATER:
        // something completely different
        break;
    default:
        // get encoded frame
        byte[] frame = new byte[encoderOutputInfo.size];

        mEncoderOutputBuffers[encoderIndex].get(frame);

        Log.v(tag, "got frame. size: " + frame.length);
        Log.v(tag, "printing frame");
        Log.v(tag, printBytesAsBinary(frame));

        mEncoderOutputBuffers[encoderIndex].clear();

        // release encoder output buffer
        mEncoder.releaseOutputBuffer(encoderIndex, false);
}

而印刷的logcat:

And the Logcat print:

02-07 11:48:19.014: V/GoogleEncoder(24883): got frame. size: 427
02-07 11:48:19.014: V/GoogleEncoder(24883): printing frame
02-07 11:48:19.014: V/GoogleEncoder(24883): 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
02-07 11:48:20.544: V/GoogleEncoder(24883): got frame. size: 379
02-07 11:48:20.544: V/GoogleEncoder(24883): printing frame
02-07 11:48:20.544: V/GoogleEncoder(24883): 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

任何人有这个问题已经可以告诉我什么,我可能是做错了什么?我已经尝试过的输出缓冲器搞乱(如倒带()),但似乎没有任何工作。

Anyone had this problem already and can tell me what I might be doing wrong? I already tried messing with the output buffer (e.g. rewind()) but nothing seems to work.

奇怪的是,编码工作与CyanogenMod的11台设备,这也是4.4(试穿了S3)

Oddly enough, encoding works on devices with Cyanogenmod 11 which is also 4.4 (Tried on a S3)

推荐答案

媒体codeC 并没有把的ByteBuffer 在正确的位置。您需要调用后手动放置它 dequeueOutputBuffer()

MediaCodec doesn't put the ByteBuffer in the correct position. You need to position it manually after the call to dequeueOutputBuffer():

int encoderStatus = encoder.dequeueOutputBuffer(info, TIMEOUT_USEC);
...
ByteBuffer encodedData = encoderOutputBuffers[encoderStatus];
encodedData.position(info.offset);
encodedData.limit(info.offset + info.size);

(请参见恩codeDE codeTEST 。)这是不一样的快退(),虽然我有点惊讶,没有工作 - 我本来期望的输出通常会开始在缓冲器的开头。

(See EncodeDecodeTest.) That's not the same as rewind(), though I'm a little surprised that didn't work -- I would have expected that output would usually start at the beginning of the buffer.

有一些已知的问题 VP8 在Android 4.3,但你似乎并不被打的。

There are some known issues with VP8 on Android 4.3, though you don't seem to be hitting those.

如果不能解决您的问题,这将有助于了解你正在使用(S3为Android和氰?),Android的软件版本,就看你使用的code中的设备配置()媒体codeC ,和什么样的价值观被使用。

If this does not fix your issue, it would be helpful to know the device you're using (S3 for both Android and Cyanogen?), the Android software version, to see the code you're using to configure() the MediaCodec, and what values are used.

这篇关于VP8编码的Nexus 5返回空/ 0帧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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