mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-28 11:23:45 +02:00
Merge pull request #462 from Vanilagy/dts
Full DTS read/write support + @mediabunny/dts extension package
This commit is contained in:
@@ -125,6 +125,7 @@ export default withMermaid({
|
||||
{ text: 'mp3-encoder', link: '/guide/extensions/mp3-encoder' },
|
||||
{ text: 'aac-encoder', link: '/guide/extensions/aac-encoder' },
|
||||
{ text: 'ac3', link: '/guide/extensions/ac3' },
|
||||
{ text: 'dts', link: '/guide/extensions/dts' },
|
||||
{ text: 'flac-encoder', link: '/guide/extensions/flac-encoder' },
|
||||
{ text: 'prores', link: '/guide/extensions/prores' },
|
||||
],
|
||||
@@ -162,6 +163,7 @@ export default withMermaid({
|
||||
{ text: 'FLAC', link: '/codec-registry/flac' },
|
||||
{ text: 'AC-3', link: '/codec-registry/ac3' },
|
||||
{ text: 'E-AC-3', link: '/codec-registry/eac3' },
|
||||
{ text: 'DTS', link: '/codec-registry/dts' },
|
||||
{ text: 'Linear PCM', link: '/codec-registry/pcm' },
|
||||
{ text: 'μ-law PCM', link: '/codec-registry/ulaw' },
|
||||
{ text: 'A-law PCM', link: '/codec-registry/alaw' },
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
"@mediabunny/server": "Adds full video/audio decoder and encoder support to Mediabunny running in server-side environments such as Node, Bun, or Deno.",
|
||||
"@mediabunny/mp3-encoder": "Adds MP3 encoder support to Mediabunny.",
|
||||
"@mediabunny/ac3": "Adds AC-3/E-AC-3 decoder and encoder support to Mediabunny.",
|
||||
"@mediabunny/dts": "Adds DTS decoder and encoder support to Mediabunny.",
|
||||
"@mediabunny/aac-encoder": "Polyfills AAC encoder support to Mediabunny.",
|
||||
"@mediabunny/flac-encoder": "Adds FLAC encoder support to Mediabunny.",
|
||||
"@mediabunny/prores": "Adds Apple ProRes decoder support to Mediabunny."
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
---
|
||||
description: DTS audio codec definition, defining legal codec strings, decoder configs, and packet data formats.
|
||||
---
|
||||
|
||||
<script setup>
|
||||
import { VPBadge } from 'vitepress/theme'
|
||||
</script>
|
||||
|
||||
<VPBadge type="info" text="Audio codec" />
|
||||
|
||||
# DTS codec registration
|
||||
|
||||
## Description
|
||||
|
||||
The DTS audio codec (DTS Coherent Acoustics), specified in [ETSI TS 102 114](https://www.etsi.org/deliver/etsi_ts/102100_102199/102114/01.06.01_60/ts_102114v010601p.pdf).
|
||||
|
||||
## Codec ID
|
||||
|
||||
```ts
|
||||
'dts'
|
||||
```
|
||||
|
||||
## `EncodedPacket` data
|
||||
|
||||
The packet's data must be a core substream frame as defined in Section 5 of [ETSI TS 102 114](https://www.etsi.org/deliver/etsi_ts/102100_102199/102114/01.06.01_60/ts_102114v010601p.pdf), beginning with the sync word `0x7FFE8001`, followed by any number of extension substreams as defined in Section 7.4.1 of [ETSI TS 102 114](https://www.etsi.org/deliver/etsi_ts/102100_102199/102114/01.06.01_60/ts_102114v010601p.pdf), each beginning with the sync word `0x64582025`. The core substream frame may be omitted.
|
||||
|
||||
The bitstream must use 16-bit big-endian packing.
|
||||
|
||||
## `EncodedPacket` type
|
||||
|
||||
The packet's type is always `'key'`.
|
||||
|
||||
## `AudioDecoderConfig` codec string
|
||||
|
||||
The codec string must be one of the four four-character codes identifying which substreams the bitstream is built from:
|
||||
|
||||
- `'dtsc'` - a core substream only
|
||||
- `'dtsh'` - a core substream with extension substreams
|
||||
- `'dtsl'` - extension substreams carrying lossless audio, with no core substream
|
||||
- `'dtse'` - DTS Express
|
||||
|
||||
## `AudioDecoderConfig` description
|
||||
|
||||
`description` is not used for this codec.
|
||||
@@ -26,6 +26,7 @@ The registry is an extension of the [WebCodecs Codec Registry](https://www.w3.or
|
||||
- [FLAC](./flac)
|
||||
- [AC-3](./ac3)
|
||||
- [E-AC-3](./eac3)
|
||||
- [DTS](./dts)
|
||||
- [Linear PCM](./pcm)
|
||||
- [μ-law PCM](./ulaw)
|
||||
- [A-law PCM](./alaw)
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
---
|
||||
description: The @mediabunny/dts extension provides fast DTS decoders and encoders for both browser and server environments.
|
||||
---
|
||||
|
||||
# @mediabunny/dts
|
||||
|
||||
Browsers have no support for the DTS audio codec in their WebCodecs implementations. This extension package provides both a decoder and encoder for use with Mediabunny, allowing you to decode and encode this codec directly in the browser. It is implemented using Mediabunny's [custom coder API](../supported-formats-and-codecs#custom-coders) and uses a fast, size-optimized WASM build of [FFmpeg](https://ffmpeg.org/)'s DTS coders under the hood.
|
||||
|
||||
<a class="!no-underline inline-flex items-center gap-1.5" :no-icon="true" href="https://github.com/Vanilagy/mediabunny/blob/main/packages/dts/README.md">
|
||||
GitHub page
|
||||
<span class="vpi-arrow-right" />
|
||||
</a>
|
||||
|
||||
## Installation
|
||||
|
||||
This library peer-depends on Mediabunny. Install both using npm:
|
||||
```bash
|
||||
npm install mediabunny @mediabunny/dts
|
||||
```
|
||||
|
||||
Alternatively, directly include them using a script tag:
|
||||
```html
|
||||
<script src="mediabunny.js"></script>
|
||||
<script src="mediabunny-dts.js"></script>
|
||||
```
|
||||
|
||||
This will expose the global objects `Mediabunny` and `MediabunnyDts`. Use `mediabunny-dts.d.ts` to provide types for these globals. You can download the built distribution files from the [releases page](https://github.com/Vanilagy/mediabunny/releases).
|
||||
|
||||
## Usage
|
||||
|
||||
```ts
|
||||
import { registerDtsDecoder, registerDtsEncoder } from '@mediabunny/dts';
|
||||
|
||||
registerDtsDecoder();
|
||||
registerDtsEncoder();
|
||||
```
|
||||
That's it - Mediabunny now uses the registered DTS decoder and encoder automatically.
|
||||
@@ -8,7 +8,7 @@ By default, Mediabunny requires a browser environment for full access to decoder
|
||||
|
||||
Features added by this package include:
|
||||
- Video decoders and encoders for AVC (H.264), HEVC (H.265), VP8, VP9, AV1, and ProRes. Supports both length-prefixed and Annex B AVC/HEVC as well as transparent video via VP9 and ProRes.
|
||||
- Audio decoders and encoders for AAC, MP3, Vorbis, Opus, FLAC, AC-3 and E-AC-3. Supports AAC in both AAC and ADTS formats.
|
||||
- Audio decoders and encoders for AAC, MP3, Vorbis, Opus, FLAC, AC-3, E-AC-3 and DTS. Supports AAC in both AAC and ADTS formats.
|
||||
- Video frame transformation support (resize, rotate, crop)
|
||||
- Automatic hardware acceleration on all platforms (macOS, Linux, Windows)
|
||||
- Built-in multithreading
|
||||
|
||||
@@ -64,7 +64,7 @@ Mediabunny's simple yet flexible API provides a modern alternative to traditiona
|
||||
|
||||
The extension enables:
|
||||
- Video decoders and encoders for AVC (H.264), HEVC (H.265), VP8, VP9, and AV1. Supports both length-prefixed and Annex B AVC/HEVC as well as transparent video via VP9.
|
||||
- Audio decoders and encoders for AAC, MP3, Vorbis, Opus, FLAC, AC-3 and E-AC-3. Supports AAC in both AAC and ADTS formats.
|
||||
- Audio decoders and encoders for AAC, MP3, Vorbis, Opus, FLAC, AC-3, E-AC-3 and DTS. Supports AAC in both AAC and ADTS formats.
|
||||
- Video frame transformation support (resize, rotate, crop)
|
||||
- Automatic hardware acceleration on all platforms (macOS, Linux, Windows)
|
||||
- Built-in multithreading
|
||||
|
||||
@@ -51,6 +51,7 @@ Mediabunny ships with built-in decoders and encoders for all audio PCM codecs, m
|
||||
- `'flac'` - Free Lossless Audio Codec (FLAC) [^flac]
|
||||
- `'ac3'` - Dolby Digital (AC-3) [^ac3]
|
||||
- `'eac3'` - Dolby Digital Plus (E-AC-3) [^ac3]
|
||||
- `'dts'` - DTS Coherent Acoustics [^dts]
|
||||
- `'pcm-u8'` - 8-bit unsigned PCM
|
||||
- `'pcm-s8'` - 8-bit signed PCM
|
||||
- `'pcm-s16'` - 16-bit little-endian signed PCM
|
||||
@@ -89,6 +90,7 @@ Not all codecs can be used with all containers. The following table specifies th
|
||||
| `'flac'` | ✓ | ✓ | ✓ | | | | | | ✓ | |
|
||||
| `'ac3'` | ✓ | ✓ | ✓ | | | | | | | ✓ |
|
||||
| `'eac3'` | ✓ | ✓ | ✓ | | | | | | | ✓ |
|
||||
| `'dts'` | ✓ | ✓ | ✓ | | | | | | | ✓ |
|
||||
| `'pcm-u8'` | | ✓ | ✓ | | | | ✓ | | | |
|
||||
| `'pcm-s8'` | | ✓ | | | | | | | | |
|
||||
| `'pcm-s16'` | ✓ | ✓ | ✓ | | | | ✓ | | | |
|
||||
@@ -112,6 +114,7 @@ For HLS, the supported codecs depend on the segment format chosen.
|
||||
[^mp3]: MP3 encoding is not supported by WebCodecs. You can polyfill it with the [`@mediabunny/mp3-encoder`](./extensions/mp3-encoder) extension package.
|
||||
[^flac]: FLAC encoding is not supported by WebCodecs. You can polyfill it with the [`@mediabunny/flac-encoder`](./extensions/flac-encoder) extension package.
|
||||
[^ac3]: AC-3 and E-AC-3 are not natively supported by WebCodecs. To encode or decode these codecs, you can use the [`@mediabunny/ac3`](./extensions/ac3) extension package.
|
||||
[^dts]: DTS is not natively supported by WebCodecs. To encode or decode it, you can use the [`@mediabunny/dts`](./extensions/dts) extension package.
|
||||
[^webm]: 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.
|
||||
[^webvtt]: WebVTT can only be written, not read.
|
||||
|
||||
@@ -127,7 +130,7 @@ import { canEncode } from 'mediabunny';
|
||||
canEncode('avc'); // => Promise<boolean>
|
||||
canEncode('opus'); // => Promise<boolean>
|
||||
```
|
||||
Video codecs are checked using 1280x720 @1Mbps, while audio codecs are checked using 2 channels, 48 kHz @128kbps.
|
||||
Video codecs are checked using 1280x720, while audio codecs are checked using 2 channels at 48 kHz.
|
||||
|
||||
You can also check encodability using specific configurations:
|
||||
```ts
|
||||
|
||||
Reference in New Issue
Block a user