Socket
Socket
Sign inDemoInstall

media-codecs

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    media-codecs

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').


Version published
Weekly downloads
171
increased by205.36%
Maintainers
1
Created
Weekly downloads
 

Changelog

Source

2.0.1 (2024-05-24)

Bug Fixes

  • update types (40adc3b)

Readme

Source

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({ profile: "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

media-codecs
av
avc
hevc
vp

Typedefs

AVProfileItem : object
VCProfileItem : object
CodecItem : object
MediaCodecItem : object
VPCodecOptions : object
AVCodecOptions : object
AVCCodecOptions : object
HEVCCodecOptions : object

media-codecs

media-codecs.VP : vp

Kind: static property of media-codecs

media-codecs.AV : av

Kind: static property of media-codecs

media-codecs.AVC : avc

Kind: static property of media-codecs

media-codecs.HEVC : hevc

Kind: static property of media-codecs

av

av.AV_CODECS : Array.<CodecItem>

List of codecs

Kind: static constant of av

av.AV_PROFILES : Array.<AVProfileItem>

List of AV profiles numbers

Kind: static constant of av See: av1-spec

av.AV_LEVELS : Array.<string>

AV Levels

Kind: static constant of av See: av1-spec

av.AV_TIER : Array.<string>

List of supported tier

Kind: static constant of av

av.AV_BIT_DEPTH : Array.<number>

List of supported bit depth

Kind: static constant of av

av.getAllItems() ⇒ Array.<MediaCodecItem>

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

Kind: static method of av

av.getCodec(options) ⇒ string

Get a codec parameter string

Kind: static method of av

ParamType
optionsAVCodecOptions

av.getCodecName(codec) ⇒ string

Get a codec human readbable name

Kind: static method of av

ParamTypeDescription
codecstringa codec string (av01.P.LLT.DD eg. "av01.P.LLT.DD")

avc

avc.AVC_PROFILES : Array.<VCProfileItem>

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

Kind: static constant of avc

avc.AVC_LEVELS : Array.<number>

AVC Levels

Kind: static 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: static method of avc

avc.getCodec(options) ⇒ string

Get a codec parameter string

Kind: static method of avc

ParamType
optionsAVCCodecOptions

avc.getCodecName(codec) ⇒ string

Get a codec human readbable name

Kind: static method of avc

ParamTypeDescription
codecstringa codec string (cccc.PP.LL.DD eg. "vp09.00.10.08")

hevc

hevc.HEVC_PROFILES : Array.<VCProfileItem>

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

See Annexe 3 Profiles

Kind: static 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: static constant of hevc

hevc.HEVC_LEVELS : Array.<string>

HEVC Levels

Kind: static constant of hevc See: hevc-levels

hevc.HEVC_TIER : Array.<string>

List of supported tier

Kind: static constant of hevc

hevc.getAllItems() ⇒ Array.<MediaCodecItem>

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

Kind: static method of hevc

hevc.getCodec(options) ⇒ string

Get a codec parameter string

Kind: static method of hevc

ParamType
optionsHEVCCodecOptions

hevc.getCodecName(codec) ⇒ string

Get a codec human readbable name

Kind: static method of hevc

ParamTypeDescription
codecstringa codec string (cccc.PP.C.TLL.CC eg. "hev1.1.3.H34.B0")

vp

vp.VP_CODECS : Array.<CodecItem>

List of codecs

Kind: static constant of vp

vp.VP_PROFILES : Array.<number>

List of VP profiles numbers

Kind: static constant of vp

vp.VP_LEVELS : Array.<string>

VP Levels

Kind: static constant of vp See: webmproject.org

vp.VP_BIT_DEPTH : Array.<number>

List of supported bit depth

Kind: static constant of vp

vp.getAllItems() ⇒ Array.<MediaCodecItem>

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

Kind: static method of vp

vp.getCodec(options) ⇒ string

Get a codec parameter string

Kind: static method of vp

ParamType
optionsVPCodecOptions

vp.getCodecName(codec) ⇒ string

Get a codec human readbable name

Kind: static method of vp

ParamTypeDescription
codecstringa codec string (avc1[.PPCCLL] eg. "avc1.640028")

AVProfileItem : object

Kind: global typedef Properties

NameTypeDescription
namestring
PPstringprofile numbers (seq_profile)

VCProfileItem : object

Kind: global typedef Properties

NameTypeDescription
namestring
PPstringprofile numbers as hex string
CCstringconstraints component as hex string

CodecItem : object

Kind: global typedef Properties

NameTypeDescription
namestring
ccccstringthe four-character ID for the codec

MediaCodecItem : object

Kind: global typedef Properties

NameType
namestring
codecstring

VPCodecOptions : object

Kind: global typedef Properties

NameTypeDescription
namestringHuman readable codec name: "VP8" or "VP9"
profilenumber0, 1, 2 or 3
levelstring
bitDepthnumber

AVCodecOptions : object

Kind: global typedef Properties

NameTypeDescription
namestringHuman readable codec name: "AV1", potentially AV2 in the future
profilestringAV profile name: "Main", "High" or "Professional"
levelstring
tierstring"Main" or "High"
bitDepthnumber8, 10 or 12

AVCCodecOptions : object

Kind: global typedef Properties

NameTypeDescription
profilestringAVC profile name (eg. "Baseline")
levelstring

HEVCCodecOptions : object

Kind: global typedef Properties

NameTypeDescription
profilestringHEVC profile name (eg. "Main 10")
compatibilitynumber
levelstring
tierstring"Main" or "High"
constraintstringTODO

License

MIT. See license file.

Keywords

FAQs

Last updated on 24 May 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc