AgoraIO / Advanced-Video

MIT License
261 stars 336 forks source link

Android App crashing while stroing videoFrame into videobuffer, showing BufferOverflowException in bytebuffercapture.put(buf) #248

Open abhinavbhadauria-bigstep opened 3 years ago

abhinavbhadauria-bigstep commented 3 years ago

@Override public void onCaptureVideoFrame(int videoFrameType, int width, int height, int bufferLength, int yStride, int uStride, int vStride, int rotation, long renderTimeMs) { byte[] buf = new byte[bufferLength]; byteBufferCapture.limit(bufferLength); byteBufferCapture.get(buf); byteBufferCapture.flip();

    for (MediaDataVideoObserver observer : videoObserverList) {
        observer.onCaptureVideoFrame(buf, videoFrameType, width, height, bufferLength, yStride, uStride, vStride, rotation, renderTimeMs);
    }

    byteBufferCapture.put(buf);
    byteBufferCapture.flip();

    if (beCaptureVideoShot) {
        beCaptureVideoShot = false;

        getVideoSnapshot(width, height, rotation, bufferLength, buf, captureFilePath, yStride, uStride, vStride);
    }
}

@Override
public void onPreEncodeVideoFrame(int videoFrameType, int width, int height, int bufferLength, int yStride, int uStride, int vStride, int rotation, long renderTimeMs) {
    byte[] buf = new byte[bufferLength];
    byteBufferCapture.limit(bufferLength);
    byteBufferCapture.get(buf);
    byteBufferCapture.flip();

    for (MediaDataVideoObserver observer : videoObserverList) {
        observer.onPreEncodeVideoFrame(buf, videoFrameType, width, height, bufferLength, yStride, uStride, vStride, rotation, renderTimeMs);
    }

    byteBufferCapture.put(buf);
    byteBufferCapture.flip();

    if (beCaptureVideoShot) {
        beCaptureVideoShot = false;

        getVideoSnapshot(width, height, rotation, bufferLength, buf, captureFilePath, yStride, uStride, vStride);
    }
}
yoreland commented 3 years ago

which sdk version you are currently using?