From 683e9daf403df3dfedecb9ac5193901815d4ba47 Mon Sep 17 00:00:00 2001 From: Simon Ott <78349773+ottsimon@users.noreply.github.com> Date: Thu, 19 Dec 2024 14:19:38 +0100 Subject: [PATCH 1/2] Apply the webm duration fix only to webm files --- src/steps/recording/recorder.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/steps/recording/recorder.tsx b/src/steps/recording/recorder.tsx index 3f322694..17ad574c 100644 --- a/src/steps/recording/recorder.tsx +++ b/src/steps/recording/recorder.tsx @@ -64,7 +64,15 @@ 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; + + if (mainMimeType === "video/webm") { + media = await fixWebmDuration(new Blob(this.#data, { type: mimeType })); + } else { + media = new Blob(this.#data, { type: mimeType }); + } + const url = URL.createObjectURL(media); this.#reset(); From f6b29135c03e11bbf4e630fc6d542c2560000855 Mon Sep 17 00:00:00 2001 From: Simon Ott <78349773+ottsimon@users.noreply.github.com> Date: Thu, 19 Dec 2024 15:45:36 +0100 Subject: [PATCH 2/2] Apply fix also for mkv files --- src/steps/recording/recorder.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/steps/recording/recorder.tsx b/src/steps/recording/recorder.tsx index 17ad574c..8cdaf117 100644 --- a/src/steps/recording/recorder.tsx +++ b/src/steps/recording/recorder.tsx @@ -67,7 +67,9 @@ export default class Recorder { const mainMimeType = mimeType.split(";")[0].trim(); let media; - if (mainMimeType === "video/webm") { + 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 });