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

@fix-webm-duration/parser

v1.0.1

Published

Parse webm files into individual sections, edit the sections, and compile the file from edited sections back together

Downloads

54,480

Readme

@fix-webm-duration/parser

Parse webm files into individual sections, edit the sections, and compile the file from edited sections back together.

Warning: it's an internal implementation package, the interfaces here can change at any moment! Please don't use it directly in production code, only for debugging contents of webm files while developing!

Installation

Install from a package manager:

npm install @fix-webm-duration/parser

Usage

Parse a blob:

import { WebmFile } from "@fix-webm-duration/parser";

const file = await WebmFile.fromBlob(blob);

It will return an instance of WebmFile, which is a tree of sections with IDs. WebmFile and WebmContainer are containers for other sections, while all other classes of webm nodes (WebmUint, WebmFloat, WebmString) are the final leaves of the tree. WebmBase is the base node class that is uses for nodes with unrecognized IDs (the map of webm nodes in the library is not full, it's only a set of nodes required to fix webm duration).

Traverse nodes:

The data field of a parsed WebmContainer (or WebmFile) object contains a list of child nodes (which could be leaves or other sections).

Use the getSectionById method to get a direct child section by ID, e.g.

const segmentSection: WebmContainer | null = file.getSectionById(0x8538067);

Section IDs could be found in the sections.ts file.

Modify nodes

Use the setValue method to modify the value of nodes, e.g.

const durationSection = infoSection.getSectionById(0x489);
if (!durationSection) throw new Error("Duration section not found");
durationSection.setValue(60000);

Access regular array method for the data field to add or remove child nodes for a sections, e.g.

const durationSection = new WebmFloat("Duration");
durationSection.setValue(duration);
infoSection.data!.push({
    id: 0x489,
    data: durationSection,
});

Compile modified file back to blob

Call updateByData method of all modified WebmContainer and WebmFile objects in the reverse order, i.e. starting from the most nested nodes, and ending with the WebmFile object.

Call the toBlob method of the file to convert the parsed file to blob. Pass MIME type to it if it's not default, e.g. file.toBlob("audio/webm").