Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
bc392b4
fix(codecs): no hung flush, stale outputs or open native codecs
andreialecu Nov 24, 2026
b7e89f0
fix(android): AAC encoder keeps its last frames and times them by fra…
andreialecu Nov 24, 2026
9ec348d
fix(android): video encoder outputs every frame, and cleans up when i…
andreialecu Nov 24, 2026
0624a00
fix(android): files in the user's cache directory, decoded file:// UR…
andreialecu Nov 24, 2026
e11eef0
fix(ios): AudioEncoder starts a new timeline after flush
andreialecu Nov 24, 2026
aade4e3
test(e2e): AAC length and timestamps, a dropped video frame, file paths
andreialecu Nov 24, 2026
4c70e21
docs: casts for Mediabunny's VideoSample, AAC limits, Android pools a…
andreialecu Nov 24, 2026
1f6d403
refactor(example): the Lottie card's assets, animation and sound in o…
andreialecu Nov 24, 2026
1cfa7b3
test(e2e): the example's Lottie export and video compression, through…
andreialecu Nov 24, 2026
1cb8e30
fix(ios): VideoDecoder outputs frames in presentation order
andreialecu Nov 24, 2026
40889ab
fix(android): AudioEncoder.flush() with nothing encoded outputs nothing
andreialecu Nov 24, 2026
a2e5a2d
fix(android): ask the AAC encoder for LC through "profile" too
andreialecu Nov 24, 2026
e2fcfc0
fix(android): take FDK's AAC encoder by name, and trim its delay only
andreialecu Nov 24, 2026
41d1f21
fix(android): AudioDecoder.flush() queues no end of stream with nothi…
andreialecu Nov 24, 2026
a6e9530
test(e2e): type the AudioDecoder flush test's steps for tsc
andreialecu Nov 24, 2026
7799da4
fix(ios): AudioEncoder.flush() with nothing encoded outputs nothing
andreialecu Nov 24, 2026
f4d8ed2
fix(android): pick the video decoder by name, honouring hardwareAccel…
andreialecu Nov 24, 2026
447571a
fix(android): decoded frames have the picture's size, and the encoder…
andreialecu Nov 24, 2026
e589d16
fix(android): decoded frames report "NV12" whatever the decoder's 4:2…
andreialecu Nov 24, 2026
6eadfdb
fix(android): size the video decoder from the SPS when the config has…
andreialecu Nov 24, 2026
ff5fa41
fix(android): VideoDecoder.flush() with nothing queued queues no end …
andreialecu Nov 24, 2026
8e148c0
fix(android): the video decoder asks its surface not to drop pictures
andreialecu Nov 24, 2026
3c44cd6
fix(android): the video decoder waits for input while JS holds every …
andreialecu Nov 24, 2026
81be073
test(e2e): the held-frames test expects the decoder to wait on Androi…
andreialecu Nov 24, 2026
7eb7e10
test(e2e): close a VideoDecoder while JS holds every decoded picture
andreialecu Nov 24, 2026
b1bcbb4
test(unit): JVM tests for the encoder rules, taken out of Capabilitie…
andreialecu Nov 24, 2026
f9d823a
fix(android): the frame rate and bitrate are hints, not encoder requi…
andreialecu Nov 24, 2026
a4e4587
fix(android): the default bitrate is clamped into the encoder's range
andreialecu Nov 24, 2026
130bd20
fix(android): read encoder sizes leniently: aligned, swapped, and 108…
andreialecu Nov 24, 2026
5f0035e
fix(android): prefer a hardware encoder that takes the config over a …
andreialecu Nov 24, 2026
48b732d
docs: how Android's isConfigSupported reads sizes, frame rate and bit…
andreialecu Nov 24, 2026
d5c3738
fix(android): odd sizes are not read aligned up by isConfigSupported …
andreialecu Nov 24, 2026
ab31f00
fix(android): an encoder that takes the size as asked beats hardware …
andreialecu Nov 24, 2026
ca406dc
style(test): format the odd-size isConfigSupported test (review)
andreialecu Nov 24, 2026
18ec1b2
fix(android): set the H.264 level with the profile, and drop the prof…
andreialecu Nov 24, 2026
32b96c7
fix(android): try the next encoder when one refuses every configure, …
andreialecu Nov 24, 2026
df2c890
fix(android): encode every frame when timestamps repeat or go backwards
andreialecu Nov 24, 2026
9770b51
fix(android): put requested key frames on the frame asked for
andreialecu Nov 24, 2026
53f5119
docs(android): say the timestamps are still not respaced for rate con…
andreialecu Nov 24, 2026
7dd9e2f
fix(android): let the frames drawn come out before ending a short encode
andreialecu Nov 24, 2026
ebdfecf
fix(android): flush ends when every frame came out, with no fixed tim…
andreialecu Nov 24, 2026
915842a
fix(android): a video codec that fails is stopped, so the GL thread i…
andreialecu Nov 24, 2026
0f2519b
fix(android): VideoEncoder.close() lets go of the codec before it ret…
andreialecu Nov 24, 2026
8fd934e
test(e2e): close() a VideoEncoder whose codec hangs without failing
andreialecu Nov 24, 2026
c9d85ee
fix(android): stop a failed video codec only where no buffer is in us…
andreialecu Nov 24, 2026
053a5e5
test(unit): run the C++ host tests with clang under ASan and UBSan, i…
andreialecu Nov 24, 2026
8f1bb57
fix(android): convert odd-width and odd-height HDR frames to P010 wit…
andreialecu Nov 24, 2026
f7a808f
fix(android): bound the wait on a frame's GPU fence, and fail the fra…
andreialecu Nov 24, 2026
fdea0b0
fix(android): fail an HDR frame whose GPU fence does not signal, befo…
andreialecu Nov 24, 2026
457e24d
fix(android): refuse an RGBA16F surface pool the device cannot make C…
andreialecu Nov 24, 2026
9276b1e
fix(android): clear the encoder's window surface before drawing each …
andreialecu Nov 24, 2026
47cd026
fix(android): fall back to a window-only EGL config, and check the pb…
andreialecu Nov 24, 2026
37cfb1f
fix(android): encode() returns once a wrapped surface's frame has bee…
andreialecu Nov 24, 2026
8cda813
fix(android): encode() of a wrapped surface returns at once when its …
andreialecu Nov 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ jobs:
- name: Unit tests
run: yarn test:unit

# The Android C++ helpers that need no NDK, under ASan and UBSan.
- name: C++ host tests
run: yarn test:cpp

- name: Build the package
run: yarn build

Expand Down
15 changes: 14 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ or pick "My Mac (Designed for iPad)" in Xcode and run it from there.
## Testing

**Unit tests** (`yarn test:unit`, `src/__tests__/unit`) cover the
`WritableStream` and Mediabunny writing through it, in Node.
`WritableStream` and Mediabunny writing through it, in Node. `yarn test:jvm`
runs the JVM tests of the Android encoder rules (`EncoderRules.java`, under
`android/src/test/java`) through the example app's Gradle. `yarn test:cpp`
builds the host tests of the Android C++ helpers that need no NDK
(`android/src/test/cpp/*_test.cpp`) with clang, under AddressSanitizer and
UndefinedBehaviorSanitizer, and runs them.

**End-to-end tests** (`src/__tests__/WebCodecs.spec.ts`) run on a simulator
or emulator with the example app, and check the files with ffprobe and
Expand All @@ -50,6 +55,14 @@ ffmpeg on the host:
2. Launch the app on a simulator or emulator.
3. At the repository root, run `yarn test`.

To share the machine with other projects, start Metro on another port
(`yarn start --port 8102`) and give Metro and `yarn test` the same
`E2E_PORT` (for example `E2E_PORT=4300`, with Metro's `--reset-cache`).
The app reaches the test server on `localhost`, through `adb reverse` on
Android; where that does not work, start Metro with
`E2E_ANDROID_HOST=10.0.2.2` (the emulator's address for this machine). With
several Android devices attached, set `ANDROID_SERIAL` for `yarn test`.

They cover:

- 60 frames at 128×128 in memory: H.264, no B-frames, BT.709 tags, colors
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ const FRAME_COUNT = 7 * FRAME_RATE; // a 7 s video
const BITRATE = 8_000_000; // bits per second (8 Mbps)
const MICROSECONDS_PER_SECOND = 1_000_000; // WebCodecs times are in µs
const FRAME_DURATION = MICROSECONDS_PER_SECOND / FRAME_RATE;
// RNWebGPU is the global react-native-webgpu installs; `device` is your
// GPUDevice (navigator.gpu.requestAdapter(), then requestDevice()).

const file = createFileWritable("export.mp4"); // in the cache directory
const output = new Output({
Expand All @@ -190,11 +192,12 @@ for (let i = 0; i < FRAME_COUNT; i++) {
buffer.release();

const frame = new VideoFrame(surface, {
timestamp: i * FRAME_DURATION,
timestamp: i * FRAME_DURATION, // must grow from frame to frame
duration: FRAME_DURATION,
fence: fences[0], // the encoder waits for it natively
});
const sample = new VideoSample(frame);
// Mediabunny is typed for the DOM's VideoFrame; this one stands in for it.
const sample = new VideoSample(frame as unknown as globalThis.VideoFrame);
try {
await video.add(sample); // resolves once the encoder has room
} finally {
Expand Down
2 changes: 2 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,6 @@ repositories {
dependencies {
implementation "com.facebook.react:react-native:+"
implementation project(":react-native-nitro-modules")
// Plain JVM tests of the pure rules (EncoderRules): `yarn test:jvm`.
testImplementation "junit:junit:4.13.2"
}
Loading
Loading