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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@invintusmedia/tomp4

v1.0.9

Published

Convert MPEG-TS, fMP4, and HLS streams to MP4 with clipping support - pure JavaScript, zero dependencies

Readme

 

you've got an HLS stream, or some .ts segments, or fMP4 chunks.

you want an .mp4 file.

import toMp4 from '@invintusmedia/tomp4'

const mp4 = await toMp4('https://example.com/stream.m3u8')
mp4.download('my-video.mp4')

that's it. no ffmpeg. no wasm. no dependencies.

 

from different sources

// HLS playlist (auto-picks highest quality)
const mp4 = await toMp4('https://example.com/master.m3u8')

// single .ts segment
const mp4 = await toMp4('https://example.com/segment.ts')

// raw bytes you already have
const mp4 = await toMp4(uint8Array)

// pick your quality
const hls = await toMp4.parseHls('https://example.com/master.m3u8')
console.log(hls.qualities) // ['1080p', '720p', '480p']
const mp4 = await toMp4(hls.select('720p'))

clip to time range

// one-step: download HLS + clip (only fetches needed segments)
const mp4 = await toMp4('https://example.com/stream.m3u8', {
  startTime: 0,
  endTime: 30
})

// clip existing data (snaps to keyframes)
const mp4 = await toMp4(data, {
  startTime: 5,
  endTime: 15
})

analyze without converting

const info = toMp4.analyze(tsData)

info.duration      // 99.5 (seconds)
info.keyframes     // [{index: 0, time: 0}, {index: 150, time: 5.0}, ...]
info.videoCodec    // "H.264/AVC"
info.audioCodec    // "AAC"

progress callback

const mp4 = await toMp4(url, {
  onProgress: (msg, info) => {
    if (info?.percent !== undefined) {
      console.log(`${info.percent}% - ${msg}`)
    }
  }
})
// 10% - Downloading: 10%
// 50% - Downloaded 5.2 MB
// 60% - Frames: 300 video, 450 audio
// 100% - Complete

use the result

mp4.download('video.mp4')   // trigger download
video.src = mp4.toURL()     // play in video element
mp4.data                    // Uint8Array
mp4.toBlob()                // Blob
mp4.toArrayBuffer()         // ArrayBuffer
mp4.revokeURL()             // free memory

 

what it does

remuxes video. no transcoding.

| input | output | |-------|--------| | .ts (MPEG-TS) | .mp4 | | .m4s (fMP4) | .mp4 | | .m3u8 (HLS) | .mp4 |

video: H.264, H.265
audio: AAC

 

what it doesn't do

  • transcode (no converting h264→h265, etc)
  • handle DRM/encrypted streams
  • support MP3, AC-3 audio (yet)

 

browser + node

works in both. ~50kb minified.

<script type="module">
  import toMp4 from '@invintusmedia/tomp4'
</script>

 

MIT