Delay in preparing media recorder on android

后端 未结 1 1387
执笔经年
执笔经年 2021-02-11 04:24

I am recording multiple small videos within 10 sec. I need to prepare and start media recorder again and again before creating any video. Due to which, there is a time lag of on

相关标签:
1条回答
  • 2021-02-11 04:50

    So Instagram also suffers from the MediaRecorder delay. You can tell when you do quick taps. The progress bar resets. It's only once you've held the record button for longer than a second does it actually capture anything.

    This is just an inherent flaw in MediaRecorder. The only way around this is to use the setPreviewCallbackWithBuffer API. In using this API you provide the camera with buffers to display the preview, and it calls back to you with the YUV frame that it showed on the preview surface. You can then pass this buffer through to MediaCodec to encode the video.

    Ideally, OEMs have implemented MediaCodec to understand the buffers being passed from the camera, but we've seen spotty performance on a lot of devices pre 4.3. Random MediaCodec implementations that expect different alignments and YUV formats than the camera provides for example. You'll also have to capture audio yourself and maintain AV sync.

    Alternatively you can pass the buffers to ffmpeg to encode - just be careful which codecs you build into ffmpeg. VP8 + vorbis is the best performing royalty free codecs we've seen.

    0 讨论(0)
提交回复
热议问题