Skip to content

Commit

Permalink
Let the browser decide the best MIME-type
Browse files Browse the repository at this point in the history
For one, currently we prefer vp9 over other codecs. Chrome on Android
does support vp9, but encoding is very slow. This leads to ~2fps
recordings on non-powerful devices, which is obviously unacceptable.
Second, Safari only supports a few special MIME-types. We could special
case something for Safari, but we can also let the browser choose the
MIME-type. This is a good default.

We might want to add "expert settings" later with which advanced users
can tweak these things.
  • Loading branch information
LukasKalbertodt committed Jan 21, 2020
1 parent 20f918d commit 78a31ca
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions src/recorder.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
import { isRecordingSupported } from './util';

const findSupportedMimeType = list =>
isRecordingSupported() && 'isTypeSupported' in MediaRecorder
? list.find(mimeType => MediaRecorder.isTypeSupported(mimeType)) || ''
: '';

export default class Recorder {
constructor(stream, options = {}) {
const mimeType =
options.mimeType ||
(stream.getVideoTracks().length
? findSupportedMimeType([
'video/webm;codecs="vp9,opus"',
'video/webm;codecs="vp9.0,opus"',
'video/webm;codecs="avc1"',
'video/x-matroska;codecs="avc1"',
'video/webm;codecs="vp8,opus"'
])
: findSupportedMimeType(['audio/ogg;codecs=opus', 'audio/webm;codecs=opus']));
const mimeType = options.mimeType || undefined;

const _recData = [];
this.recorder = new MediaRecorder(stream, { mimeType });
Expand Down

0 comments on commit 78a31ca

Please sign in to comment.