Initialize a video callback like this
mReceivedVideoDataCallBack = new DJICamera.CameraReceivedVideoDataCallback() { @Override public void onResult(byte[] videoBuffer, int size) { if(mCodecManager != null){
Do your work by implementing TextureView.SurfaceTextureListener and for TextureView mVideoSurface call this line after its initialization:
mVideoSurface.setSurfaceTextureListener(this);
and then do:
@Override public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) { Log.v(TAG, "onSurfaceTextureAvailable"); DJICamera camera = FPVDemoApplication.getCameraInstance(); if (mCodecManager == null && surface != null && camera != null) { //Normal init for the surface mCodecManager = new DJICodecManager(this, surface, width, height); Log.v(TAG, "Initialized CodecManager"); } } @Override public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) { Log.v(TAG, "onSurfaceTextureSizeChanged"); } @Override public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) { Log.v(TAG, "onSurfaceTextureDestroyed"); if (mCodecManager != null) { mCodecManager.cleanSurface(); mCodecManager = null; } return false; } @Override public void onSurfaceTextureUpdated(SurfaceTexture surface) { final Bitmap image = mVideoSurface.getBitmap(); //Do whatever you want with the bitmap image here on every frame }
Hope this helps!
source share