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

media-codecs

v2.0.0

Published

Get a codec parameter string (like 'avc1.4d002a') from human readable options (like { name: 'Main', level: '4.2' }) and back to a descriptive name ('AVC Main Profile Level 4.2').

Downloads

208

Readme

media-codecs

npm version stability-stable npm minzipped size dependencies types Conventional Commits styled with prettier linted with eslint license

Get a codec parameter string (like "avc1.4d002a") from human readable options (like { name: "Main", level: "4.2" }) and back to a descriptive name ("AVC Main Profile Level 4.2").

Useful for checking supported codecs with HTMLMediaElement.canPlayType / MediaSource.isTypeSupported and to pass as option for the WebCodecs API VideoEncoder configure parameters. Supports Advanced Video Coding (AVC), Video Partition (VP8/VP9), AOMedia Video (AV1) and partially High Efficiency Video Coding HEVC.

See the demo that checks current browser support of all video codecs and MDN's Codecs in common media types.

paypal coinbase twitter

Installation

npm install media-codecs

Usage

import { AVC } from "media-codecs";

const codec = AVC.getCodec({ name: "Main", level: "4.2" });
// => avc1.4d002a
const mimeType = `video/mp4;codecs="${codec}"`;

console.log(MediaSource.isTypeSupported(mimeType));

Roadmap:

  • [ ] HEVC compatibility and constraints
  • [ ] VP, HEVC and AV1 optional parameters

API

Modules

Typedefs

index

vp

vp~VP_CODECS : Array.<CodecItem>

List of codecs

Kind: inner constant of vp

vp~VP_PROFILES : Array.<number>

List of VP profiles numbers

Kind: inner constant of vp

vp~VP_LEVELS : Array.<number>

VP Levels

Kind: inner constant of vp See: webmproject.org

vp~VP_BIT_DEPTH : Array.<number>

List of supported bit depth

Kind: inner constant of vp

vp~getAllItems() ⇒ Array.<MediaCodecItem>

Return a list of all possible codec parameter string and their human readable names

Kind: inner method of vp

vp~getCodec(options) ⇒ string

Get a codec parameter string

Kind: inner method of vp

| Param | Type | | ------- | ---------------------------------------------- | | options | VPCodecOptions |

vp~getCodecName(codec) ⇒ string

Get a codec human readbable name

Kind: inner method of vp

| Param | Type | Description | | ----- | ------------------- | ------------------------------------------------ | | codec | string | a codec string (avc1[.PPCCLL] eg. "avc1.640028") |

hevc

hevc~See : Array.<VCProfileItem>

List of profiles with their profile numbers (PP) and the compatibility (C).

Kind: inner constant of hevc

hevc~HEVC_PROFILE_COMPATIBILITY : Array.<number>

HEVC Profile Compatibility as a number in the 0..32 range TODO: is that correct

Kind: inner constant of hevc

hevc~HEVC_LEVELS : Array.<number>

HEVC Levels

Kind: inner constant of hevc See: hevc-levels

hevc~HEVC_TIER : Array.<number>

List of supported tier

Kind: inner constant of hevc

hevc~getAllItems() ⇒ Array.<MediaCodecItem>

Return a list of all possible codec parameter string and their human readable names

Kind: inner method of hevc

hevc~getCodec(options) ⇒ string

Get a codec parameter string

Kind: inner method of hevc

| Param | Type | | ------- | -------------------------------------------------- | | options | HEVCCodecOptions |

hevc~getCodecName(codec) ⇒ string

Get a codec human readbable name

Kind: inner method of hevc

| Param | Type | Description | | ----- | ------------------- | ------------------------------------------------------- | | codec | string | a codec string (cccc.PP.C.TLL.CC eg. "hev1.1.3.H34.B0") |

avc

avc~AVC_PROFILES : Array.<VCProfileItem>

List of profiles with their profile numbers (PP) and the constraints component (CC).

Kind: inner constant of avc

avc~AVC_LEVELS : Array.<number>

AVC Levels

Kind: inner constant of avc See: wikipedia.org

avc~getAllItems() ⇒ Array.<MediaCodecItem>

Return a list of all possible codec parameter string and their human readable names

Kind: inner method of avc

avc~getCodec(options) ⇒ string

Get a codec parameter string

Kind: inner method of avc

| Param | Type | | ------- | ------------------------------------------------ | | options | AVCCodecOptions |

avc~getCodecName(codec) ⇒ string

Get a codec human readbable name

Kind: inner method of avc

| Param | Type | Description | | ----- | ------------------- | -------------------------------------------------- | | codec | string | a codec string (cccc.PP.LL.DD eg. "vp09.00.10.08") |

av

av~AV_CODECS : Array.<CodecItem>

List of codecs

Kind: inner constant of av

av~AV_PROFILES : Array.<number>

List of AV profiles numbers

Kind: inner constant of av See: av1-spec

av~AV_LEVELS : Array.<number>

AV Levels

Kind: inner constant of av See: av1-spec

av~AV_TIER : Array.<number>

List of supported tier

Kind: inner constant of av

av~AV_BIT_DEPTH : Array.<number>

List of supported bit depth

Kind: inner constant of av

av~getAllItems() ⇒ Array.<MediaCodecItem>

Return a list of all possible codec parameter string and their human readable names

Kind: inner method of av

av~getCodec(options) ⇒ string

Get a codec parameter string

Kind: inner method of av

| Param | Type | | ------- | ---------------------------------------------- | | options | AVCodecOptions |

av~getCodecName(codec) ⇒ string

Get a codec human readbable name

Kind: inner method of av

| Param | Type | Description | | ----- | ------------------- | -------------------------------------------------- | | codec | string | a codec string (av01.P.LLT.DD eg. "av01.P.LLT.DD") |

VCProfileItem : Object

Kind: global typedef Properties

| Name | Type | Description | | ---- | ------------------- | ----------------------------------- | | name | string | | | PP | string | profile numbers as hex string | | CC | string | constraints component as hex string |

CodecItem : Object

Kind: global typedef Properties

| Name | Type | Description | | ---- | ------------------- | ----------------------------------- | | name | string | | | cccc | string | the four-character ID for the codec |

MediaCodecItem : Object

Kind: global typedef Properties

| Name | Type | | ----- | ------------------- | | name | string | | codec | string |

VPCodecOptions : Object

Kind: global typedef Properties

| Name | Type | Description | | -------- | ------------------- | ----------------------------------------- | | name | string | Human readable codec name: "VP8" or "VP9" | | profile | number | 0, 1, 2 or 3 | | level | string | | | bitDepth | number | |

AVCodecOptions : Object

Kind: global typedef Properties

| Name | Type | Description | | -------- | ------------------- | --------------------------------------------------------------- | | name | string | Human readable codec name: "AV1", potentially AV2 in the future | | profile | string | AV profile name: "Main", "High" or "Professional" | | level | string | | | tier | string | "Main" or "High" | | bitDepth | number | 8, 10 or 12 |

AVCCodecOptions : Object

Kind: global typedef Properties

| Name | Type | Description | | ------- | ------------------- | --------------------------------- | | profile | string | AVC profile name (eg. "Baseline") | | level | string | |

HEVCCodecOptions : Object

Kind: global typedef Properties

| Name | Type | Description | | ------------- | ------------------- | --------------------------------- | | profile | string | HEVC profile name (eg. "Main 10") | | compatibility | number | | | level | string | | | tier | string | "Main" or "High" | | constraint | string | TODO |

License

MIT. See license file.