saki4510t / AudioVideoRecordingSample

Simultaneous audio and video recording sample using MediaCodec/MediaMuxer
Apache License 2.0
950 stars 291 forks source link

Change Camera While Recording #7

Closed rolandvar closed 7 years ago

rolandvar commented 8 years ago

How I can add a method to change the camera while recording?

saki4510t commented 8 years ago

Hi, I don't implement and test yet and this is just assuming, please try followings.

  1. First, you need to change #startPreview so that it can accept camera id(currently camera id is defined as constant).
  2. Start preview with a camera
  3. Start recording
  4. Stop preview
  5. start preview with different camera
  6. stop recording
    ...

As I know MediaCodec encoder can not change input Surface while encoding, but this sample use offscreen rendering technique to render video images on both screen(preview) and encoder at the same time. This means we can keep input Surface from MediaCodec encoder even if we change video source.

You may see error related SurfaceTexture(to receive video images for offscreen rendering) when changing camera. In that case I assume you need to dispose old SurfaceTexture and create it again (you will need exclusion control to avoid rendering while re-creating SurfaceTexture). saki

saki4510t commented 7 years ago

Close this because there are no activity

ShagunParikh commented 6 years ago

@Makingweb Did you implemented the switch camera successfully?