Skip to content

Commit

Permalink
Apply the webm duration fix only to specific MimeTypes (#1210)
Browse files Browse the repository at this point in the history
This PR should fix
#1192
fixWebmDuration is only applied if the MimeType is "video/webm" or
"video/x-matroska".
Other formats can easily be added.

Tested with Chrome and Firefox on Windows and with Chrome, Firefox and
Safari on MacOS.
  • Loading branch information
LukasKalbertodt authored Jan 14, 2025
2 parents fc95dc9 + f6b2913 commit 9579fa0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/steps/recording/recorder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,17 @@ export default class Recorder {

#onStop = async (_event: Event) => {
const mimeType = this.#data[0]?.type || this.#recorder.mimeType;
const media = await fixWebmDuration(new Blob(this.#data, { type: mimeType }));
const mainMimeType = mimeType.split(";")[0].trim();
let media;

const fixMimeTypes = ["video/webm", "video/x-matroska"];

if (fixMimeTypes.includes(mainMimeType)) {
media = await fixWebmDuration(new Blob(this.#data, { type: mimeType }));
} else {
media = new Blob(this.#data, { type: mimeType });
}

const url = URL.createObjectURL(media);

this.#reset();
Expand Down

0 comments on commit 9579fa0

Please sign in to comment.