VP8 Encoding Nexus 5 returns empty/0-Frames

前端 未结 1 968
一整个雨季
一整个雨季 2020-12-20 05:36

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.

相关标签:
1条回答
  • 2020-12-20 05:43

    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);
    

    (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.

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

    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.

    0 讨论(0)
提交回复
热议问题