@kerf-js/media-ffmpeg 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +16 -0
- package/README.md +267 -2
- package/package.json +39 -3
- package/src/build.mjs +312 -0
- package/src/index.d.ts +20 -0
- package/src/index.mjs +92 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ravonus
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
|
6
|
+
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
|
7
|
+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
8
|
+
persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
|
11
|
+
Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
|
14
|
+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
15
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
16
|
+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,268 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://github.com/Ravonus/kerf">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/Ravonus/kerf/main/site/public/logo.svg" width="88" height="88" alt="Kerf">
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
2
6
|
|
|
3
|
-
|
|
7
|
+
<h1 align="center">@kerf-js/media-ffmpeg</h1>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<strong>Video and audio for Kerf's media pipeline, encoded by an ffmpeg you install.</strong><br>
|
|
11
|
+
AV1, VP9, HEVC and H.264 video, Opus and AAC audio, behind one <code>media.encode@1</code> slot, with an optional SHA-256 pin on the binary.
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
<p align="center">
|
|
15
|
+
<a href="https://www.npmjs.com/package/@kerf-js/media-ffmpeg"><img src="https://img.shields.io/npm/v/@kerf-js/media-ffmpeg?color=145c3c&label=npm" alt="npm version"></a>
|
|
16
|
+
<a href="https://github.com/Ravonus/kerf/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-145c3c" alt="MIT license"></a>
|
|
17
|
+
<a href="https://github.com/Ravonus/kerf/actions"><img src="https://img.shields.io/github/actions/workflow/status/Ravonus/kerf/quality.yml?branch=main&label=checks" alt="checks"></a>
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
<p align="center">
|
|
21
|
+
<a href="#quick-start">Quick start</a> ·
|
|
22
|
+
<a href="https://github.com/Ravonus/kerf/tree/main/docs">Docs</a> ·
|
|
23
|
+
<a href="https://github.com/Ravonus/kerf/tree/main/examples">Examples</a> ·
|
|
24
|
+
<a href="https://github.com/Ravonus/kerf/blob/main/CHANGELOG.md">Changelog</a> ·
|
|
25
|
+
<a href="https://github.com/Ravonus/kerf">GitHub</a>
|
|
26
|
+
</p>
|
|
27
|
+
|
|
28
|
+
> [!IMPORTANT]
|
|
29
|
+
> **Early release (0.1.x).** APIs can change between minor versions. Pin the version and read the
|
|
30
|
+
> [changelog](https://github.com/Ravonus/kerf/blob/main/CHANGELOG.md) before you upgrade.
|
|
31
|
+
|
|
32
|
+
[`@kerf-js/media`](https://www.npmjs.com/package/@kerf-js/media) <sup>[source](https://github.com/Ravonus/kerf/tree/main/packages/media)</sup> handles images on its own. For
|
|
33
|
+
video, audio and animated GIFs it asks the `media.encode@1` slot, and this package fills that slot by running ffmpeg and
|
|
34
|
+
ffprobe. It decides nothing about quality or ladders; media does that. This package knows each codec's encoder
|
|
35
|
+
names, CRF range and container, and turns a recipe into an ffmpeg command line.
|
|
36
|
+
|
|
37
|
+
Kerf ships no ffmpeg. Builds with x264 or x265 are GPL, and H.264, HEVC and AAC fall under patent pools, so which binary
|
|
38
|
+
runs is the app's choice. `kerf add` prints that note when it installs this plugin.
|
|
39
|
+
|
|
40
|
+
## Highlights
|
|
41
|
+
|
|
42
|
+
- **Six codec keys.** `video/av1`, `video/vp9`, `video/hevc`, `video/h264`, `audio/opus` and `audio/aac`, each a
|
|
43
|
+
separate provider, on both the build and the server side.
|
|
44
|
+
- **Your ffmpeg, found or pinned.** `ffmpeg` and `ffprobe` from `PATH` by default; or a path, and optionally its SHA-256,
|
|
45
|
+
which is checked before the first run.
|
|
46
|
+
- **Encoder fallbacks.** AV1 uses `libsvtav1` when the binary has it, else `libaom-av1`. A key whose encoder is missing is
|
|
47
|
+
left out of the ladder with a warning, instead of failing the build.
|
|
48
|
+
- **Web-ready output.** `yuv420p` at even dimensions, MP4 with `moov` first (`+faststart`), WebM with cues first, and
|
|
49
|
+
`<source type>` codec strings (`avc1.…`, `av01.…`, `hvc1.…`) read back from the encode.
|
|
50
|
+
- **Metadata stripped.** `-map_metadata -1` and `-map_chapters -1` on every encode: phones write GPS into videos.
|
|
51
|
+
- **GIF timing kept.** Frames pass through with their own timestamps (`-fps_mode passthrough`), so a GIF's variable
|
|
52
|
+
delays survive.
|
|
53
|
+
- **A timeout per run.** 10 minutes by default, so a stuck encode doesn't hold a build forever.
|
|
54
|
+
|
|
55
|
+
## Install
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# npm
|
|
59
|
+
npm install @kerf-js/media @kerf-js/media-ffmpeg
|
|
60
|
+
|
|
61
|
+
# pnpm
|
|
62
|
+
pnpm add @kerf-js/media @kerf-js/media-ffmpeg
|
|
63
|
+
|
|
64
|
+
# bun
|
|
65
|
+
bun add @kerf-js/media @kerf-js/media-ffmpeg
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Or let the `kerf` CLI install it and add it to `kerf.config.ts` in one step:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
npx kerf add media
|
|
72
|
+
npx kerf add media-ffmpeg
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
`kerf add` writes `import { mediaFfmpeg } from '@kerf-js/media-ffmpeg'` and adds `mediaFfmpeg()` to `plugins`.
|
|
76
|
+
|
|
77
|
+
Then install ffmpeg itself, on every machine that builds and on the server if it takes uploads:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
brew install ffmpeg # macOS
|
|
81
|
+
sudo apt install ffmpeg # Debian, Ubuntu
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
It needs `ffprobe` too (both packages above include it), and the encoders you want: `libx264` for H.264 (always
|
|
85
|
+
needed for video), `libsvtav1` or `libaom-av1` for AV1, `libvpx-vp9`, `libx265`, `libopus`, and the built-in `aac`.
|
|
86
|
+
`ffmpeg -hide_banner -encoders` lists what a binary has.
|
|
87
|
+
|
|
88
|
+
## Quick start
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
// kerf.config.ts
|
|
92
|
+
import { defineConfig } from '@kerf-js/core/config'
|
|
93
|
+
import { media } from '@kerf-js/media'
|
|
94
|
+
import { mediaFfmpeg } from '@kerf-js/media-ffmpeg'
|
|
95
|
+
|
|
96
|
+
export default defineConfig({
|
|
97
|
+
plugins: [media(), mediaFfmpeg()],
|
|
98
|
+
})
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
// src/routes/launch.tsx
|
|
103
|
+
import { Media, timeline } from '@kerf-js/core/media'
|
|
104
|
+
import clip from '../../assets/launch.mp4?media'
|
|
105
|
+
|
|
106
|
+
export default function Launch() {
|
|
107
|
+
const t = timeline(clip, { cues: { intro: 0, liftoff: 12 } })
|
|
108
|
+
return (
|
|
109
|
+
<>
|
|
110
|
+
<Media
|
|
111
|
+
src={clip}
|
|
112
|
+
timeline={t}
|
|
113
|
+
alt="The rocket launch, from the countdown to orbit"
|
|
114
|
+
/>
|
|
115
|
+
<p>
|
|
116
|
+
{t.cue.value === 'liftoff' ? 'Liftoff!' : 'Counting down…'}
|
|
117
|
+
</p>
|
|
118
|
+
</>
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
The build gives `clip` an AV1 ladder (media's default `video.codecs`), an H.264 ladder for everything else, and
|
|
124
|
+
a poster. The AV1 set ships only if it is at least 15% smaller than the H.264 one.
|
|
125
|
+
|
|
126
|
+
## How it plugs into Kerf
|
|
127
|
+
|
|
128
|
+
`mediaFfmpeg()` provides one keyed slot, `media.encode@1`, once per key in `KEYS`. Each provider points at
|
|
129
|
+
`createMediaEncode` from `src/build.mjs` on the build side and from `@kerf-js/media-ffmpeg/build` on the server
|
|
130
|
+
side, with the key added to the options.
|
|
131
|
+
|
|
132
|
+
| Consumer | When it calls this |
|
|
133
|
+
| --- | --- |
|
|
134
|
+
| `@kerf-js/media`'s `media.build@1` | A `?media` import of a video, an audio file, or an animated GIF. |
|
|
135
|
+
| `@kerf-js/media`'s `media.server@1` | `ctx.media.ingest` of a video or audio upload, or an animated GIF, and the route that serves their rungs. |
|
|
136
|
+
|
|
137
|
+
The plugin's namespace is `M`. It declares permission to read media files, write temporary directories named
|
|
138
|
+
`$TMPDIR/kerf-ffmpeg-*`, and spawn `ffmpeg` and `ffprobe`. It declares no network access and no native addon.
|
|
139
|
+
|
|
140
|
+
## Options
|
|
141
|
+
|
|
142
|
+
| Option | Type | Default | What it does |
|
|
143
|
+
| --- | --- | --- | --- |
|
|
144
|
+
| `binary` | `string` | `'system'` | `'system'` runs `ffmpeg` and `ffprobe` from `PATH`. Anything else is the path of ffmpeg. |
|
|
145
|
+
| `probe` | `string` | `ffprobe` next to `binary` | The path of ffprobe, when `binary` is a path. |
|
|
146
|
+
| `sha256` | `string` (64 hex digits) | none | The binary's SHA-256. Before its first run the file is hashed, and every encode is refused unless it matches. Needs `binary`: a `PATH` lookup has no single file to pin. |
|
|
147
|
+
| `timeout` | `number` (ms) | `600000` (10 minutes) | How long one ffmpeg run may take. |
|
|
148
|
+
|
|
149
|
+
Options are validated when the config loads: an unknown key, a `sha256` that isn't 64 hex digits, a `sha256` with
|
|
150
|
+
`binary: 'system'`, or a non-positive `timeout` is **P115**.
|
|
151
|
+
|
|
152
|
+
## What each key encodes
|
|
153
|
+
|
|
154
|
+
The knob is a CRF: lower is better quality. media searches between the minimum and maximum when a scorer is
|
|
155
|
+
available, and uses the fixed value otherwise.
|
|
156
|
+
|
|
157
|
+
| Key | Encoder (first found) | CRF min · max · fixed | Container | Audio with it | Extra arguments |
|
|
158
|
+
| --- | --- | --- | --- | --- | --- |
|
|
159
|
+
| `video/av1` | `libsvtav1`, `libaom-av1` | 20 · 58 · 35 | WebM | Opus 96k | `-preset 6`; aom: `-cpu-used 6 -row-mt 1 -b:v 0` |
|
|
160
|
+
| `video/vp9` | `libvpx-vp9` | 20 · 50 · 33 | WebM | Opus 96k | `-b:v 0 -row-mt 1 -cpu-used 2 -deadline good` |
|
|
161
|
+
| `video/hevc` | `libx265` | 16 · 36 · 26 | MP4 | AAC 128k | `-preset medium -tag:v hvc1` |
|
|
162
|
+
| `video/h264` | `libx264` | 16 · 34 · 23 | MP4 | AAC 128k | `-preset medium -profile:v high` |
|
|
163
|
+
| `audio/opus` | `libopus` | (bitrate 96k) | WebM | | |
|
|
164
|
+
| `audio/aac` | `aac` | (bitrate 128k) | M4A (MP4) | | |
|
|
165
|
+
|
|
166
|
+
Video is scaled with Lanczos to the rung's width (height rounded to even) and converted to `yuv420p`. A `copy` recipe
|
|
167
|
+
remuxes without re-encoding, which media uses for an H.264 source already at its top width and for audio already
|
|
168
|
+
under its bitrate.
|
|
169
|
+
|
|
170
|
+
## API reference
|
|
171
|
+
|
|
172
|
+
| Export | Entry | What it is |
|
|
173
|
+
| --- | --- | --- |
|
|
174
|
+
| `mediaFfmpeg(options?)` | `@kerf-js/media-ffmpeg` | The plugin for `kerf.config.ts`. Typed by `MediaFfmpegOptions`. |
|
|
175
|
+
| `MediaFfmpegOptions` | `@kerf-js/media-ffmpeg` (type) | The options above. |
|
|
176
|
+
| `KEYS` | `@kerf-js/media-ffmpeg` | The six `media.encode` keys, in the order above. |
|
|
177
|
+
| `createMediaEncode({ key, binary?, probe?, sha256?, timeout? })` | `@kerf-js/media-ffmpeg/build` | One codec's provider. Throws for a key it has no recipe for. |
|
|
178
|
+
|
|
179
|
+
<details>
|
|
180
|
+
<summary>What <code>createMediaEncode()</code> returns</summary>
|
|
181
|
+
|
|
182
|
+
| Member | What it does |
|
|
183
|
+
| --- | --- |
|
|
184
|
+
| `key` | The codec key. |
|
|
185
|
+
| `knob` | `{ min, max, fixed, higherIsBetter: false }` for the CRF. |
|
|
186
|
+
| `ext` | `webm`, `mp4` or `m4a`. |
|
|
187
|
+
| `encoderName()` | The encoder this binary would use, or `null` when it was built without one. Asks `ffmpeg -encoders` once per process. |
|
|
188
|
+
| `versions()` | `{ ffmpeg, encoder }`: the first line of `ffmpeg -version` and the encoder. media puts it in its cache key, so a new ffmpeg means new output. |
|
|
189
|
+
| `info(file)` | ffprobe's view: `format`, `duration`, `video` (`codec`, `pix`, `width`/`height` after rotation, `fps`, `frames`, `string`, `hdr`) and `audio` (`codec`, `channels`, `bitrate`, `string`). |
|
|
190
|
+
| `still(file, { at?, width? })` | One frame as PNG bytes, for posters and the quality search. |
|
|
191
|
+
| `encode(file, { knob?, width?, copy?, audio?, loopVideo? })` | Encoded bytes. `audio` is a file to mux in, or `false` to drop the source's own. `loopVideo` loops the input for the length of that audio. |
|
|
192
|
+
|
|
193
|
+
</details>
|
|
194
|
+
|
|
195
|
+
## Recipes
|
|
196
|
+
|
|
197
|
+
**A pinned binary in CI**
|
|
198
|
+
|
|
199
|
+
```ts
|
|
200
|
+
mediaFfmpeg({
|
|
201
|
+
binary: '/opt/ffmpeg/bin/ffmpeg',
|
|
202
|
+
sha256: process.env.FFMPEG_SHA256,
|
|
203
|
+
})
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
`sha256` must be 64 lowercase hex digits; `shasum -a 256 /opt/ffmpeg/bin/ffmpeg` gives it. `probe` defaults to
|
|
207
|
+
`/opt/ffmpeg/bin/ffprobe`.
|
|
208
|
+
|
|
209
|
+
**More codecs, and a longer limit for long videos**
|
|
210
|
+
|
|
211
|
+
```ts
|
|
212
|
+
plugins: [
|
|
213
|
+
media({ video: { codecs: ['av1', 'vp9', 'hevc'] } }),
|
|
214
|
+
mediaFfmpeg({ timeout: 30 * 60 * 1000 }),
|
|
215
|
+
]
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
**A sound under a looping GIF**
|
|
219
|
+
|
|
220
|
+
```tsx
|
|
221
|
+
import loop from './loop.gif?media&audio=./beat.opus'
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## Limits
|
|
225
|
+
|
|
226
|
+
- ffmpeg is not bundled and not downloaded. Every machine that builds media, and the server if it takes video or audio
|
|
227
|
+
uploads, needs its own.
|
|
228
|
+
- `video/h264` is required for any video: it is the compatible copy, so a binary without `libx264` can't build video.
|
|
229
|
+
Other missing encoders only drop that codec (an M019 warning).
|
|
230
|
+
- HDR and over-8-bit sources come out 8-bit SDR (media reports M015).
|
|
231
|
+
- Inputs are read with `-protocol_whitelist file,pipe`: no network sources.
|
|
232
|
+
- Audio bitrates are fixed: Opus 96 kbps, AAC-LC 128 kbps.
|
|
233
|
+
|
|
234
|
+
## Troubleshooting
|
|
235
|
+
|
|
236
|
+
| Message | Cause and fix |
|
|
237
|
+
| --- | --- |
|
|
238
|
+
| `M019 ffmpeg didn't run. Install ffmpeg …` | ffmpeg isn't on `PATH`, or `binary` points at nothing. Install it, or pass its path. |
|
|
239
|
+
| `M019 … has no libx264 encoder for video/h264` | The binary was built without that encoder. Use a build that has it. |
|
|
240
|
+
| `M019 … is not the pinned binary: sha256 …` | The file at `binary` changed. The message prints the actual hash. |
|
|
241
|
+
| `M019 No encoder for video/av1: it is left out of the ladder.` | A warning: the codec is skipped and the rest ships. |
|
|
242
|
+
| `video/h264: ffmpeg failed: …` | ffmpeg exited with an error; the last three lines of its stderr follow. |
|
|
243
|
+
| `P101 … needs media.encode` | Reported by media when this plugin isn't in `plugins`. |
|
|
244
|
+
|
|
245
|
+
## Related packages
|
|
246
|
+
|
|
247
|
+
| Package | What it is |
|
|
248
|
+
| --- | --- |
|
|
249
|
+
| [`@kerf-js/media`](https://www.npmjs.com/package/@kerf-js/media) | The media pipeline that uses this: ladders, quality search, uploads, M-codes. |
|
|
250
|
+
| [`@kerf-js/core`](https://www.npmjs.com/package/@kerf-js/core) | `<Media>` and `timeline()` from `@kerf-js/core/media`. |
|
|
251
|
+
| [`@kerf-js/start`](https://www.npmjs.com/package/@kerf-js/start) | `ctx.media.ingest` for uploads. |
|
|
252
|
+
| [`@kerf-js/cli`](https://www.npmjs.com/package/@kerf-js/cli) | `kerf add media-ffmpeg` and `kerf docs M019`. |
|
|
253
|
+
|
|
254
|
+
## Contributing
|
|
255
|
+
|
|
256
|
+
See [CONTRIBUTING.md](https://github.com/Ravonus/kerf/blob/main/CONTRIBUTING.md). From the repository root:
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
pnpm --filter @kerf-js/media-ffmpeg test
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
The tests that run the binary skip where ffmpeg isn't on `PATH`. media's `test/video.test.ts` covers real
|
|
263
|
+
encodes through this package.
|
|
264
|
+
|
|
265
|
+
## License
|
|
266
|
+
|
|
267
|
+
[MIT](https://github.com/Ravonus/kerf/blob/main/LICENSE). ffmpeg itself is not part of this package and carries its own
|
|
268
|
+
licence (LGPL or GPL, depending on how it was built).
|
package/package.json
CHANGED
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kerf-js/media-ffmpeg",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "@kerf-js/media-ffmpeg: the media.encode@1 provider for video and audio (AV1, VP9, HEVC, H.264, Opus, AAC) through an ffmpeg you install",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/Ravonus/kerf.git",
|
|
9
|
+
"directory": "packages/media-ffmpeg"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/Ravonus/kerf/tree/main/packages/media-ffmpeg#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/Ravonus/kerf/issues"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./src/index.d.ts",
|
|
19
|
+
"default": "./src/index.mjs"
|
|
20
|
+
},
|
|
21
|
+
"./build": "./src/build.mjs"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"@kerf-js/core": "^0.1.0"
|
|
25
|
+
},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=24"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"kerf"
|
|
31
|
+
],
|
|
32
|
+
"files": [
|
|
33
|
+
"src",
|
|
34
|
+
"plugin.mjs",
|
|
35
|
+
"plugin.d.mts",
|
|
36
|
+
"README.md",
|
|
37
|
+
"LICENSE"
|
|
38
|
+
],
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
}
|
|
6
42
|
}
|
package/src/build.mjs
ADDED
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
// Video: yuv420p, even dimensions, frames passed through with their own timestamps, so a GIF's delays survive.
|
|
2
|
+
// Audio: Opus at 96 kbps, AAC-LC at 128 kbps; never dropped unless the recipe says so.
|
|
3
|
+
// Metadata is stripped (phones write GPS into videos), and MP4 gets `moov` first and WebM its cues first.
|
|
4
|
+
import { execFile } from 'node:child_process'
|
|
5
|
+
import { createHash } from 'node:crypto'
|
|
6
|
+
import { mkdtempSync, readFileSync, rmSync } from 'node:fs'
|
|
7
|
+
import { tmpdir } from 'node:os'
|
|
8
|
+
import { dirname, join } from 'node:path'
|
|
9
|
+
import { promisify } from 'node:util'
|
|
10
|
+
|
|
11
|
+
const exec = promisify(execFile)
|
|
12
|
+
const MP4 = ['-movflags', '+faststart', '-f', 'mp4']
|
|
13
|
+
const WEBM = ['-cues_to_front', '1', '-f', 'webm']
|
|
14
|
+
const OPUS = ['-c:a', 'libopus', '-b:a', '96k']
|
|
15
|
+
const AAC = ['-c:a', 'aac', '-b:a', '128k']
|
|
16
|
+
|
|
17
|
+
/** Encoder names in the order they're tried, the knob's range (a CRF: lower is better) and what goes with the video. */
|
|
18
|
+
const CODECS = {
|
|
19
|
+
'video/av1': {
|
|
20
|
+
names: ['libsvtav1', 'libaom-av1'],
|
|
21
|
+
min: 20,
|
|
22
|
+
max: 58,
|
|
23
|
+
fixed: 35,
|
|
24
|
+
ext: 'webm',
|
|
25
|
+
mux: WEBM,
|
|
26
|
+
audio: OPUS,
|
|
27
|
+
args: {
|
|
28
|
+
libsvtav1: ['-preset', '6'],
|
|
29
|
+
'libaom-av1': ['-cpu-used', '6', '-row-mt', '1', '-b:v', '0'],
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
'video/vp9': {
|
|
33
|
+
names: ['libvpx-vp9'],
|
|
34
|
+
min: 20,
|
|
35
|
+
max: 50,
|
|
36
|
+
fixed: 33,
|
|
37
|
+
ext: 'webm',
|
|
38
|
+
mux: WEBM,
|
|
39
|
+
audio: OPUS,
|
|
40
|
+
args: { 'libvpx-vp9': ['-b:v', '0', '-row-mt', '1', '-cpu-used', '2', '-deadline', 'good'] },
|
|
41
|
+
},
|
|
42
|
+
'video/hevc': {
|
|
43
|
+
names: ['libx265'],
|
|
44
|
+
min: 16,
|
|
45
|
+
max: 36,
|
|
46
|
+
fixed: 26,
|
|
47
|
+
ext: 'mp4',
|
|
48
|
+
mux: MP4,
|
|
49
|
+
audio: AAC,
|
|
50
|
+
args: { libx265: ['-preset', 'medium', '-tag:v', 'hvc1', '-x265-params', 'log-level=error'] },
|
|
51
|
+
},
|
|
52
|
+
'video/h264': {
|
|
53
|
+
names: ['libx264'],
|
|
54
|
+
min: 16,
|
|
55
|
+
max: 34,
|
|
56
|
+
fixed: 23,
|
|
57
|
+
ext: 'mp4',
|
|
58
|
+
mux: MP4,
|
|
59
|
+
audio: AAC,
|
|
60
|
+
args: { libx264: ['-preset', 'medium', '-profile:v', 'high'] },
|
|
61
|
+
},
|
|
62
|
+
'audio/opus': { names: ['libopus'], ext: 'webm', mux: WEBM, audio: OPUS },
|
|
63
|
+
'audio/aac': { names: ['aac'], ext: 'm4a', mux: MP4, audio: AAC },
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const missing = (bin) =>
|
|
67
|
+
Object.assign(
|
|
68
|
+
new Error(
|
|
69
|
+
`M019 ${bin} didn't run. Install ffmpeg (brew install ffmpeg, apt install ffmpeg), or give mediaFfmpeg({ binary }) its path.`,
|
|
70
|
+
),
|
|
71
|
+
{ code: 'M019' },
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
const names = new Map()
|
|
75
|
+
/** What this binary can encode: asked once per process. */
|
|
76
|
+
function encodersOf(bin) {
|
|
77
|
+
if (!names.has(bin))
|
|
78
|
+
names.set(
|
|
79
|
+
bin,
|
|
80
|
+
exec(bin, ['-hide_banner', '-encoders'], { maxBuffer: 1 << 22 }).then(
|
|
81
|
+
(r) => new Set(r.stdout.split('\n').map((l) => l.trim().split(/\s+/)[1])),
|
|
82
|
+
() => {
|
|
83
|
+
throw missing(bin)
|
|
84
|
+
},
|
|
85
|
+
),
|
|
86
|
+
)
|
|
87
|
+
return names.get(bin)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function fraction(text) {
|
|
91
|
+
const [a, b = 1] = String(text).split('/').map(Number)
|
|
92
|
+
return b ? a / b : 0
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const AVC = { Baseline: '42c0', 'Constrained Baseline': '42c0', Main: '4d40', High: '6400' }
|
|
96
|
+
/** The `codecs` parameter for `<source type>`, from what ffprobe says the encode is. */
|
|
97
|
+
function codecString(s) {
|
|
98
|
+
if (s.codec_name === 'h264')
|
|
99
|
+
return `avc1.${AVC[s.profile] ?? '6400'}${Number(s.level).toString(16).padStart(2, '0')}`
|
|
100
|
+
if (s.codec_name === 'av1') return `av01.0.${String(Math.max(s.level, 0)).padStart(2, '0')}M.08`
|
|
101
|
+
if (s.codec_name === 'hevc') return `hvc1.1.6.L${s.level}.B0`
|
|
102
|
+
if (s.codec_name === 'vp9') return 'vp9'
|
|
103
|
+
if (s.codec_name === 'aac') return 'mp4a.40.2'
|
|
104
|
+
return s.codec_name
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function createInfo({ run, ffprobe }) {
|
|
108
|
+
return async function info(file) {
|
|
109
|
+
const { stdout } = await run(ffprobe, [
|
|
110
|
+
'-v',
|
|
111
|
+
'error',
|
|
112
|
+
'-protocol_whitelist',
|
|
113
|
+
'file,pipe',
|
|
114
|
+
'-show_format',
|
|
115
|
+
'-show_streams',
|
|
116
|
+
'-of',
|
|
117
|
+
'json',
|
|
118
|
+
file,
|
|
119
|
+
])
|
|
120
|
+
const { streams = [], format = {} } = JSON.parse(String(stdout))
|
|
121
|
+
const v = streams.find((s) => s.codec_type === 'video' && !s.disposition?.attached_pic)
|
|
122
|
+
const a = streams.find((s) => s.codec_type === 'audio')
|
|
123
|
+
const side = v?.side_data_list?.find((d) => d.rotation !== undefined)?.rotation ?? 0
|
|
124
|
+
const turned = Math.abs(side) % 180 === 90
|
|
125
|
+
return {
|
|
126
|
+
format: format.format_name,
|
|
127
|
+
duration: Number(format.duration) || 0,
|
|
128
|
+
video: v && {
|
|
129
|
+
codec: v.codec_name,
|
|
130
|
+
pix: v.pix_fmt,
|
|
131
|
+
width: turned ? v.height : v.width,
|
|
132
|
+
height: turned ? v.width : v.height,
|
|
133
|
+
fps: fraction(v.avg_frame_rate),
|
|
134
|
+
frames: Number(v.nb_read_frames ?? v.nb_frames) || undefined,
|
|
135
|
+
string: codecString(v),
|
|
136
|
+
hdr:
|
|
137
|
+
['smpte2084', 'arib-std-b67'].includes(v.color_transfer) ||
|
|
138
|
+
/1[02]le$/.test(v.pix_fmt ?? ''),
|
|
139
|
+
},
|
|
140
|
+
audio: a && {
|
|
141
|
+
codec: a.codec_name,
|
|
142
|
+
channels: a.channels,
|
|
143
|
+
bitrate: Number(a.bit_rate) || undefined,
|
|
144
|
+
string: codecString(a),
|
|
145
|
+
},
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function createEncode({ encoderName, ffmpeg, spec, key, output, input, scale }) {
|
|
151
|
+
return async function encode(file, { knob, width, copy, audio, loopVideo } = {}) {
|
|
152
|
+
const name = await encoderName()
|
|
153
|
+
if (!name)
|
|
154
|
+
throw Object.assign(
|
|
155
|
+
new Error(`M019 ${ffmpeg} has no ${spec.names.join(' or ')} encoder for ${key}.`),
|
|
156
|
+
{ code: 'M019' },
|
|
157
|
+
)
|
|
158
|
+
const common = ['-map_metadata', '-1', '-map_chapters', '-1']
|
|
159
|
+
if (key.startsWith('audio/'))
|
|
160
|
+
return output(spec.ext, [
|
|
161
|
+
...input(file),
|
|
162
|
+
...common,
|
|
163
|
+
'-map',
|
|
164
|
+
'0:a:0',
|
|
165
|
+
'-vn',
|
|
166
|
+
...(copy ? ['-c:a', 'copy'] : spec.audio),
|
|
167
|
+
...spec.mux,
|
|
168
|
+
])
|
|
169
|
+
// `-shortest` overruns on a looping GIF by what the encoder has buffered, so the sound's length is set outright.
|
|
170
|
+
const tracks =
|
|
171
|
+
typeof audio === 'string'
|
|
172
|
+
? [
|
|
173
|
+
...input(file, loopVideo),
|
|
174
|
+
...input(audio),
|
|
175
|
+
'-map',
|
|
176
|
+
'0:v:0',
|
|
177
|
+
'-map',
|
|
178
|
+
'1:a:0',
|
|
179
|
+
'-t',
|
|
180
|
+
String((await this.info(audio)).duration),
|
|
181
|
+
...spec.audio,
|
|
182
|
+
]
|
|
183
|
+
: [
|
|
184
|
+
...input(file),
|
|
185
|
+
'-map',
|
|
186
|
+
'0:v:0',
|
|
187
|
+
...(audio === false
|
|
188
|
+
? []
|
|
189
|
+
: ['-map', '0:a:0?', ...(copy ? ['-c:a', 'copy'] : spec.audio)]),
|
|
190
|
+
]
|
|
191
|
+
const video = copy
|
|
192
|
+
? ['-c:v', 'copy']
|
|
193
|
+
: [
|
|
194
|
+
'-vf',
|
|
195
|
+
scale(width),
|
|
196
|
+
'-fps_mode',
|
|
197
|
+
'passthrough',
|
|
198
|
+
'-c:v',
|
|
199
|
+
name,
|
|
200
|
+
'-crf',
|
|
201
|
+
String(knob ?? spec.fixed),
|
|
202
|
+
...spec.args[name],
|
|
203
|
+
]
|
|
204
|
+
return output(spec.ext, [...tracks, ...common, ...video, ...spec.mux])
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function createRunner({ ffmpeg, sha256, key, timeout }) {
|
|
209
|
+
let pinned = !sha256
|
|
210
|
+
|
|
211
|
+
async function run(bin, args) {
|
|
212
|
+
if (!pinned) {
|
|
213
|
+
const actual = createHash('sha256').update(readFileSync(ffmpeg)).digest('hex')
|
|
214
|
+
if (actual !== sha256)
|
|
215
|
+
throw Object.assign(
|
|
216
|
+
new Error(`M019 ${ffmpeg} is not the pinned binary: sha256 ${actual}.`),
|
|
217
|
+
{ code: 'M019' },
|
|
218
|
+
)
|
|
219
|
+
pinned = true
|
|
220
|
+
}
|
|
221
|
+
return exec(bin, args, { timeout, maxBuffer: 1 << 26, encoding: 'buffer' }).catch((error) => {
|
|
222
|
+
if (error.code === 'ENOENT') throw missing(bin)
|
|
223
|
+
throw new Error(
|
|
224
|
+
`${key}: ${bin} failed: ${String(error.stderr ?? error.message)
|
|
225
|
+
.trim()
|
|
226
|
+
.split('\n')
|
|
227
|
+
.slice(-3)
|
|
228
|
+
.join(' ')}`,
|
|
229
|
+
)
|
|
230
|
+
})
|
|
231
|
+
}
|
|
232
|
+
return run
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function createOutput(ffmpeg, run) {
|
|
236
|
+
async function output(ext, args) {
|
|
237
|
+
const dir = mkdtempSync(join(tmpdir(), 'kerf-ffmpeg-'))
|
|
238
|
+
try {
|
|
239
|
+
const file = join(dir, `out.${ext}`)
|
|
240
|
+
await run(ffmpeg, ['-hide_banner', '-loglevel', 'error', '-nostdin', '-y', ...args, file])
|
|
241
|
+
return new Uint8Array(readFileSync(file))
|
|
242
|
+
} finally {
|
|
243
|
+
rmSync(dir, { recursive: true, force: true })
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return output
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/** The media.encode@1 provider for one codec key: `encode` runs ffmpeg on a file and a recipe, and gives the bytes back. */
|
|
250
|
+
export function createMediaEncode({ key, binary = 'system', probe, sha256, timeout = 600_000 }) {
|
|
251
|
+
const spec = CODECS[key]
|
|
252
|
+
if (!spec) throw new Error(`media.encode: no ffmpeg recipe for ${key}`)
|
|
253
|
+
const ffmpeg = binary === 'system' ? 'ffmpeg' : binary
|
|
254
|
+
const ffprobe = probe ?? (binary === 'system' ? 'ffprobe' : join(dirname(binary), 'ffprobe'))
|
|
255
|
+
const run = createRunner({ ffmpeg, sha256, key, timeout })
|
|
256
|
+
|
|
257
|
+
/** ffmpeg writing one temporary file, which comes back as bytes. */
|
|
258
|
+
const output = createOutput(ffmpeg, run)
|
|
259
|
+
|
|
260
|
+
const input = (file, loop) => [
|
|
261
|
+
'-protocol_whitelist',
|
|
262
|
+
'file,pipe',
|
|
263
|
+
...(loop ? ['-ignore_loop', '0'] : []),
|
|
264
|
+
'-i',
|
|
265
|
+
file,
|
|
266
|
+
]
|
|
267
|
+
|
|
268
|
+
const scale = (width) =>
|
|
269
|
+
`scale=${width ? `${width}:-2` : 'trunc(iw/2)*2:trunc(ih/2)*2'}:flags=lanczos,format=yuv420p`
|
|
270
|
+
|
|
271
|
+
async function encoderName() {
|
|
272
|
+
const have = await encodersOf(ffmpeg)
|
|
273
|
+
return spec.names.find((n) => have.has(n)) ?? null
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return {
|
|
277
|
+
key,
|
|
278
|
+
/** Lowest and highest knob, and the setting used with no quality search. Lower is better. */
|
|
279
|
+
knob: { min: spec.min, max: spec.max, fixed: spec.fixed, higherIsBetter: false },
|
|
280
|
+
ext: spec.ext,
|
|
281
|
+
/** The encoder this binary would use, or null when it wasn't built with one. */
|
|
282
|
+
encoderName,
|
|
283
|
+
/** Goes into the cache key. */
|
|
284
|
+
versions: async () => ({
|
|
285
|
+
ffmpeg: String((await run(ffmpeg, ['-version'])).stdout).split('\n')[0],
|
|
286
|
+
encoder: await encoderName(),
|
|
287
|
+
}),
|
|
288
|
+
|
|
289
|
+
/** What a file is, from ffprobe. */
|
|
290
|
+
info: createInfo({ run, ffprobe }),
|
|
291
|
+
|
|
292
|
+
/** One frame as a PNG, for the poster and the quality search. */
|
|
293
|
+
still: (file, { at = 0, width } = {}) =>
|
|
294
|
+
output('png', [
|
|
295
|
+
'-ss',
|
|
296
|
+
String(at),
|
|
297
|
+
...input(file),
|
|
298
|
+
'-map',
|
|
299
|
+
'0:v:0',
|
|
300
|
+
'-frames:v',
|
|
301
|
+
'1',
|
|
302
|
+
...(width ? ['-vf', `scale=${width}:-2:flags=lanczos`] : []),
|
|
303
|
+
]),
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* @param {string} file
|
|
307
|
+
* @param {{ knob?: number, width?: number, copy?: boolean, audio?: string | false, loopVideo?: boolean }} recipe
|
|
308
|
+
* `copy`: remux without re-encoding. `audio`: a file to mux in, or false to drop the source's own.
|
|
309
|
+
*/
|
|
310
|
+
encode: createEncode({ encoderName, ffmpeg, spec, key, output, input, scale }),
|
|
311
|
+
}
|
|
312
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { PluginInstance } from '@kerf-js/core/plugin'
|
|
2
|
+
|
|
3
|
+
/** Options of `mediaFfmpeg()`: which ffmpeg to run, and how far to trust it. */
|
|
4
|
+
export interface MediaFfmpegOptions {
|
|
5
|
+
/** 'system' (the default) runs `ffmpeg` and `ffprobe` from PATH; otherwise the path of ffmpeg. */
|
|
6
|
+
binary?: string
|
|
7
|
+
/** The path of ffprobe, when `binary` is a path. Default: `ffprobe` next to it. */
|
|
8
|
+
probe?: string
|
|
9
|
+
/** SHA-256 of `binary`: an encode is refused unless the file matches. */
|
|
10
|
+
sha256?: string
|
|
11
|
+
/** Milliseconds one ffmpeg run may take. Default 10 minutes. */
|
|
12
|
+
timeout?: number
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** The media.encode@1 keys this plugin provides, one per codec. */
|
|
16
|
+
export declare const KEYS: string[]
|
|
17
|
+
/** The plugin for `kerf.config.ts`: encodes video and audio with ffmpeg for `@kerf-js/media`. */
|
|
18
|
+
export declare function mediaFfmpeg(
|
|
19
|
+
options?: MediaFfmpegOptions,
|
|
20
|
+
): PluginInstance<MediaFfmpegOptions>
|
package/src/index.mjs
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// mediaFfmpeg() for kerf.config.ts: provides media.encode@1 for the video and audio keys. It runs an
|
|
2
|
+
// ffmpeg you installed, or the one `binary` names (with `sha256`, refused unless the file matches). kerf ships no ffmpeg:
|
|
3
|
+
// builds with x264/x265 are GPL, and H.264, HEVC and AAC fall under patent pools, so that choice stays with the app.
|
|
4
|
+
import { fileURLToPath } from 'node:url'
|
|
5
|
+
import { definePlugin, defineSlot, provide } from '@kerf-js/core/plugin'
|
|
6
|
+
|
|
7
|
+
const mediaEncode = defineSlot({
|
|
8
|
+
id: 'media.encode',
|
|
9
|
+
version: 1,
|
|
10
|
+
cardinality: 'keyed',
|
|
11
|
+
sides: ['build', 'server'],
|
|
12
|
+
})
|
|
13
|
+
export const KEYS = [
|
|
14
|
+
'video/av1',
|
|
15
|
+
'video/vp9',
|
|
16
|
+
'video/hevc',
|
|
17
|
+
'video/h264',
|
|
18
|
+
'audio/opus',
|
|
19
|
+
'audio/aac',
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
const fail = (path, message) => {
|
|
23
|
+
throw Object.assign(new Error(message), { path })
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function options(input) {
|
|
27
|
+
for (const key of Object.keys(input))
|
|
28
|
+
if (!['binary', 'probe', 'sha256', 'timeout'].includes(key)) fail(key, 'unknown option')
|
|
29
|
+
const { binary = 'system', probe, sha256, timeout = 600_000 } = input
|
|
30
|
+
if (typeof binary !== 'string') fail('binary', "'system' for the ffmpeg on PATH, or a path")
|
|
31
|
+
if (probe !== undefined && typeof probe !== 'string') fail('probe', 'the path of ffprobe')
|
|
32
|
+
if (sha256 !== undefined && !/^[0-9a-f]{64}$/.test(sha256))
|
|
33
|
+
fail('sha256', 'the 64 hex digits of the binary')
|
|
34
|
+
if (sha256 && binary === 'system')
|
|
35
|
+
fail('sha256', 'needs `binary`: a PATH lookup has no one file to pin')
|
|
36
|
+
if (!(Number.isInteger(timeout) && timeout > 0)) fail('timeout', 'milliseconds per encode')
|
|
37
|
+
return { binary, ...(probe && { probe }), ...(sha256 && { sha256 }), timeout }
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const mediaFfmpeg = definePlugin({
|
|
41
|
+
name: '@kerf-js/media-ffmpeg',
|
|
42
|
+
version: '0.1.0',
|
|
43
|
+
kerf: '*',
|
|
44
|
+
namespace: 'M',
|
|
45
|
+
options,
|
|
46
|
+
permissions: {
|
|
47
|
+
fs: {
|
|
48
|
+
read: ['**/*.{gif,mp4,m4v,mov,webm,mkv,ogv,mp3,wav,flac,ogg,oga,opus,m4a,aac}'],
|
|
49
|
+
write: ['$TMPDIR/kerf-ffmpeg-*'],
|
|
50
|
+
},
|
|
51
|
+
spawn: ['ffmpeg', 'ffprobe'],
|
|
52
|
+
},
|
|
53
|
+
contribute: (o) => ({
|
|
54
|
+
provides: KEYS.map((key) =>
|
|
55
|
+
provide(mediaEncode, {
|
|
56
|
+
key,
|
|
57
|
+
sides: {
|
|
58
|
+
build: {
|
|
59
|
+
module: fileURLToPath(new URL('./build.mjs', import.meta.url)),
|
|
60
|
+
export: 'createMediaEncode',
|
|
61
|
+
options: { ...o, key },
|
|
62
|
+
},
|
|
63
|
+
server: {
|
|
64
|
+
module: '@kerf-js/media-ffmpeg/build',
|
|
65
|
+
export: 'createMediaEncode',
|
|
66
|
+
options: { ...o, key },
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
}),
|
|
70
|
+
),
|
|
71
|
+
agents: {
|
|
72
|
+
title: 'Video and audio (@kerf-js/media-ffmpeg)',
|
|
73
|
+
text: [
|
|
74
|
+
'- GIFs, videos and audio files are `?media` imports rendered with `<Media>`. Never hand-write `<video>` or `<source>`.',
|
|
75
|
+
'- Sync code to them with `timeline(asset, { cues })` from `@kerf-js/core/media` and `<Media timeline={t}>`, not `timeupdate` listeners.',
|
|
76
|
+
'- `./loop.gif?media&audio=./beat.opus` muxes the audio into the video at build.',
|
|
77
|
+
].join('\n'),
|
|
78
|
+
},
|
|
79
|
+
catalog: [
|
|
80
|
+
{
|
|
81
|
+
name: 'timeline',
|
|
82
|
+
import: '@kerf-js/core/media',
|
|
83
|
+
summary:
|
|
84
|
+
'timeline(asset, { cues }): currentTime and playing as boxes, cues on presented frames',
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
notes: [
|
|
88
|
+
'ffmpeg is not installed by kerf. Builds with x264/x265 are GPL; distributing one can bind what you ship with it.',
|
|
89
|
+
'H.264, HEVC and AAC encoders fall under patent pools (Via LA, Access Advance). AV1, VP9 and Opus are royalty-free.',
|
|
90
|
+
],
|
|
91
|
+
}),
|
|
92
|
+
})
|