- From: Zheng Yun via GitHub <sysbot+gh@w3.org>
- Date: Mon, 13 Jun 2022 13:03:56 +0000
- To: public-webrtc-logs@w3.org
> A few years have passed and there is still no official solution. The good solution I've tried so far is this `webm-duration-fix` for those who need it. It supports fixing recording files larger than 2GB and has a low memory footprint when fixing. based on ts-ebml,Support browser and node。 https://github.com/buynao/webm-duration-fix
>
> ```
> import fixWebmDuration from 'webm-duration-fix';
>
> const mimeType = 'video/webm\;codecs=vp9';
> const blobSlice: BlobPart[] = [];
>
> mediaRecorder = new MediaRecorder(stream, {
> mimeType
> });
>
> mediaRecorder.ondataavailable = (event: BlobEvent) => {
> blobSlice.push(event.data);
> }
>
> mediaRecorder.onstop = async () => {
> // fix blob, support fix webm file larger than 2GB
> const fixBlob = await fixWebmDuration(new Blob([...blobSlice], { type: mimeType }));
> // to write locally, it is recommended to use fs.createWriteStream to reduce memory usage
> const fileWriteStream = fs.createWriteStream(inputPath);
> const blobReadstream = fixBlob.stream();
> const blobReader = blobReadstream.getReader();
>
> while (true) {
> let { done, value } = await blobReader.read();
> if (done) {
> console.log('write done.');
> fileWriteStream.close();
> break;
> }
> fileWriteStream.write(value);
> value = null;
> }
> blobSlice = [];
> };
> ```
this one can not run in project with es2022
--
GitHub Notification of comment by ZHENGYUN01
Please view or discuss this issue at https://github.com/w3c/mediacapture-record/issues/119#issuecomment-1153888129 using your GitHub account
--
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Monday, 13 June 2022 13:03:57 UTC