Search code examples
androidmp4android-mediacodecmediamuxer

Record SurfaceView animation as video file in android


Last time I've investigated video exporting on android (Adding watermark bitmap over video in android: 4.3's MediaMuxer or ffmpeg) it wasn't an easy task.

Here's a scenario: I have a SurfaceView and a drawn BitMap at x,y coordinates. The user taps on the images and drags it around to step 2 and step 3.

enter image description here

So basically if I record all the x,y through which the touch went, I can replay the animation by drawing the BitMap at a certain framerate.

Now here's the question: is there an easy way to record the "animation" from the SurfaceView into a video file by using android components (no ffmpeg) ?


Solution

  • As far as I know, to record the events of the SurfaceView, you have to record the screen since the SurfaceView is different and does not draw in the normal view hierarchy.

    In fact, there are cases where the display data for the SurfaceView isn't even accessible to the app processor - it may be the output of a hardware video pipeline that is composited with the display output of the app processor through a dedicated video overlay. Google Groups

    A Creative way can be to capture the screen simultaneously during the event and create a MOV from the bitmaps. Please See : Create Video From Screen Capture