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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@amazon/vinyl-transmux

v1.1.1

Published

MPEG-TS to fMP4 transmuxer for browser and Node.

Readme

@amazon/vinyl-transmux

Website npm size

Converts MPEG-TS and raw ADTS segments into fragmented MP4 (fMP4) for playback via Media Source Extensions. Zero external dependencies.

Install

npm install @amazon/vinyl-transmux

Architecture

The package is split into three layers:

┌─────────────────────────────────────────────┐
│  transmux      Stateful transmuxer          │
│                (createTransmuxer)           │
├─────────────────────────────────────────────┤
│  sampleEntry   Codec-specific MP4 boxes     │
│                (mp4a/esds, avc1/avcC)       │
├──────────────────┬──────────────────────────┤
│  mp4             │  mpegts / adts           │
│  Generic fMP4    │  Demux + parse           │
│  box writer      │                          │
└──────────────────┴──────────────────────────┘
  • mp4 — Generic ISO BMFF box writer. Produces ftyp, moov, moof, mdat, and all structural sub-boxes. No codec knowledge. Configurable via options with sensible defaults.
  • mpegts — MPEG Transport Stream demuxer. Parses PAT/PMT, reassembles PES packets, extracts PTS timestamps.
  • adts — Audio Data Transport Stream parser. Extracts AAC frame boundaries, sample rates, and channel configuration.
  • sampleEntry — Codec-specific MP4 sample entry builders. Produces mp4a + esds for AAC and avc1 + avcC for H.264. This is the only layer with codec knowledge.
  • transmux — Stateful orchestrator. Detects the input format (MPEG-TS or raw ADTS), demuxes, parses codec configuration, builds the fMP4 init and media segments.

Usage

import { createTransmuxer } from '@amazon/vinyl-transmux'

const transmuxer = createTransmuxer()

// For each HLS segment (ArrayBuffer of MPEG-TS or ADTS data):
const result = transmuxer.transmux(segmentData)

// result.initSegment — ftyp + moov (always returned, cached after first call)
// result.mediaSegment — moof + mdat
// result.duration — segment duration in seconds

The transmuxer is stateful — call transmux() for each segment in order. It tracks decode timestamps, sequence numbers, and codec configuration across calls. The init segment is generated on the first call and cached for subsequent calls.

Supported Formats

| Input | Output | Status | | ------------------ | ------------------------------- | ------ | | ADTS AAC | fMP4 audio (mp4a) | yes | | MPEG-TS with AAC | fMP4 audio (mp4a) | yes | | MPEG-TS with H.264 | fMP4 video (avc1) | yes | | MPEG-TS muxed | fMP4 video + audio (multi-trak) | yes |

MP4 Box Writer

The mp4 module is a general-purpose fMP4 box writer, usable independently of the transmuxer:

import {
    box,
    fullBox,
    ftyp,
    moov,
    audioTrak,
    videoTrak,
    moof,
    mdat,
    patchDataOffset,
} from '@amazon/vinyl-transmux'

const ftypBox = ftyp({
    majorBrand: 'dash',
    compatibleBrands: ['iso6', 'mp41'],
})

const moovBox = moov(
    audioTrak({
        trackId: 1,
        sampleRate: 44100,
        channelCount: 2,
        sampleEntry: myAudioSampleEntry,
    }),
    videoTrak({
        trackId: 2,
        width: 1920,
        height: 1080,
        sampleEntry: myVideoSampleEntry,
    })
)

const moofBox = moof({
    sequenceNumber: 1,
    trackId: 1,
    baseDecodeTime: 0,
    samples: [
        { duration: 1024, size: 400 },
        { duration: 1024, size: 380 },
    ],
})
patchDataOffset(moofBox, moofBox.byteLength)
const mdatBox = mdat(rawMediaData)

ID3 Tags

Leading ID3v2 tags (common in HLS for timed metadata) are automatically skipped before format detection.

H.264 SPS Parsing

The transmuxer includes a minimal H.264 SPS parser that extracts resolution and profile information from Sequence Parameter Set NAL units. It supports Baseline, Main, and High profiles including the chroma format and scaling matrix extensions.

License

Apache-2.0