From 20e4610da40acd3c0d831cbd7c891a321d66061b Mon Sep 17 00:00:00 2001 From: Vanilagy <1696106+Vanilagy@users.noreply.github.com> Date: Fri, 16 Jan 2026 20:51:27 +0100 Subject: [PATCH] Document MPEG-TS --- README.md | 2 +- docs/guide/input-formats.md | 2 + docs/guide/introduction.md | 2 +- docs/guide/output-formats.md | 29 +++++++++++- docs/guide/supported-formats-and-codecs.md | 55 +++++++++++----------- 5 files changed, 59 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 738f4fb..5c80224 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ Mediabunny is a JavaScript library for reading, writing, and converting media fi Core features include: -- **Wide format support**: Read and write MP4, MOV, WebM, MKV, WAVE, MP3, Ogg, ADTS, FLAC +- **Wide format support**: Read and write MP4, MOV, WebM, MKV, WAVE, MP3, Ogg, ADTS, FLAC, MPEG-TS - **Built-in encoding & decoding**: Supports 25+ video, audio, and subtitle codecs, hardware-accelerated using the WebCodecs API - **High precision**: Fine-grained, microsecond-accurate reading and writing operations - **Conversion API**: Easy-to-use API with features such as transmuxing, transcoding, resizing, rotation, cropping, resampling, trimming, and more diff --git a/docs/guide/input-formats.md b/docs/guide/input-formats.md index 828ce20..7a22f7e 100644 --- a/docs/guide/input-formats.md +++ b/docs/guide/input-formats.md @@ -32,6 +32,7 @@ import { OGG, // Ogg input format singleton ADTS, // ADTS input format singleton FLAC, // FLAC input format singleton + MPEG_TS, // MPEG-TS input format singleton } from 'mediabunny'; ``` @@ -80,6 +81,7 @@ In addition to singletons, input format classes are structured hierarchically: - `OggInputFormat` - `AdtsInputFormat` - `FlacInputFormat` + - `MpegTsInputFormat` This means you can also perform input format checks using `instanceof` instead of `===` comparisons. For example: ```ts diff --git a/docs/guide/introduction.md b/docs/guide/introduction.md index 20b86a5..718e1d3 100644 --- a/docs/guide/introduction.md +++ b/docs/guide/introduction.md @@ -12,7 +12,7 @@ Here's a long list of stuff this library does: - Converting media files - Hardware-accelerated decoding & encoding (via the WebCodecs API) - Support for multiple video, audio and subtitle tracks -- Read & write support for many container formats (.mp4, .mov, .webm, .mkv, .mp3, .wav, .ogg, .aac, .flac), including variations such as MP4 with Fast Start, fragmented MP4, streamable Matroska, transparent WebM, etc. +- Read & write support for many container formats (.mp4, .mov, .webm, .mkv, .mp3, .wav, .ogg, .aac, .flac, .ts), including variations such as MP4 with Fast Start, fragmented MP4, streamable Matroska, transparent WebM, etc. - Support for 25 different codecs - Lazy, optimized, on-demand file reading - Input and output streaming, arbitrary file size support diff --git a/docs/guide/output-formats.md b/docs/guide/output-formats.md index 6e125cb..a626734 100644 --- a/docs/guide/output-formats.md +++ b/docs/guide/output-formats.md @@ -289,7 +289,7 @@ type AdtsOutputFormatOptions = { This output format creates FLAC (.flac) files. ```ts -import { Output, FlacOutputFormat } from 'mediabunny'; +import { Output, FlacOutputFormat } from 'mediabunny'; const output = new Output({ format: new FlacOutputFormat(options), @@ -304,4 +304,29 @@ type FlacOutputFormatOptions = { }; ``` - `onFrame`\ - Will be called for each FLAC frame that is written. \ No newline at end of file + Will be called for each FLAC frame that is written. + +## MPEG-TS + +This output format creates MPEG Transport Stream (.ts) files. +```ts +import { Output, MpegTsOutputFormat } from 'mediabunny'; + +const output = new Output({ + format: new MpegTsOutputFormat(options), + // ... +}); +``` + +::: info +This format ensures [append-only writing](#append-only-writing). +::: + +The following options are available: +```ts +type MpegTsOutputFormatOptions = { + onPacket?: (data: Uint8Array, position: number) => unknown; +}; +``` +- `onPacket`\ + Will be called for each 188-byte Transport Stream packet that is written. \ No newline at end of file diff --git a/docs/guide/supported-formats-and-codecs.md b/docs/guide/supported-formats-and-codecs.md index 50648e8..e28fa3c 100644 --- a/docs/guide/supported-formats-and-codecs.md +++ b/docs/guide/supported-formats-and-codecs.md @@ -13,6 +13,7 @@ Mediabunny supports many commonly used media container formats, all of which are - WAVE (.wav) - ADTS (.aac) - FLAC (.flac) +- MPEG Transport Stream (.ts) ## Codecs @@ -62,33 +63,33 @@ Mediabunny ships with built-in decoders and encoders for all audio PCM codecs, m Not all codecs can be used with all containers. The following table specifies the supported codec-container combinations: -| | .mp4 | .mov | .mkv | .webm[^1] | .ogg | .mp3 | .wav | .aac | .flac | -|:--------------:|:--------:|:-----:|:-----:|:---------:|:-----:|:-----:|:-----:|:-----:|:-----:| -| `'avc'` | ✓ | ✓ | ✓ | | | | | | | -| `'hevc'` | ✓ | ✓ | ✓ | | | | | | | -| `'vp8'` | ✓ | ✓ | ✓ | ✓ | | | | | | -| `'vp9'` | ✓ | ✓ | ✓ | ✓ | | | | | | -| `'av1'` | ✓ | ✓ | ✓ | ✓ | | | | | | -| `'aac'` | ✓ | ✓ | ✓ | | | | | ✓ | | -| `'opus'` | ✓ | ✓ | ✓ | ✓ | ✓ | | | | | -| `'mp3'` | ✓ | ✓ | ✓ | | | ✓ | | | | -| `'vorbis'` | ✓ | ✓ | ✓ | ✓ | ✓ | | | | | -| `'flac'` | ✓ | ✓ | ✓ | | | | | | ✓ | -| `'pcm-u8'` | | ✓ | ✓ | | | | ✓ | | | -| `'pcm-s8'` | | ✓ | | | | | | | | -| `'pcm-s16'` | ✓ | ✓ | ✓ | | | | ✓ | | | -| `'pcm-s16be'` | ✓ | ✓ | ✓ | | | | | | | -| `'pcm-s24'` | ✓ | ✓ | ✓ | | | | ✓ | | | -| `'pcm-s24be'` | ✓ | ✓ | ✓ | | | | | | | -| `'pcm-s32'` | ✓ | ✓ | ✓ | | | | ✓ | | | -| `'pcm-s32be'` | ✓ | ✓ | ✓ | | | | | | | -| `'pcm-f32'` | ✓ | ✓ | ✓ | | | | ✓ | | | -| `'pcm-f32be'` | ✓ | ✓ | | | | | | | | -| `'pcm-f64'` | ✓ | ✓ | ✓ | | | | | | | -| `'pcm-f64be'` | ✓ | ✓ | | | | | | | | -| `'ulaw'` | | ✓ | | | | | ✓ | | | -| `'alaw'` | | ✓ | | | | | ✓ | | | -| `'webvtt'`[^2] | (✓) | | (✓) | (✓) | | | | | | +| | .mp4 | .mov | .mkv | .webm[^1] | .ogg | .mp3 | .wav | .aac | .flac | .ts | +|:--------------:|:--------:|:-----:|:-----:|:---------:|:-----:|:-----:|:-----:|:-----:|:-----:|:-----:| +| `'avc'` | ✓ | ✓ | ✓ | | | | | | | ✓ | +| `'hevc'` | ✓ | ✓ | ✓ | | | | | | | ✓ | +| `'vp8'` | ✓ | ✓ | ✓ | ✓ | | | | | | | +| `'vp9'` | ✓ | ✓ | ✓ | ✓ | | | | | | | +| `'av1'` | ✓ | ✓ | ✓ | ✓ | | | | | | | +| `'aac'` | ✓ | ✓ | ✓ | | | | | ✓ | | ✓ | +| `'opus'` | ✓ | ✓ | ✓ | ✓ | ✓ | | | | | | +| `'mp3'` | ✓ | ✓ | ✓ | | | ✓ | | | | ✓ | +| `'vorbis'` | ✓ | ✓ | ✓ | ✓ | ✓ | | | | | | +| `'flac'` | ✓ | ✓ | ✓ | | | | | | ✓ | | +| `'pcm-u8'` | | ✓ | ✓ | | | | ✓ | | | | +| `'pcm-s8'` | | ✓ | | | | | | | | | +| `'pcm-s16'` | ✓ | ✓ | ✓ | | | | ✓ | | | | +| `'pcm-s16be'` | ✓ | ✓ | ✓ | | | | | | | | +| `'pcm-s24'` | ✓ | ✓ | ✓ | | | | ✓ | | | | +| `'pcm-s24be'` | ✓ | ✓ | ✓ | | | | | | | | +| `'pcm-s32'` | ✓ | ✓ | ✓ | | | | ✓ | | | | +| `'pcm-s32be'` | ✓ | ✓ | ✓ | | | | | | | | +| `'pcm-f32'` | ✓ | ✓ | ✓ | | | | ✓ | | | | +| `'pcm-f32be'` | ✓ | ✓ | | | | | | | | | +| `'pcm-f64'` | ✓ | ✓ | ✓ | | | | | | | | +| `'pcm-f64be'` | ✓ | ✓ | | | | | | | | | +| `'ulaw'` | | ✓ | | | | | ✓ | | | | +| `'alaw'` | | ✓ | | | | | ✓ | | | | +| `'webvtt'`[^2] | (✓) | | (✓) | (✓) | | | | | | | [^1]: WebM only supports a small subset of the codecs supported by Matroska. However, this library can technically read all codecs from a WebM that are supported by Matroska.