user924
user924

Reputation: 12293

MediaRecorder - safe outputformat (video container) and codec to record playable video even when a device suddenly turns off

Now I use the next settings for MediaRecorder instance

setOutputFormat(MediaRecorder.OutputFormat.MPEG_4)

setVideoEncoder(
    if (isHevcCodecSupported()) {
        MediaRecorder.VideoEncoder.HEVC
    } else {
        MediaRecorder.VideoEncoder.H264
    }
)

If a device suddenly turns off (in case of low battery or other system failures which causes reboots or power off) then a currently recording video won't be playable - a corrupted video file.

Is there any settings for MediaRecorder (output format/codec) which will keep a recording video playable even in such cases?

Update

Seems WEBM format is playable even when a device turns off, though it's not seekable but at least you can play it in such cases.

But one problem - seems Android doesn't support audio encoding for WEBM output format, we can only do video recording MediaRecorder WEBM with both video and audio

Also problem with WEBM on Android that MediaRecorder.setOrientationHint() does nothing... It works fine with MP4 (avc+aac codecs)

Upvotes: 1

Views: 237

Answers (0)

Related Questions