Search code examples
androidandroid-cameraandroid-mediarecorder

how to save camera preview frame in video?


I am trying to add a green frame when record a video using android camera like the image below. I build a custom cameraPreview and apply preview.setForeground(getDrawable(R.drawable.frame_green)); in the Camera Activity

After recording a video, this green frame won't show in the video.

enter image description here


Solution

  • You cannot use MediaRecorder to save a video with modified camera stream. You can use MediaCodec to encode modified video (see CameraToMpegTest sample at http://bigflake.com/mediacodec).

    Or you can post-process the video file, as suggested by H.Brooks in comments above.