Document MPEG-TS

This commit is contained in:
Vanilagy
2026-01-16 20:51:27 +01:00
parent 53b04619e1
commit 20e4610da4
5 changed files with 59 additions and 31 deletions
+1 -1
View File
@@ -70,7 +70,7 @@ Mediabunny is a JavaScript library for reading, writing, and converting media fi
Core features include: 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 - **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 - **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 - **Conversion API**: Easy-to-use API with features such as transmuxing, transcoding, resizing, rotation, cropping, resampling, trimming, and more
+2
View File
@@ -32,6 +32,7 @@ import {
OGG, // Ogg input format singleton OGG, // Ogg input format singleton
ADTS, // ADTS input format singleton ADTS, // ADTS input format singleton
FLAC, // FLAC input format singleton FLAC, // FLAC input format singleton
MPEG_TS, // MPEG-TS input format singleton
} from 'mediabunny'; } from 'mediabunny';
``` ```
@@ -80,6 +81,7 @@ In addition to singletons, input format classes are structured hierarchically:
- `OggInputFormat` - `OggInputFormat`
- `AdtsInputFormat` - `AdtsInputFormat`
- `FlacInputFormat` - `FlacInputFormat`
- `MpegTsInputFormat`
This means you can also perform input format checks using `instanceof` instead of `===` comparisons. For example: This means you can also perform input format checks using `instanceof` instead of `===` comparisons. For example:
```ts ```ts
+1 -1
View File
@@ -12,7 +12,7 @@ Here's a long list of stuff this library does:
- Converting media files - Converting media files
- Hardware-accelerated decoding & encoding (via the WebCodecs API) - Hardware-accelerated decoding & encoding (via the WebCodecs API)
- Support for multiple video, audio and subtitle tracks - 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 - Support for 25 different codecs
- Lazy, optimized, on-demand file reading - Lazy, optimized, on-demand file reading
- Input and output streaming, arbitrary file size support - Input and output streaming, arbitrary file size support
+25
View File
@@ -305,3 +305,28 @@ type FlacOutputFormatOptions = {
``` ```
- `onFrame`\ - `onFrame`\
Will be called for each FLAC frame that is written. 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.
+28 -27
View File
@@ -13,6 +13,7 @@ Mediabunny supports many commonly used media container formats, all of which are
- WAVE (.wav) - WAVE (.wav)
- ADTS (.aac) - ADTS (.aac)
- FLAC (.flac) - FLAC (.flac)
- MPEG Transport Stream (.ts)
## Codecs ## 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: 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 | | | .mp4 | .mov | .mkv | .webm[^1] | .ogg | .mp3 | .wav | .aac | .flac | .ts |
|:--------------:|:--------:|:-----:|:-----:|:---------:|:-----:|:-----:|:-----:|:-----:|:-----:| |:--------------:|:--------:|:-----:|:-----:|:---------:|:-----:|:-----:|:-----:|:-----:|:-----:|:-----:|
| `'avc'` | ✓ | ✓ | ✓ | | | | | | | | `'avc'` | ✓ | ✓ | ✓ | | | | | | | ✓ |
| `'hevc'` | ✓ | ✓ | ✓ | | | | | | | | `'hevc'` | ✓ | ✓ | ✓ | | | | | | | ✓ |
| `'vp8'` | ✓ | ✓ | ✓ | ✓ | | | | | | | `'vp8'` | ✓ | ✓ | ✓ | ✓ | | | | | | |
| `'vp9'` | ✓ | ✓ | ✓ | ✓ | | | | | | | `'vp9'` | ✓ | ✓ | ✓ | ✓ | | | | | | |
| `'av1'` | ✓ | ✓ | ✓ | ✓ | | | | | | | `'av1'` | ✓ | ✓ | ✓ | ✓ | | | | | | |
| `'aac'` | ✓ | ✓ | ✓ | | | | | ✓ | | | `'aac'` | ✓ | ✓ | ✓ | | | | | ✓ | | ✓ |
| `'opus'` | ✓ | ✓ | ✓ | ✓ | ✓ | | | | | | `'opus'` | ✓ | ✓ | ✓ | ✓ | ✓ | | | | | |
| `'mp3'` | ✓ | ✓ | ✓ | | | ✓ | | | | | `'mp3'` | ✓ | ✓ | ✓ | | | ✓ | | | | ✓ |
| `'vorbis'` | ✓ | ✓ | ✓ | ✓ | ✓ | | | | | | `'vorbis'` | ✓ | ✓ | ✓ | ✓ | ✓ | | | | | |
| `'flac'` | ✓ | ✓ | ✓ | | | | | | ✓ | | `'flac'` | ✓ | ✓ | ✓ | | | | | | ✓ | |
| `'pcm-u8'` | | ✓ | ✓ | | | | ✓ | | | | `'pcm-u8'` | | ✓ | ✓ | | | | ✓ | | | |
| `'pcm-s8'` | | ✓ | | | | | | | | | `'pcm-s8'` | | ✓ | | | | | | | | |
| `'pcm-s16'` | ✓ | ✓ | ✓ | | | | ✓ | | | | `'pcm-s16'` | ✓ | ✓ | ✓ | | | | ✓ | | | |
| `'pcm-s16be'` | ✓ | ✓ | ✓ | | | | | | | | `'pcm-s16be'` | ✓ | ✓ | ✓ | | | | | | | |
| `'pcm-s24'` | ✓ | ✓ | ✓ | | | | ✓ | | | | `'pcm-s24'` | ✓ | ✓ | ✓ | | | | ✓ | | | |
| `'pcm-s24be'` | ✓ | ✓ | ✓ | | | | | | | | `'pcm-s24be'` | ✓ | ✓ | ✓ | | | | | | | |
| `'pcm-s32'` | ✓ | ✓ | ✓ | | | | ✓ | | | | `'pcm-s32'` | ✓ | ✓ | ✓ | | | | ✓ | | | |
| `'pcm-s32be'` | ✓ | ✓ | ✓ | | | | | | | | `'pcm-s32be'` | ✓ | ✓ | ✓ | | | | | | | |
| `'pcm-f32'` | ✓ | ✓ | ✓ | | | | ✓ | | | | `'pcm-f32'` | ✓ | ✓ | ✓ | | | | ✓ | | | |
| `'pcm-f32be'` | ✓ | ✓ | | | | | | | | | `'pcm-f32be'` | ✓ | ✓ | | | | | | | | |
| `'pcm-f64'` | ✓ | ✓ | ✓ | | | | | | | | `'pcm-f64'` | ✓ | ✓ | ✓ | | | | | | | |
| `'pcm-f64be'` | ✓ | ✓ | | | | | | | | | `'pcm-f64be'` | ✓ | ✓ | | | | | | | | |
| `'ulaw'` | | ✓ | | | | | ✓ | | | | `'ulaw'` | | ✓ | | | | | ✓ | | | |
| `'alaw'` | | ✓ | | | | | ✓ | | | | `'alaw'` | | ✓ | | | | | ✓ | | | |
| `'webvtt'`[^2] | (✓) | | (✓) | (✓) | | | | | | | `'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. [^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.