Editing android VideoView frames

丶灬走出姿态 提交于 2019-11-29 13:47:36
Ronnie

You can extend the VideoView and override its draw(Canvas canvas) method.

  • Set your bitmap to the canvas received through draw.
  • Call super.draw() which will get the frame drawn onto your bitmap.
  • Access the frame pixels from the bitmap.

    class MotionDetectorVideoView extends VideoView {
    public Bitmap mFrameBitmap;
    ...
        @Override
        public void draw(Canvas canvas) {
            // set your own member bitmap to canvas..
            canvas.setBitmap(mFrameBitmap);
            super.draw(canvas);
            // do whatever you want with mFrameBitmap. It now contains the frame.
            ...
            // Allocate `buffer` big enough to hold the whole frame.
            mFrameBitmap.copyPixelsToBuffer(buffer);
            ...
        }
    }
    

I don't know whether this will work. Avoid doing heavy calculation in draw, start a thread there.

In your case I would use the Camera Preview instead the VideoView, if you are working with live motion, not recorded videos. You can use a Camera Preview Callback to catch everyframe captured by your camera. This callback implements :

onPreviewFrame(byte[] data, Camera camera)
Called as preview frames are displayed.

Which I think it could be useful for you.

http://developer.android.com/reference/android/hardware/Camera.PreviewCallback.html

Tell if that is what you are searching for.

Good luck.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!