How to add duration to metadata of files recorder by MediaRecorder
Asked Answered
D

1

8

I am recording video by MediaRecorder in Chrome. My code is similar to an example from MediaStream docs. I am receiving videos that do not have Duration metadata.

I compared it by mediainfo with exemplary webm file from:

https://file-examples-com.github.io/uploads/2020/03/file_example_WEBM_480_900KB.webm

On the left, there are metadata of file recorded by MediaRecorder, on the right from the exemplary webm file.

enter image description here

Detailed comparison on DiffChecker

https://www.diffchecker.com/87G23lbX

There are three key differences:

In the file from MediaRecorder:

  1. there is lacking Duration.
  2. there is lacking Bit rate.
  3. there is added IsTruncated: Yes.

In effect when I add this file to the video tag on website with controls attribute, then I can use controls only when file is displayed to the end.

I need to fix it and save non truncated files with this duration. Both frontend and backend solutions are accepted.

Deplete answered 28/8, 2020 at 20:16 Comment(2)
I fixed thanks to package github.com/yusitnikov/fix-webm-duration/blob/master/…, but I am surprised that it is done by low-level access to sections of webm binary.Deplete
Related: https://mcmap.net/q/1230219/-how-to-save-mediarecorder-stream-to-ogg-file-in-php-including-metadata/1066234Tooling
H
3

The solution proposed by daniel works like a charm, which was to use the library from https://github.com/yusitnikov/fix-webm-duration to add the duration metadata to the webm Blob.

Helbon answered 29/6, 2023 at 10:33 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.