Implement ADTS muxer :3

This commit is contained in:
Ally
2025-08-17 16:14:15 +02:00
parent 0cb466ebb1
commit 1ce5e108a7
8 changed files with 262 additions and 31 deletions
+1 -1
View File
@@ -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), including variations such as MP4 with Fast Start, fragmented MP4, or streamable Matroska
- Read & write support for many container formats (.mp4, .mov, .webm, .mkv, .mp3, .wav, .ogg, .aac), including variations such as MP4 with Fast Start, fragmented MP4, or streamable Matroska
- Support for 25 different codecs
- Lazy, optimized, on-demand file reading
- Input and output streaming, arbitrary file size support
+22 -1
View File
@@ -244,4 +244,25 @@ type WavOutputFormatOptions = {
- `large`\
When enabled, an RF64 file be written, allowing for file sizes to exceed 4 GiB, which is otherwise not possible for regular WAVE files.
- `onHeader`\
Will be called once the file header is written. The header consists of the RIFF header, the format chunk, and the start of the data chunk (with a placeholder size of 0).
Will be called once the file header is written. The header consists of the RIFF header, the format chunk, and the start of the data chunk (with a placeholder size of 0).
## ADTS
This output format creates ADTS (.aac) files.
```ts
import { Output, AdtsOutputFormat } from 'mediabunny';
const output = new Output({
format: new AdtsOutputFormat(options),
// ...
});
```
The following options are available:
```ts
type AdtsOutputFormatOptions = {
onFrame?: (data: Uint8Array, position: number) => unknown;
};
```
- `onFrame`\
Will be called for each ADTS frame that is written.
+28 -27
View File
@@ -11,6 +11,7 @@ Mediabunny supports many commonly used media container formats, all of which are
- Ogg (.ogg)
- MP3 (.mp3)
- WAVE (.wav)
- ADTS (.aac)
## Codecs
@@ -60,33 +61,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 |
|:--------------:|:--------:|:-----:|:-----:|:---------:|:-----:|:-----:|:-----:|
| `'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 |
|:--------------:|:--------:|:-----:|:-----:|:---------:|:-----:|:-----:|:-----:|:-----:|
| `'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.