mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-10-03 13:53:53 +02:00
Begin work on documentation
This commit is contained in:
@@ -2,3 +2,4 @@
|
|||||||
/build
|
/build
|
||||||
/dist
|
/dist
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
/docs/.vitepress/cache
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
import { defineConfig } from 'vitepress';
|
||||||
|
import footnote from 'markdown-it-footnote';
|
||||||
|
|
||||||
|
// https://vitepress.dev/reference/site-config
|
||||||
|
export default defineConfig({
|
||||||
|
title: 'Mediakit',
|
||||||
|
description: 'A VitePress Site',
|
||||||
|
cleanUrls: true,
|
||||||
|
themeConfig: {
|
||||||
|
// https://vitepress.dev/reference/default-theme-config
|
||||||
|
nav: [
|
||||||
|
{ text: 'Home', link: '/' },
|
||||||
|
{ text: 'Guide', link: '/guide/introduction' },
|
||||||
|
],
|
||||||
|
|
||||||
|
sidebar: [
|
||||||
|
{
|
||||||
|
text: 'Getting started',
|
||||||
|
items: [
|
||||||
|
{ text: 'Introduction', link: '/guide/introduction' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Reading media files',
|
||||||
|
items: [
|
||||||
|
{ text: 'Reading basics', link: '/guide/reading' },
|
||||||
|
{ text: 'Media sinks', link: '/guide/media-sinks' },
|
||||||
|
{ text: 'Input formats', link: '/guide/input-formats' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Writing media files',
|
||||||
|
items: [
|
||||||
|
{ text: 'Writing basics', link: '/guide/writing' },
|
||||||
|
{ text: 'Media sources', link: '/guide/media-sources' },
|
||||||
|
{ text: 'Output formats', link: '/guide/output-formats' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Miscellaneous',
|
||||||
|
items: [
|
||||||
|
{ text: 'Supported formats & codecs', link: 'guide/supported-formats-and-codecs' },
|
||||||
|
{ text: 'Custom coders', link: 'guide/custom-coders' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
socialLinks: [
|
||||||
|
{ icon: 'github', link: 'https://github.com/vuejs/vitepress' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
markdown: {
|
||||||
|
config(md) {
|
||||||
|
md.use(footnote);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
# Introduction
|
||||||
|
|
||||||
|
Install Mediakit using your favorite package manager:
|
||||||
|
|
||||||
|
::: code-group
|
||||||
|
```bash [npm]
|
||||||
|
npm install mediakit
|
||||||
|
```
|
||||||
|
```bash [yarn]
|
||||||
|
yarn add mediakit
|
||||||
|
```
|
||||||
|
```bash [pnpm]
|
||||||
|
pnpm add mediakit
|
||||||
|
```
|
||||||
|
```bash [bun]
|
||||||
|
bun add mediakit
|
||||||
|
```
|
||||||
|
:::
|
||||||
|
|
||||||
|
Both ESM and CommonJS are supported:
|
||||||
|
```ts
|
||||||
|
import * as Mediakit from 'mediakit';
|
||||||
|
const Mediakit = require('mediakit');
|
||||||
|
```
|
||||||
|
|
||||||
|
Alternativly, you can simply include the library using a script tag in your HTML:
|
||||||
|
```html
|
||||||
|
<script src="path/to/mediakit.js"></script>
|
||||||
|
```
|
||||||
|
|
||||||
|
You can download the built distribution file from the [releases page](https://github.com/Vanilagy/mp4-muxer/releases).
|
||||||
@@ -0,0 +1,146 @@
|
|||||||
|
# Supported formats & codecs
|
||||||
|
|
||||||
|
Mediakit supports many container formats and media codecs.
|
||||||
|
|
||||||
|
## Container formats
|
||||||
|
|
||||||
|
Mediakit supports many commonly used media container formats, all of which are supported bidirectionally (reading & writing):
|
||||||
|
|
||||||
|
- ISOBMFF-based formats (.mp4, .m4v, .m4a, ...)
|
||||||
|
- QuickTime File Format (.mov)
|
||||||
|
- Matroska (.mkv)
|
||||||
|
- WebM (.webm)
|
||||||
|
- Ogg (.ogg)
|
||||||
|
- MP3 (.mp3)
|
||||||
|
- WAVE (.wav)
|
||||||
|
|
||||||
|
## Codecs
|
||||||
|
|
||||||
|
Mediakit supports a wide range of video, audio and subtitle codecs. More specifically, it supports all codecs specified by the WebCodecs API and a few additional PCM codecs out of the box.
|
||||||
|
|
||||||
|
The availability of the codecs provided by the WebCodecs API depends on the browser and cannot be guaranteed by this library. Mediakit provides [special utility functions](#querying-codec-encodability) to check which codecs are able to encoded. You can also specify [custom coders](./custom-coders) to provide your own encoder/decoder implementation if the browser doesn't support the codec natively.
|
||||||
|
|
||||||
|
### Video codecs
|
||||||
|
|
||||||
|
- `'avc'` - Advanced Video Coding (AVC) / H.264
|
||||||
|
- `'hevc'` - High Efficiency Video Coding (HEVC) / H.265
|
||||||
|
- `'vp8'` - VP8
|
||||||
|
- `'vp9'` - VP9
|
||||||
|
- `'av1'` - AOMedia Video 1 (AV1)
|
||||||
|
|
||||||
|
### Audio codecs
|
||||||
|
|
||||||
|
- `'aac'` - Advanced Audio Coding (AAC)
|
||||||
|
- `'opus'` - Opus
|
||||||
|
- `'mp3'` - MP3
|
||||||
|
- `'vorbis'` - Vorbis
|
||||||
|
- `'flac'` - Free Lossless Audio Codec (FLAC)
|
||||||
|
- `'pcm-u8'` - 8-bit unsigned PCM
|
||||||
|
- `'pcm-s8'` - 8-bit signed PCM
|
||||||
|
- `'pcm-s16'` - 16-bit little-endian signed PCM
|
||||||
|
- `'pcm-s16be'` - 16-bit big-endian signed PCM
|
||||||
|
- `'pcm-s24'` - 24-bit little-endian signed PCM
|
||||||
|
- `'pcm-s24be'` - 24-bit big-endian signed PCM
|
||||||
|
- `'pcm-s32'` - 32-bit little-endian signed PCM
|
||||||
|
- `'pcm-s32be'` - 32-bit big-endian signed PCM
|
||||||
|
- `'pcm-f32'` - 32-bit little-endian float PCM
|
||||||
|
- `'pcm-f32be'` - 32-bit big-endian float PCM
|
||||||
|
- `'ulaw'` - μ-law PCM
|
||||||
|
- `'alaw'` - A-law PCM
|
||||||
|
|
||||||
|
### Subtitle codecs
|
||||||
|
|
||||||
|
- `'webvtt'` - WebVTT
|
||||||
|
|
||||||
|
## Compatibility table
|
||||||
|
|
||||||
|
Not all codecs can be used with all containers. The following table specifies the supported codec-container combinations:
|
||||||
|
|
||||||
|
| | .mp4[^1] | .mov | .mkv | .webm[^2] | .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'` | | ✓ | | | | | |
|
||||||
|
| `'ulaw'` | | ✓ | | | | | ✓ |
|
||||||
|
| `'alaw'` | | ✓ | | | | | ✓ |
|
||||||
|
| `'webvtt'`[^3] | (✓) | | (✓) | (✓) | | | |
|
||||||
|
|
||||||
|
|
||||||
|
[^1]: PCM audio codecs are not supported by MP4. If somebody were to include PCM audio in an MP4 anyway, this library would still be able to read it.
|
||||||
|
[^2]: 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.
|
||||||
|
[^3]: WebVTT can only be written, not read.
|
||||||
|
|
||||||
|
## Querying codec encodability
|
||||||
|
|
||||||
|
Mediakit provides utility functions that you can use to check if the browser can encode a given codec. Additionally, you
|
||||||
|
can check if a codec is encodable with a specific _configuration_.
|
||||||
|
|
||||||
|
`canEncode` is a general-purpose function that can be called with all codecs and tests encodability using commonly used configurations:
|
||||||
|
```ts
|
||||||
|
import { canEncode } from 'mediakit';
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
You can also check encodability using specific configurations:
|
||||||
|
```ts
|
||||||
|
import { canEncodeVideo, canEncodeAudio } from 'mediakit';
|
||||||
|
|
||||||
|
canEncodeVideo('hevc', {
|
||||||
|
width: 1920, height: 1080, bitrate: 1e7
|
||||||
|
}); // => Promise<boolean>
|
||||||
|
|
||||||
|
canEncodeAudio('aac', {
|
||||||
|
numberOfChannels: 1, sampleRate: 44100, bitrate: 192e3
|
||||||
|
}); // => Promise<boolean>
|
||||||
|
```
|
||||||
|
|
||||||
|
In addition, you can use the following functions which check encodability for multiple codecs at once and return a list of
|
||||||
|
supported codecs:
|
||||||
|
```ts
|
||||||
|
import {
|
||||||
|
getEncodableCodecs,
|
||||||
|
getEncodableVideoCodecs,
|
||||||
|
getEncodableAudioCodecs,
|
||||||
|
getEncodableSubtitleCodecs,
|
||||||
|
} from 'mediakit';
|
||||||
|
|
||||||
|
getEncodableCodecs(); // Promise<MediaCodec[]>
|
||||||
|
getEncodableVideoCodecs(); // Promise<VideoCodec[]>
|
||||||
|
getEncodableAudioCodecs(); // Promise<AudioCodec[]>
|
||||||
|
getEncodableSubtitleCodecs(); // Promise<SubtitleCodec[]>
|
||||||
|
```
|
||||||
|
|
||||||
|
These functions also accept optional configuration options:
|
||||||
|
```ts
|
||||||
|
import { getEncodableVideoCodecs } from 'mediakit';
|
||||||
|
|
||||||
|
// Checks only which of AVC, HEVC and VP8 can be encoded at 1280x720 @10Mbps:
|
||||||
|
getEncodableVideoCodecs(
|
||||||
|
['avc', 'hevc', 'vp8'],
|
||||||
|
{ width: 1920, height: 1080, bitrate: 1e7 },
|
||||||
|
); // => Promise<VideoCodec[]>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Querying codec decodability
|
||||||
|
|
||||||
|
TODO link to input track
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
---
|
||||||
|
# https://vitepress.dev/reference/default-theme-home-page
|
||||||
|
layout: home
|
||||||
|
|
||||||
|
hero:
|
||||||
|
name: "My Awesome Project"
|
||||||
|
text: "A VitePress Site"
|
||||||
|
tagline: My great project tagline
|
||||||
|
actions:
|
||||||
|
- theme: brand
|
||||||
|
text: Markdown Examples
|
||||||
|
link: /markdown-examples
|
||||||
|
- theme: alt
|
||||||
|
text: API Examples
|
||||||
|
link: /api-examples
|
||||||
|
|
||||||
|
features:
|
||||||
|
- title: Feature A
|
||||||
|
details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
|
||||||
|
- title: Feature B
|
||||||
|
details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
|
||||||
|
- title: Feature C
|
||||||
|
details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
|
||||||
|
---
|
||||||
|
|
||||||
|
things the guide needs to cover:
|
||||||
|
- writing files
|
||||||
|
- output usage
|
||||||
|
- all output formats
|
||||||
|
- all media sources
|
||||||
|
- reading files
|
||||||
|
- input usage
|
||||||
|
- all input formats
|
||||||
|
- all media sinks
|
||||||
|
- utility functions
|
||||||
|
- supported containers / codecs
|
||||||
|
- samples & packets
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"extends": "../tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"moduleResolution": "nodenext",
|
||||||
|
"module": "NodeNext"
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
".vitepress/config.mts"
|
||||||
|
]
|
||||||
|
}
|
||||||
Generated
+2413
-1
File diff suppressed because it is too large
Load Diff
+8
-2
@@ -22,7 +22,10 @@
|
|||||||
"watch": "node build.mjs --watch",
|
"watch": "node build.mjs --watch",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"check": "tsc -p src --noEmit && tsc -p scripts --noEmit",
|
"check": "tsc -p src --noEmit && tsc -p scripts --noEmit",
|
||||||
"check-docblocks": "ts-node scripts/check-docblocks dist/metamuxer.d.ts"
|
"check-docblocks": "ts-node scripts/check-docblocks dist/metamuxer.d.ts",
|
||||||
|
"docs:dev": "vitepress dev docs",
|
||||||
|
"docs:build": "vitepress build docs",
|
||||||
|
"docs:preview": "vitepress preview docs"
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@@ -34,11 +37,14 @@
|
|||||||
"@eslint/js": "^9.22.0",
|
"@eslint/js": "^9.22.0",
|
||||||
"@microsoft/api-extractor": "^7.52.1",
|
"@microsoft/api-extractor": "^7.52.1",
|
||||||
"@stylistic/eslint-plugin": "^4.2.0",
|
"@stylistic/eslint-plugin": "^4.2.0",
|
||||||
|
"@types/markdown-it-footnote": "^3.0.4",
|
||||||
"@types/node": "^22.13.10",
|
"@types/node": "^22.13.10",
|
||||||
"esbuild": "^0.25.1",
|
"esbuild": "^0.25.1",
|
||||||
"eslint": "^9.22.0",
|
"eslint": "^9.22.0",
|
||||||
|
"markdown-it-footnote": "^4.0.0",
|
||||||
"ts-node": "^10.9.2",
|
"ts-node": "^10.9.2",
|
||||||
"typescript": "^5.8.2",
|
"typescript": "^5.8.2",
|
||||||
"typescript-eslint": "^8.26.1"
|
"typescript-eslint": "^8.26.1",
|
||||||
|
"vitepress": "^1.6.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user