munim-ffmpeg 0.3.1 → 0.4.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/README.md +18 -7
- package/package.json +1 -1
- package/scripts/binaries.json +1 -1
package/README.md
CHANGED
|
@@ -153,13 +153,16 @@ Every release runs the example's 24-check device suite. For 0.3.x:
|
|
|
153
153
|
|
|
154
154
|
An Android emulator has no working MediaCodec **encoder**. `h264_mediacodec` and `hevc_mediacodec` report success and produce a file containing no frames, so anything downstream of an encode fails. Everything else — audio encoding, filters, FFprobe, muxing, cancellation, protocols — works normally there.
|
|
155
155
|
|
|
156
|
-
This is an emulator limitation, not a package one, but it is worth knowing before debugging: **test video encoding on a physical device**.
|
|
156
|
+
This is an emulator limitation, not a package one, but it is worth knowing before debugging: **test video encoding on a physical device**.
|
|
157
|
+
|
|
158
|
+
`pickEncoder` cannot detect it, because MediaCodec *is* present in an emulator — it just does not work. When you need encoding to succeed regardless of environment, ask for the software encoder by name:
|
|
157
159
|
|
|
158
160
|
```typescript
|
|
159
|
-
|
|
161
|
+
// Deterministic anywhere: emulators, CI, older devices.
|
|
162
|
+
await execute(['-y', '-i', input, '-c:v', 'libopenh264', '-pix_fmt', 'yuv420p', output])
|
|
160
163
|
```
|
|
161
164
|
|
|
162
|
-
`mpeg4` and `libvpx-vp9` are software encoders and work everywhere.
|
|
165
|
+
`libopenh264`, `mpeg4` and `libvpx-vp9` are all software encoders and work everywhere.
|
|
163
166
|
|
|
164
167
|
## Bundled FFmpeg builds
|
|
165
168
|
|
|
@@ -173,7 +176,7 @@ Both platforms run **FFmpeg 9.0.1**, built from [ffmpeg.org](https://www.ffmpeg.
|
|
|
173
176
|
| TLS | SecureTransport | mbedTLS |
|
|
174
177
|
| Minimum | iOS 15.1 | API 24, 16 KB pages |
|
|
175
178
|
|
|
176
|
-
Linked libraries, identical on both: **LAME** (MP3), **Opus**, **libvpx** (VP8/VP9), **dav1d** (AV1 decoding), plus everything FFmpeg builds natively.
|
|
179
|
+
Linked libraries, identical on both: **LAME** (MP3), **Opus**, **libvpx** (VP8/VP9), **dav1d** (AV1 decoding), **openh264** (software H.264), plus everything FFmpeg builds natively.
|
|
177
180
|
|
|
178
181
|
FFmpeg's own `ffmpeg` and `ffprobe` tools are compiled to run inside your app process, so the argument arrays you pass are handled by the real command-line code paths rather than a reimplementation.
|
|
179
182
|
|
|
@@ -181,20 +184,26 @@ FFmpeg's own `ffmpeg` and `ffprobe` tools are compiled to run inside your app pr
|
|
|
181
184
|
|
|
182
185
|
Verified by running the example's device suite: iOS reports 186 encoders, Android 184. Everything FFmpeg builds natively (`aac`, `alac`, `flac`, `mpeg4`, `mjpeg`, `png`, `gif`, `pcm_*`, …) is on both, as are `libmp3lame`, `libopus`, `libvpx`, and `libvpx-vp9`.
|
|
183
186
|
|
|
184
|
-
H.264 and HEVC come from the platform's hardware encoder, which is faster and
|
|
187
|
+
H.264 and HEVC come from the platform's hardware encoder, which is faster and uses less power than a software encoder. `libopenh264` is there as a software H.264 fallback for anywhere hardware encoding is unavailable — an emulator, for instance:
|
|
185
188
|
|
|
186
189
|
| Encoder | iOS | Android |
|
|
187
190
|
| --- | --- | --- |
|
|
188
191
|
| `h264_videotoolbox`, `hevc_videotoolbox`, `prores_videotoolbox` | ✅ | ❌ |
|
|
189
192
|
| `h264_mediacodec`, `hevc_mediacodec`, `vp8_mediacodec`, `vp9_mediacodec` | ❌ | ✅ |
|
|
190
193
|
| `aac_at`, `alac_at` (AudioToolbox) | ✅ | ❌ |
|
|
194
|
+
| `libopenh264` (H.264, software) | ✅ | ✅ |
|
|
191
195
|
|
|
192
196
|
Resolve the name at runtime instead of branching on `Platform.OS`:
|
|
193
197
|
|
|
194
198
|
```typescript
|
|
195
199
|
import { execute, pickEncoder } from 'munim-ffmpeg'
|
|
196
200
|
|
|
197
|
-
|
|
201
|
+
// Hardware first, software as the fallback.
|
|
202
|
+
const h264 = await pickEncoder([
|
|
203
|
+
'h264_videotoolbox',
|
|
204
|
+
'h264_mediacodec',
|
|
205
|
+
'libopenh264',
|
|
206
|
+
])
|
|
198
207
|
if (!h264) throw new Error('No H.264 encoder in this build')
|
|
199
208
|
|
|
200
209
|
await execute(['-y', '-i', inputPath, '-c:v', h264, outputPath])
|
|
@@ -622,7 +631,9 @@ if (result.success) {
|
|
|
622
631
|
|
|
623
632
|
The JavaScript, TypeScript, Swift, Kotlin, C core, and generated Nitro bridge in this repository are Apache-2.0.
|
|
624
633
|
|
|
625
|
-
The bundled FFmpeg 9.0.1 is **LGPLv3**, on both platforms. It is configured without `--enable-gpl`, so no x264, x265, xvid, or vid.stab
|
|
634
|
+
The bundled FFmpeg 9.0.1 is **LGPLv3**, on both platforms. It is configured without `--enable-gpl`, so no x264, x265, xvid, or vid.stab. The external libraries it links are LAME (LGPL), Opus (BSD), libvpx (BSD), dav1d (BSD), openh264 (BSD 2-clause), and mbedTLS (Apache-2.0) on Android.
|
|
635
|
+
|
|
636
|
+
> **A note on H.264 patents.** Hardware encoders are covered by the licences device manufacturers already pay for. Software H.264 encoding through `libopenh264` is not: Cisco's royalty coverage applies to *their* prebuilt binary, and this package builds openh264 from source. If you ship software H.264 encoding at scale, check where you stand with AVC licensing. Hardware encoders avoid the question entirely, which is why `pickEncoder` should list them first.
|
|
626
637
|
|
|
627
638
|
In practice that means your application does **not** inherit GPL obligations. LGPL still applies: the FFmpeg libraries are linked and their license and notices must be conveyed with your app, and users must be able to relink against a modified FFmpeg. The exact configuration used is recorded in [`scripts/ffmpeg/build-ios.sh`](./scripts/ffmpeg/build-ios.sh) and [`build-android.sh`](./scripts/ffmpeg/build-android.sh), and the binaries can be reproduced from them.
|
|
628
639
|
|
package/package.json
CHANGED
package/scripts/binaries.json
CHANGED