npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@w-xuefeng/fix-webm-metainfo

v1.0.8

Published

a lib based on ts-ebml and support large file (>2GB)

Downloads

9

Readme

fix-webm-metainfo

This is a lib based on ts-ebml and support large file (>2GB) which ts-ebml not supported

Use this function can not only add "Duration" but also add "SeekHead", "Seek", "SeekID", "SeekPosition" and "Cues", "CueTime", "CueTrack", "CueClusterPosition", "CueTrackPositions", "CuePoint" for a webm file

Usage

import fixWebmMetaInfo from 'fix-webm-metainfo';

const mimeType = 'video/webm\;codecs=vp9';
const blobSlice: BlobPart[] = [];

mediaRecorder = new MediaRecorder(stream, {
  mimeType,
  videoBitsPerSecond: 1e6
});

mediaRecorder.ondataavailable = (event: BlobEvent) => {
  blobSlice.push(event.data);
}

mediaRecorder.onstop = async () => {
  // support fix webm file larger than 2GB
  const fixedWebMBlob = await fixWebmMetaInfo(new Blob([...blobSlice], { type: mimeType }));
  blobSlice = [];
};

// use timeslice to avoid memory consumption in renderer process, and generate blob size each second
mediaRecorder.start(1000);
setTimeout(() => mediaRecorder.stop(), 5000); // generate 5 blob slices

Release Note

v1.0.6:
fix: using Blob instead of arrayBuffer to fix recreate webm and solving memory leak

v1.0.5
feat: initial commit

Tips for using this library

Does this library has memory leak (both in main process and renderer process) ?

Currently each record will have a maxiumm 5MB memory leak (already the best result, because chromium interal blob <-> arrayBuffer process has some kind of bug, and we have to regenerate webm meta head), if you have the ability to modify chromium, this value can decrease down to 1MB or even much smaller size.

How to decrease memory leak(decrease page zie)?

The only why is modify chromium project, here is the example:

// storage/browser/blob/blob_storage_constants.cc
#if defined(OS_ANDROID)
// On minimal Android maximum in-memory space can be as low as 5MB.
constexpr uint64_t kDefaultMinPageFileSize = 5ull * 1024 * 1024 / 2;
const float kDefaultMaxBlobInMemorySpaceUnderPressureRatio = 0.02f;
#else
// fix1: change 5MB minPageSize to 1MB
constexpr uint64_t kDefaultMinPageFileSize = 1ull * 1024 * 1024;
const float kDefaultMaxBlobInMemorySpaceUnderPressureRatio = 0.002f;
#endif
What is the maximum record file size?

According to chromium blob implention, this value varies from Math.min(software located disk partition size * / 10, free disk space), so if you C:\ partition is 128GB, the max record size is 12.8GB, even if you have 100GB free space.

how to get rid of the limit of record file size?

The only why is modify chromium project, here is the example:

// storage/browser/blob/blob_memory_controller.cc
if (disk_size >= 0) {
#if defined(OS_CHROMEOS)
  limits.desired_max_disk_space = static_cast<uint64_t>(disk_size / 2ll);
#elif defined(OS_ANDROID)
  limits.desired_max_disk_space = static_cast<uint64_t>(3ll * disk_size / 50);
#else
  // fix2: make file limit from 1/10 disk size to 1/1
  limits.desired_max_disk_space = static_cast<uint64_t>(disk_size);
#endif
}
Why timeslice will reduce memory usage?

Because blob creation has a Renderer -> Main -> Memory/Disk Transport process, and if no mediaRecord.RequestData() called or timeslice specified, then all data will be buffered in renderer process, we have to clear the data in memory.

What Video record tooks me 2GB(x64) in main process?

Because Blob designed to be store in sharedMemory initially, and if the memory is not enough to store, it will use disk space to store blob afterward.

how can i not use memory and directly store blob to disk?

The only why is modify chromium project, here is the example:

// storage/browser/blob/blob_memory_controller.cc
if (memory_size > 0) {
#if !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
  // fix3: make 2GB -> 200MB to decrease main process memory usage
  constexpr size_t kTwoHundrendMegabytes = 2ull * 100 * 1024 * 1024;
  limits.max_blob_in_memory_space = kTwoHundrendMegabytes;
#elif defined(OS_ANDROID)
  limits.max_blob_in_memory_space = static_cast<size_t>(memory_size / 100ll);
#else
  limits.max_blob_in_memory_space = static_cast<size_t>(memory_size / 5ll);
#endif
}

What is the current limit of this library

  1. using web worker to decrease thread crimp (already implement, will suport later)
  2. decrease runtime fix memory consumption
  3. support non-node enviroment fixup

License

GPL General Public License 3.0 see http://www.gnu.org/licenses/gpl-3.0.html