You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Moves Pulse's native video work from react-native-video-trim (RNVT) to our own engine, pulse-editor (@mieweb/pulse-editor): a Nitro module on AVFoundation (iOS) and Media3 (Android), with no FFmpeg. It goes one method at a time: each method is switched over in the app and tested on both phones. conform and thumbnail are switched over and tested on both phones (2026-10-07, re-run on both 2026-10-13), macOS, the Android emulator and the iOS Simulator. <PulsePreview>, the player the timeline editor is built on, shows the export's frames on both phones and meets its speed targets on the iPhone; on the S24 first frame, edits and playback meet theirs, drags run on a plain player (about 31 seeks landed/s), and paused seeks and the start after a seek miss theirs, accepted as Media3 limits (2026-10-14). Since 2026-10-14 every trim is whole frames and every clip length a whole ms on both platforms (pulse-editor #12), so the preview lands on the export's frame everywhere but in 2× clips. RNVT's editor (showEditor) is now the only part of the fork the app still uses. Main (app 2.2.4) is merged in, and the draft data layer the timeline editor writes through is in place. This PR stays open until every RNVT call is replaced; its last commit removes RNVT and FFmpeg, then it merges.
Part of #242 (why, plan and status). Squashes #239 (submodules). Relates to #241 (recorder bitrate).
Status
✅ done · ⏳ left to do · 📋 not started. Devices: iPhone 17 Pro Max (iOS) and Galaxy S24 Ultra, Android 16 (Android), and since 2026-10-13 also a Pixel 6a, Android 17 beta; "macOS" = the same iOS code run on a Mac against references; "emulator" = Android 17 emulator.
✅ iPhone: 3-clip join (90 ms), trims, muted clip, 2- and 8-min drafts (0.66 s, 2.4–5.2 s); macOS: audio matches the original within 0.1 ms · iPhone (2026-10-14, pulse-editor #12): every trim whole source frames, every clip length a whole ms; lip sync ±0.1 ms (2× −25.0), 0 decode errors
✅ S24: 3-clip join (0.65 s, exact length), trims, muted clip; emulator: same fixtures · Pixel 6a (2026-10-14, pulse-editor #12, the join cut to the same window): lip sync 0.0 ms (2× −17.5), 0 decode errors; the trimmed join 16–21 ms shorter than asked on the two phones (nearest-frame ends)
merge: cancel
(not possible in RNVT)
✅ iPhone: cancel mid-merge; macOS: no files left behind
✅ S24: settles 6–36 ms after the abort, no files left; emulator
✅ S24: mixed draft (20 clips: HEVC, 60 fps, 4K, landscape) in 17.2–17.9 s and wild-imports draft (12 clips, HLG and PQ HDR included) in 13.8–14.1 s, exact lengths; emulator: 5.1 mixed draft
merge: RNVT fallback removed
the FFmpeg merge
✅ in code: the app merges with pulse-editor only, and an error shows the retry state (tsc, lint, tests; not run on a device since)
✅ same
5
extractAudio → Whisper captions
extractAudio
✅ iPhone: captions (extract 80–180 ms, VAD 128 ms, Whisper 123 ms); macOS: PCM vs FFmpeg reference within 0.1 ms; local whisper.cpp 1.9.3 gives the same transcripts
✅ S24: captions (extract 0.4–0.8 s, Whisper 1.5 s on CPU); emulator: length and speech onset exact vs FFmpeg; local whisper.cpp gives the same transcripts
Cleanups from the whisper.rn audit (VAD comment, real CPU fallback)
✅ from whisper.rn 0.7.4's source, not run: the Whisper fallback now asks for the CPU (it only runs if the GPU context fails to load)
✅ comments only (whisper.rn has no Android GPU backend)
6
conform: import normalization, HDR
compress, cancelCompress
✅ iPhone (2026-10-07): 42 inputs (fixtures + the real-recording corpus) all to contract, no decode errors, lip sync 0.0–0.1 ms, cancel settled in 377 ms; HDR tone-mapped (the same levels as RNVT within 1); 1080p 5–7× realtime; faster than RNVT on 33 of 38 · iPhone Release (2026-10-13): 38 converted + 3 already matching, the same 7 HDR level flags, lip sync 0.0 / 0.1 ms, cancel settled in 753 ms · macOS: 51 of 51
✅ S24 (2026-10-07): 38 of 38 converted incl. HLG / PQ / Dolby Vision, lip sync 0.0 ms, cancel settled in 15 ms, 1080p 4–7× realtime; RNVT's full conform fails on the phone by its own bug · S24 (2026-10-13, full corpus + the merged frame rule): 34 converted, 7 passed through (the recording, and 6 clips that differ only in audio layout: Android's import policy), the corrupt source rejected (746 of 3430 frames), every clean source keeps every frame, HDR levels −10…−65 (the tone map), lip sync 0.0 ms, cancel settled in 5–12 ms · emulator: every 8-bit input
7
thumbnail
getFrameAt
✅ iPhone (2026-10-07): 37 of 37 covers, at or above RNVT's match to FFmpeg on every one (RNVT fails past the end and a < 1 s clip, wrong frames on 2); 22–50 ms per cover, 10–20 ms slower than RNVT · iPhone Release (2026-10-13): 37 of 37, the same match; 37–849 ms per cover (both engines 2.3× slower than 2026-10-07: the phone that day) · macOS + Simulator
✅ S24 (2026-10-07): 37 of 37 covers, the better match on most (RNVT fails the < 1 s clip, ignores a mirror) · S24 (2026-10-13, the merged warm extractor): median 15 ms per call; later covers of a file 10–40 ms (were 160–600 each), a file's first 144–516 ms; pictures unchanged · emulator
8
<PulsePreview>: composition player
(needed by the editor)
✅ iPhone (2026-10-07 Debug; 2026-10-13 Release, and Debug on pulse-editor main): seeks show the export's frame 79 of 80, 77 of 80 and 40 of 40 (the misses: the export's sped-up-clip quirk), p90 56–64 ms, first frame 54–122 ms, edits on screen in 41–148 ms all showing the edit, 48–62 pictures/s while dragging, 30 fps, warm plays start in 0–1 ms. A play with sound on a cold audio output (≥ 5 s idle, or the first) starts 160 ms ahead so its first sound isn't cut (traces; pulse-editor #7, by ear next) · 20 and 40 clips (2026-10-13): first frame 76–83 ms, edits 60–77 ms, 30 fps · whole-frame trims (2026-10-14, Debug): seeks on the export's frame join / trims / edits / mute 20 / 20 / 19 / 20 of 20, 20 clips 26–27 of 30, 40 clips 38 of 38, trims + edits 16 of 20 (was 13), odd-length join 20 of 20; every miss in a 2× clip
✅ S24 (2026-10-13, with the drag layer, pulse-editor #10): seeks show the export's frame 80 of 80, edits 8 of 8 (165–354 ms), first frame 85–192 ms, 28.7–29.2 fps none dropped; while dragging about 31 seeks land per second (the composition alone 0.5, 9–13 pictures/s), a drag into another clip shows it in 63–162 ms, the drag picture matched the composition's in 16 of 16 checked pairs, settle 120–189 ms; accepted as Media3 limits (2026-10-14): paused seek p90 199–294 ms over the 2026-10-13 runs (202–281 in this one; the composition) and play 120–239 ms after a paused seek (120–154 in this one); pulse-editor #13 (playback frame rate) waits for an S24 run · Pixel 6a (2026-10-13, the four drafts and 20 / 40 clips): first frame 125–516 ms, edits 163–361 ms all showing the edit, 27–31 seeks landed/s while dragging, 19–24 fps none dropped · Pixel 6a (2026-10-14, whole-frame trims, Debug): seeks on the export's frame 20 of 20 on each of the four drafts (trims was 13 with whole frames but fractional-ms lengths), 20 clips 30 of 30 (was 28), 40 clips 38 of 38 (was 30), trims + edits 17 of 20 (the 3 in the 2× clip), odd-length join 20 of 20 · emulator: 60 of 60 in six runs · Accepted (Media3 CompositionPlayer, tried 2026-10-13): paused seek p90 200–340 ms, play ~150 ms after a paused seek
9
Timeline editor UI (React Native), replacing the clip preview and the per-clip editor
showEditor
⏳ iPhone (2026-10-14, Debug, by hand): opens from the recorder on the tapped clip; play, scrub, select, edits, undo, reorder and trims used on the phone; an edit keeps the playhead's time (pulse-editor #18, from the time log). The old preview and RNVT's editor are removed (d7e235d)
⏳ Pixel 6a (2026-10-14, Debug): open, play/pause, scrub, select and deselect, rotate, flip, speed, crop presets, trims (incl. press-pause-drag), undo/redo, reorder in Clips (then also from a timeline hold, since removed), the dragged clip above the screen, background pause, the view remembered
10
File helpers to expo-file-system
deleteFile, cleanFiles, saveToDocuments
✅ deleteFile → File.delete; cleanFiles → an expo-file-system sweep of RNVT's trimmedVideo* files (Simulator: removed them, kept other files); "Save to Files" button dropped, Share's sheet has it on iOS
✅ same code; sweep not yet run on Android
11
Last commit: remove the fork and FFmpeg (package, Podfile, Gradle, submodule), then merge
the fork
📋
📋
Done so far
Native modules as git submodules under modules/
The modules:pulse-editor, removed from package.json and the lockfile; Expo autolinks it from ./modules. react-native-video-trim was autolinked the same way until it was removed with its FFmpeg (d7e235d).
Resolution: Metro resolves each import to the module's TypeScript src/ (no build step) and blocks modules/*/node_modules and example/, so there's one react-native. TypeScript paths match.
CI: build workflows fetch the submodules (iOS after prepare-expo-env). Prettier ignores modules/.
Why not a file: dependency: it installed the fork's devDependencies, putting a second react-native where Metro finds it.
Updating a module: commit in the submodule, then the pointer here. Fresh clones need --recurse-submodules.
probe (replaces FFprobe)
Engines: AVFoundation's async loaders on iOS (about 2 ms per clip); the Media3 Inspector on Android.
Android fixes (emulator, 171 files): iPhone Dolby Vision video reads as hevc (its base layer, via Media3's getAlternativeCodecMimeType) instead of dolby-vision, and video.durationMs is the video track's own length (Media3's MediaExtractorCompat), not the container's. Every field now matches the iOS probe on the same 171 files (147 iPhone videos: Dolby Vision HLG, 4K60/120, screen recordings, messaging-app files; plus the dev samples), except fps on 6 synthetic samples (29.83–30.0, all round to 30). The extra parse costs time on the emulator: median 5 → 9 ms per probe.
Mirror: both platforms read it from the track matrix (negative determinant). On the emulator, 5 ffmpeg-tagged files (plain, rotated, hflip, rotated + hflip, vflip) read the same as AVFoundation on macOS.
Import rules read bitDepth and transfer. The recorder format moves to recorder.format.v2; since conform landed, decideImport hands pulse-editor its clockwise rotation directly.
Contract:merge(clips, options, { onProgress, signal }).
No RNVT fallback: the app merges with pulse-editor only. A merge error shows the export screen's retry state instead of falling through to RNVT's FFmpeg merge.
Clips carry their edit as typed fields: trim, speed, mute, clockwise rotation, flip, crop.
Options carry the canvas (1080×1920 at 30 fps), the bitrate (5 Mbps) and the recorder's audio layout.
Aborting signal cancels; leaving the export screen or changing clips aborts it.
iOS paths:
Join: when clips share one H.264/AAC format that fits and is at most 1.6× the bitrate, and none has a rendered edit. AVMutableComposition with frame-accurate trims, then a passthrough export.
Selective: only rotated, flipped, cropped or sped-up clips are rendered, into the draft's own format, then everything is joined. Since pulse-editor feat: on-device captions (whisper.rn) with GPU accel + model picker #14, copied clips trimmed at their start are rendered too, and a rendered clip ends at its slot (Engine pass 2026-10-14).
Full encode: when clips don't share a format that fits, or the selective path fails. The whole timeline is encoded once onto the upright canvas.
Android paths:
Join (Media3 transmux): only when nothing is trimmed or edited. Media3 can't mix copied and encoded clips, and copying isn't frame-accurate at a trimmed start.
Otherwise: one hardware encode with trims, natural-pitch speed, rotate/flip/crop/letterbox effects, and an explicit 5.1 → stereo downmix.
Android audio sync fix (found by measuring): Android merges drifted: each clip's audio kept its source's AAC end padding (Media3 never trims it), so every clip pushed the next clip's audio later (0 → 10.7 → 21.4 ms over a 3-clip join), and encoded merges started 9.4 ms late (Media3 assumes 1600 samples of encoder priming; the emulator's encoder primes 2048). Each clip's audio is now cut to the clip's length, a join encodes its audio (video still copied), and each AAC encoder's priming is measured once and written to the edit list. After: every flash/click event within 0.0 ms on the emulator (joins, 44.1/48 kHz mixes, clips with audio 200 ms longer or shorter than video), within 3 ms inside 2×/0.5× clips. iOS was already within 0.2 ms.
Android merge audio quality: resampling uses the band-limited filter extractAudio uses instead of Media3's linear interpolation (a 10 kHz tone's alias at 13.9 kHz: −21 dB → −117.5 dB). The export code is shared with conform; decoder fallback is on.
Muted clips: the gap is filled with real silence (the audio is re-encoded) instead of being left as an empty stretch in the audio track. In a local check, FFmpeg 9 also placed the audio correctly after an empty stretch (within 8 ms); browsers weren't tested.
Audio sync fix (found in device testing): re-encoded audio is now written to an MP4 instead of an M4A before the join. From the M4A, the AAC encoder's priming (2,112 samples) was lost, so FFmpeg-based players played the audio 44 ms late. Every iOS path now matches the original recording within 0.1 ms in both AVFoundation and FFmpeg.
Build fix: pulse-editor's React Native codegen scans only src/. Before, it collided with the app's generated view managers at dex merge.
extractAudio and captions (whisper.rn 0.6.0 → 0.7.4)
Contract:extractAudio(uri, { sampleRate = 16000 }) → { data: ArrayBuffer, sampleRate, durationMs }: 16-bit mono PCM in memory, empty when there's no audio track.
iOS: one AVAssetReader pass. Apple's converter decodes, downmixes and resamples; the audio is read as float and turned down only if the downmix would clip (5.1 did).
Android: Media3's extractor into MediaCodec, mono at −3 dB per channel, and a band-limited polyphase resampler (Media3's Sonic interpolates linearly, which aliases). Priming is skipped by the decoder's timestamps, because the S24's decoder already drops it and skipping it again put audio 21 ms early. Output stops at the track's duration.
Captions: VAD (detectSpeechData) and Whisper (transcribeData) read the one buffer. There's no FFmpeg WAV on disk, no second decode and no temp cleanup.
Greedy decoding:beamSize: 1 is dropped, because whisper.rn turns on beam search for any beamSize. Same transcripts and 8–15% faster in a local run of the same whisper.cpp; not measured separately on the phones.
VAD asks for the CPU explicitly. whisper.rn 0.7.4 already runs VAD on the CPU on both platforms, so this changes nothing at runtime. The 12.7 s VAD time on the first iPhone run isn't explained; the next run took 128 ms. It gets re-measured on the next device run.
Whisper's CPU fallback passes useGpu: false. whisper.rn defaults useGpu to true, so the old fallback asked for the GPU again. It only runs if the GPU context fails to load, which hasn't happened in testing; checked by reading whisper.rn's source.
Audit of the migrated methods (both platforms)
Each bug below was reproduced against the code before the fix and re-measured after (iOS: pulse-editor's own sources on macOS; Android: the emulator), with flash/click sync fixtures, FFmpeg decodes and the phone test clips.
iOS
A full encode could hang forever, and cancel couldn't stop it: a sped-up clip next to a clip in another audio format stalled AVFoundation's audio mix reader (4 of 5 runs), and played that clip's audio at 1×. Full encodes now render clip by clip and join (the selective path's machinery): 30 of 30 runs finish, audio in sync, the same length every run.
Selective exports mis-decoded in FFmpeg-based players (browsers, servers): rendered clips used B-frames, camera clips don't. Renders no longer use B-frames (FFmpeg: 665 of 665 frames, 0 errors), and a draft whose copied clips reorder frames is fully encoded.
A cancelled full encode left a temp file; audio stopped early when a draft ended on a muted clip (6.0 s of audio for 10.0 s of video). Both fixed.
Probe read rotation 180° off for mirrored videos; it now matches Android.
Errors name the clip; a trim past a clip's end is an error; HDR/10-bit clips never join; progress in 0.5% steps (an 8-minute encode sent JS 13,000 updates).
Android
Trimmed clips' audio was late by 7–48 ms (Media3 drops whole AAC frames before a clip's start). Full encodes now read each clip's audio from its file's start in a parallel audio sequence and cut it exactly: every event 0.0 ms at 1×, within 3 ms at 2× / 0.5×.
Drafts longer than ~5.5 minutes failed to export (the index outgrew Media3's 400 KB reserve, so the file wasn't faststart). Space is now reserved for the draft's length and the index moved to the front: an 8-minute, 80-clip draft joins in 48 s.
A join could silently produce corrupt video (clips from different H.264 encoder setups share the first clip's SPS/PPS). Clips now join only with compatible parameter sets; otherwise the draft is encoded.
5.1 → stereo matches iOS (was 7.7–10.7 dB quieter; some layouts folded channels onto the wrong side); progress no longer freezes when a join falls back to an encode; clips that can't be read are named; the encoder-priming measurement is bounded (2 s) and uses a chirp.
Both: errors reach JS as plain messages (Android sent the Kotlin class name and stack trace, iOS Swift's type description). Merge files a killed app left in the cache are deleted after a day.
Emulator / macOS pass before the device run (2026-10-01)
Measured with a temporary on-device bench (not committed) on the iOS Simulator and the Android emulator, and with pulse-editor's iOS sources on macOS, using the new flash/click sync drafts (+ s6 join, + s7 mixed 48 / 44.1 kHz; regenerated without B-frames, like camera recordings, so an edited + s6 takes the selective path).
iOS joins drifted in FFmpeg-based players (Chrome, servers): copied AAC relies on one edit-list entry per clip to drop each clip's priming and end padding, which AVFoundation honours and FFmpeg doesn't (4-clip join: 0 → 10.7 → 21.4 → 32 ms; ~200 ms over 20 clips). Audio from more than one clip is now re-encoded once over the timeline: 0.0 ms at every event in FFmpeg and AVFoundation, on macOS and in the app on the Simulator. A single clip's audio is still copied. Cost (macOS): a 2-minute join 0.5 → 3.4 s, 8 minutes 3 → 13.6 s; on the iPhone since, a 2-minute join 1.0 s (2026-10-01) and 1.6 s (2026-10-13).
iOS trimmed joins started the picture up to 16.7 ms after the sound in FFmpeg (it drops a partial first frame). Join trims now snap to the nearest frame: 0.0 ms in both.
Android HDR failed on any GPU without GL_EXT_YUV_target (OpenGL tone mapping needs it; the emulator lacks it). Such a device now reads HDR as SDR (flatter colours) instead of failing; not run on such a device yet (the emulator can't decode 10-bit HEVC at all). HDR on the S24 ran on 2026-10-07 (below).
Android export errors were a codec-configuration dump ("Codec exception: CodecInfo{max-bitrate=…}"); they're now one plain sentence per Media3 error code, with the full exception, each encoder's measured priming and any encoder fallback logged under adb logcat -s PulseEditor.
Android exports played 44 ms early on Apple players (Safari, Photos, iOS viewers): Media3's muxer omits the AAC roll sample group that FFmpeg writes, so AVFoundation trimmed Apple's default priming on top of the edit list (FFmpeg read 0.0, AVFoundation −44 ms). The group is now added after export: all six sync drafts read the same in both players on the emulator (0.0 ms; 2× clips −17.5 ms, half a frame).
iOS mixed-audio drafts (e.g. 48 and 44.1 kHz clips) now join instead of fully encoding, since the join re-encodes multi-clip audio anyway (macOS: 12.8 s → 0.77 s, in sync).
Android extractAudio no longer idles in its decode loop and downmixes in bulk (emulator, 24 s 5.1 clip: 1951 → 959 ms).
Compared with RNVT on the same scenarios (Simulator and emulator, so sync and correctness only; speed needs the phones): RNVT's joins drift +32 ms in FFmpeg-based players, its 2× draft is 1584 ms out in FFmpeg, it fails extractAudio on a file without audio, and its probe is ~20× slower (106 vs 5 ms).
Checked and fine: every hostile import (HDR, PQ, 120 fps, VFR, Opus, no audio, 270°, square, NTSC, mono 44.1 kHz) alone and as one draft on iOS; selective, muted-clip joins, 2× / 0.5× (within one frame) and cancel (no leftovers) on both.
On the phones (2026-10-01, iPhone 17 Pro Max + Galaxy S24 Ultra)
Same scenarios on both engines, alternating order, with the flash/click sync drafts measured in FFmpeg (browsers) and AVFoundation (Photos).
Sync: pulse-editor 0.0 ms in both players on joins, trims, selective and mixed-rate drafts on both phones (2× clips within half a frame). RNVT: +32 ms on iPhone joins and trims in FFmpeg, +496 ms on the iPhone 2× draft, −24 to +15 ms on the S24, durations up to 320 ms off.
S24 speed: pulse-editor beats RNVT on every merge (0.53–0.95× its time); HDR (HLG, PQ) and start-trimmed clips work. iPhone: joins are 2–3× RNVT's time because the audio is re-encoded (that's what keeps browsers in sync); 2-minute join 1.3 s.
Fixed from the phone runs: Android extractAudio batches decoder frames on Android 15+ (2-minute draft 9.0 → 1.2 s, alignment within 0.06 ms); one-clip Android drafts were re-encoded instead of copied; Android joins feed the audio encoder in larger buffers (21–34% faster). Cancel: iPhone 155 ms, S24 6–36 ms, no leftover files.
Every output faststart; FFmpeg decode errors only on an iPhone selective export of x264-made test clips (Apple-encoded clips, like recordings: 0, checked on macOS).
On the phones (2026-10-13)
S24, both engines again (android-s24-compare-1013h-1, debug APK): pulse-editor faster than RNVT on every merge, 0.37–0.71× its time (2-minute join 8.6 vs 23.2 s, 8-minute 41.0 vs 81.2 s, edited draft 4.2 vs 8.2 s); RNVT's own times within −3…+11% of 2026-10-01. Lip sync unchanged: pulse-editor 0.0 ms in both players (2× clips −17.5), RNVT −24…+15.4. A merge cancelled mid-way settled 12 ms after the abort, nothing left; extractAudio 51–126× realtime (android-s24-quick-1013g-2).
Batched audio decoding in Android exports (Android 15+, pulse-editor RNVT native trim editor + destructive edit model #4): Transformer's audio is decoded with extractAudio's batch settings when the decoder supports it (logcat on the S24: audio decoder: batched (c2.android.aac.decoder, input 64 KB, output 256 KB)). S24 against 2026-10-01: copied drafts 8–29% faster (heavier join test files on 2026-10-13), the 2× draft 28%, other encodes −3…+5%.
Release builds, same code, same day: the S24's release APK joins 25–35% faster than its debug APK (2-minute join 5.8 s, 21× realtime); re-encoded drafts +2…+9%, preview and seeks no faster. iPhone Release merges −19…+18% of Debug with no direction; extractAudio 15–43% faster in Release (2-minute draft 391 vs 690 ms). So the debug numbers in Migrate native media work from react-native-video-trim to pulse-editor (engine for the timeline editor) #242 hold for iOS merges and overstate Android join times by about a third.
iPhone, both engines again (ios-ios-compare-1013): lip sync as on 2026-10-01 (pulse-editor 0.0 ms in both players, 2× draft −25.0; RNVT +27–32 ms in browsers on joins and trims, +496.5 ms on the 2× draft). The phone was slower that day for both engines: joins 1.2–1.9× (pulse-editor) and 1.1–2.3× (RNVT, unchanged code) of 2026-10-01, covers 2.3× and conforms 1.1× of 2026-10-07; the ratios held (pulse-editor's joins 1.3–1.9× RNVT's). Inference: the phone; whether Low Power Mode was on wasn't checked.
Also
Minimum Android is now 10 (API 29), from 7 (API 24); iOS stays at 16.4. API 29 is the lowest where Media3 tone-maps HDR to SDR on the GPU; below it, Transformer refuses to decode HDR, so iPhone HDR imports (117 of our 147 phone test clips) couldn't be converted for Android. Also fixes an Android lint error in the merge (Media3's setSpeed is @ExperimentalApi and wasn't opted in).
The recorder's preview player sets preservesPitch explicitly (expo-video's Android player starts with it off).
conform
Contract:conform(uri, { width, height, rotation (clockwise tag), fps, bitrate, audio: { sampleRate, channels }, copyVideo }, { onProgress, signal }) → { uri, durationMs, encoded, bitrate }. The policy stays in Pulse's decideImport; conform carries it out.
Output: H.264 8-bit SDR BT.709 at the canvas and the recorder's rotation tag (1920×1080 tagged 90° on both phones), AAC in the recorder's layout, faststart. HDR is tone-mapped, mirrored sources are flipped back, copyVideo re-encodes only the audio.
Fail closed: a video whose sound the device can't decode is rejected (RNVT imported it silent); outputs are probed and must be as long as the source's picture. No FFmpeg retry.
iOS: merge's single-clip render (constant 30 fps) and its join with the audio re-encoded; the iPhone camera's rotation matrix. Android: one Transformer export (frame drop to 30, mirror flip, letterbox, a turn into the coded orientation) with the exact tag written on the muxer's format; every Android SDR encode (merge too) now asks for BT.709 limited range.
Pulse:conformToContract calls conform once and verifies as before; the import and .pulse unpack gates use it. RNVT's compress is no longer called.
macOS (iOS code), 53-group sample of 173 files (iPhone Dolby Vision HLG up to 4K120 with spatial audio, screen recordings, full-range HEVC, 5.1 exports, messaging clips, the import fixtures): all 51 that needed it converted to contract, 0.2–34 s each, no FFmpeg decode errors; lip sync 0.0–0.1 ms in FFmpeg and AVFoundation, full and audio-only; a mirrored clip correct.
Android emulator, through Pulse's import gate: every 8-bit input converted to contract for an upright and a 90°-tagged target; lip sync 0.0 ms in both players, full and audio-only; cancel 14–86 ms, nothing left behind. The emulator can't decode 10-bit HEVC, so HDR waits for the S24.
iPhone videos' spatial-audio track: iPhone videos carry an APAC track Android can't decode next to their stereo AAC. Test clips with a real iPhone video's two tracks (APAC second, and APAC first and default) keep the AAC sound on macOS, the Simulator and the emulator, full and audio-only (correlation with the source's AAC 0.999 at 0 ms), so iPhone videos imported on Android keep their sound.
Next to RNVT's compress in Pulse: on the iOS Simulator both convert to contract; on the Android emulator RNVT's full conversion fails by its own bug (its FFmpeg command picks the mpeg4 encoder with contradictory frame-rate options), its audio-only one works. On the phones (2026-10-07): iPhone 42 of 42 inputs to contract from both engines, no decode errors, lip sync 0.0–0.1 ms, cancel settled in 377 ms, pulse-editor faster on 33 of 38 (slower on audio-only), 1080p 5–7× realtime, 4K Dolby Vision 1.5×; S24 38 of 38 incl. HLG / PQ / Dolby Vision (the emulator couldn't), lip sync 0.0 ms, cancel settled in 15 ms, 1080p 4–7× realtime, RNVT's full conform fails there by its bug. Found on the S24 (2026-10-07): a corrupt source (export 4.MP4, 73 decode errors on the Mac) came out with 746 of 3424 frames and gaps where iOS conceals; a 23.976 fps HLG clip came out at 26.4 fps and a 4K HEVC one at 29.3 fps, their sources' variable timing kept (the recorder-match check flags the rate; the bench's decode check had misread the timing as duplicate timestamps and was corrected). 2026-10-13: Android conform now rejects an output with fewer than 80% of the frames a clean decode gives, counted from the source's sample times through Media3's own frame-drop rule (pulse-editor feat(dev): realistic dev-seed fixtures (Git LFS) + generator #2). S24, the full corpus (android-s24-conform-pe-1013h-1): 34 converted, 7 passed through (the phone's recording, and 6 clips that differ from the recorder only in audio layout, which Android's decideImport now leaves as they are), the corrupt source rejected ("This phone couldn't decode all of the video (746 of 3430 frames)"); HDR levels −10…−65 below the source (the tone map); the two variable-timing clips as on 2026-10-07; lip sync 0.0 ms; cancel settled 5 ms; no level shift on the full-range HEVC screen recording (the emulator's darkening doesn't happen on the phone). With the merged rule (android-s24-conform-pe-1013k-1) the expected count equals the written one on every clean source (a 60 fps clip 600 of 600, the screen recording 645 of 645). iPhone Release (ios-ios-rel-conform-1013, pulse-editor only): 41 inputs, 38 converted and 3 already matching, the same 7 HDR level flags as 2026-10-07, lip sync 0.0 / 0.1 ms, cancel settled 753 ms after the abort (377 on 2026-10-07).
thumbnail
Contract:thumbnail(uri, { timeMs, maxWidth, maxHeight, quality, rotation, flipped, crop }) → { uri, width, height, timeMs }: the exact frame as a JPEG, fitted inside the maximum, with the clip's edit drawn by merge's own geometry (so a cover matches the export) and HDR tone-mapped.
iOS:AVAssetImageGenerator (zero tolerance) through a MergeGeometry video composition. Android: Media3 FrameExtractor with merge's edit effects (+ mirror flip). Pulse's generateThumbnailFile uses it; RNVT's getFrameAt is no longer called.
Fixes over RNVT: Android un-edited covers were 61×108 instead of 144×256 (sized before turning upright), mirrored sources came out sideways, same-second covers overwrote each other; iOS failed on PQ HDR and on a time past the end.
Tested: macOS (every edit vs merge's frame, 31–35 dB; HDR; exact frames); Android emulator and iOS Simulator in Pulse next to RNVT (same pictures; exact frames; 150–600 ms per cover on the emulator, 20–160 ms on the Simulator). Phones (2026-10-07): 37 of 37 covers on each, the better match to the FFmpeg reference on most (RNVT fails past the end and a < 1 s clip, picks wrong frames on two corpus clips, ignores a mirror on the S24); iPhone 22–50 ms per cover (10–20 ms slower than RNVT), S24 160–600 ms (RNVT 90–630; a player per call: fine for one cover, too slow for a strip). 2026-10-13: on Android the extractor of the last file stays open (pulse-editor Draft & clip management: rename, delete, ⋯ menu #3; the file's size and modification time are in its media id) and the edit is drawn on the extracted bitmap with merge's geometry. S24 (android-s24-thumb-1013j-1, the merged code): 37 of 37 covers, every PSNR unchanged; median 15 ms per call, later covers of a file 10–40 ms, a file's first cover 144–516 ms (RNVT 94–517 ms per cover, still failing the < 1 s clip). iPhone Release (ios-ios-rel-thumb-1013): 37 of 37, every PSNR unchanged; 37–849 ms per cover (median 107), with RNVT's times 2.3× slower than 2026-10-07 as well (the phone that day). (The 2026-10-07 counts here said 39; every thumbnail result file holds 37 covers.)
<PulsePreview>
Contract:<PulsePreview clips options onStatus onTime onReady /> with play, pause, seek(timeMs) (resolves once that frame is on screen; a newer seek replaces a pending one) and setScrubbing. clips are MergeClips and options the draft's MergeOptions, so it plays exactly what merge would export. snapshot() and stats() are for the bench.
Preview = export by construction: iOS plays Timeline.compose, the composition merge now renders from (split out of Render; merge unchanged). Android's one CompositionPlayer is built from merge's per-clip media items and effects. Every clip, copied or rendered, is trimmed to the nearest source frame with a whole-ms length on both platforms (pulse-editor feat: adopt more react-native-video-trim features #12), so trimmed drafts show the export's frames.
"On screen" is measured, not assumed: iOS waits for the layer to display the new item. Android draws into a TextureView, because CompositionPlayer's frame callback fires before rotate/crop/letterbox are drawn (with a SurfaceView, 4 of 6 edit screenshots showed the old picture).
Tested with Pulse's bench (preview mode): four test clips carrying each frame's number in the picture, three drafts (whole clips, trims inside frames, rotate/flip/crop/speed), every screenshot compared with the export of the same draft:
iPhone 17 Pro Max (2026-10-02): seeks 59 of 60 on the export's frame (the 1: the export lags a frame at the end of the sped-up rendered clip), p90 64–79 ms; first frame 73–86 ms; edits on screen in 53–81 ms, 6 of 6 showing the edit; ~31 pictures/s while dragging; playback 30 fps, none dropped. Play started 169–301 ms late (fixed since, below).
iOS Simulator (2026-10-06, the committed code): seeks 58–59 of 60 (same quirk), p90 62–76 ms; first frame 31–73 ms; edits 27–80 ms, all showing the edit; 60 pictures/s while dragging; 29.1–29.5 fps, none dropped; play-start lag 0 ms.
Android emulator (host GPU and host H.264 decoder, 2026-10-06, six runs): seeks 60 of 60 in every run, edits 6 of 6, playback 26.6–28.7 fps, none dropped; first frame 114–554 ms; seek p90 ~300 ms and 3–8 pictures/s while dragging are the emulator's (goldfish decoder), not the S24's.
Exports unaffected by the shared code: the Android trimmed export's clicks sit exactly at the trims, and iOS's within its frame rounding.
Fixed on the iPhone (2026-10-02):seek() resolved when the frame was decoded, not displayed (3 / 1 / 1 of 20 seek screenshots per draft right at +0 ms, all at +50 ms). A seek is now done when the layer's displayed buffer changes (display-link watch, 40 / 300 ms caps), the video output is attached per item, and a drag reports each landed frame through onTime.
Fixed on the Simulator (2026-10-06), confirmed on the iPhone on 2026-10-07 (below): after play() the picture and the reported time stood still ~200 ms. Traces: timeControlStatus playing within 4–5 ms, but the item's timebase kept rate 0 for ~90 ms then ran up from −108 ms — play()'s start "at a host time in the near future" (AVPlayer.h) for media loading that isn't needed on a prepared local item. play() now sets the rate at the current host time: lag 168–206 → 0 ms on every draft, first new frame +249 → +18–49 ms, everything else unchanged. No effect (A/B'd): preroll, playImmediately, activating the audio session. An audio tap saw the first buffer enter the renderer 16–24 ms after play() (5–48 with play()), PTS 0.0 from position 0; sound at the speaker is an ear check on the phone.
Changed on the emulator (2026-10-06):TextureView frames carry no timestamp there, so they're matched to Media3's frame callbacks in order; after a drag, released-but-never-drawn frames in the queue made the next edit go unreported (screenshot right, lastSwapMs −1) and the settle seek hit the 3 s timeout. Stale entries (>300 ms) are now dropped before order-matching and the queue cleared on a rebuild: no unreported edit since; the settle timeout still hits 1 of 3 drafts (4 of 7 before). onTime now reports the on-screen frame's time (picture 100 → 67 ms ahead on the emulator). A chase-seek layer was tried and reverted: ExoPlayer's scrubbing mode already drops intermediate seeks, and the layer cut the drag picture rate 5–8 → 1–2/s. Each landed seek logs its decode/display split and the default decoder, for the S24 run.
On the phones (2026-10-07, the committed code):iPhoneios-ios-preview-t3: seeks 79 of 80 on the export's frame, p95 61–63 ms; first frame 56–122 ms; edits 41–92 ms, 8 of 8; 58–60 pictures/s while dragging; 30 fps, none dropped; play starts in 0 ms on every draft (the host-time start confirmed on hardware; traces: first new frame +34–50 ms). Open by ear: after a play straight from a paused seek the first audio buffer reaches a test tap 106–135 ms after play() (4–34 after a pause); preroll doesn't help (cancelled by the play 23 ms later). S24android-s24-preview-1007: seeks 80 of 80, edits 8 of 8, 29–29.6 fps none dropped, first frame 119–481 ms — the frames are right; the speed targets are missed: seek p90 239–281 ms (141 ms median is Media3 decode + composition, 24 ms the view; hardware decoder), 8–10 pictures/s while dragging, edits 288–491 ms, play 118–173 ms late after a paused seek. Its TextureView frames carry no timestamp either (matched by order), the settle seek after the trims drag hit the 3 s timeout once, no player-release timeout. Lip sync while playing: not measured on either.
On the phones (2026-10-13):iPhone, Release build (ios-ios-rel-preview-1013): seeks 77 of 80 on the export's frame (the 3: the export's sped-up-clip quirk; the preview shows the expected frame), p90 56–64 ms, first frame 61–86 ms, edits 42–99 ms 8 of 8, 54–62 pictures/s while dragging, 30.1–30.2 fps none dropped: in line with Debug on 2026-10-07. First sound after a play (step 0, ios-ios-audio-step0 and ios-ios-audio-idle-1013, a per-buffer trace of the audio tap): the seek is not the cause (a play right after a seek: first audio +2 ms); an audio output idle for ≥ 5 s is (+116–125 ms after a 10 s pause, +62 after 6 s, +2–9 after 2–4 s), and a freshly built item adds ~30–40 ms. The buffer times say the start is cut (~100–160 ms), not late (inference). pulse-editor Gesture-driven segment bar: hold-to-edit, drag-to-trash, sticky preview #7: a play on a cold output (≥ 5 s since audio last ran or never ran, and the draft has sound) starts its clock 160 ms ahead; the first buffer then arrived 115–126 ms after play(), before the clock starts (ios-ios-audio-coldlead-1013b; Release ios-ios-rel-audio-1013: a 4 s pause no hold, 6 s held). On pulse-editor main (Debug, ios-ios-main-preview-1013, the join and all-muted drafts): seeks 40 of 40, p90 59–64 ms, the 160 ms lead only on the cold plays with sound, every warm play and every play of the all-muted draft 0 ms. By ear next. S24, composition only (android-s24-preview-1013 debug APK; android-s24-rel-preview-1013e-1 release APK, timings only): seeks 80 of 80 and edits 8 of 8 on the export's frame, 29.0–29.5 fps none dropped, first frame 112–260 ms, edits 245–407 ms; the settle seek after a drag 145–272 ms (was a 3 s timeout); with onTime reporting the frame on screen while paused, restarts read +37–105 ms (were −22…−89). Missed in both builds: seek p90 199–294 ms, 9–13 pictures/s while dragging, play 136–247 ms after a seek or on a first play. Plain ExoPlayer on the same phone (SeekBench, pulse-editor Bump react-native-video-trim to 8.1.4, drop vendored patch #6, debug and release): exact drags 25–27.5 pictures/s, paused seeks p95 115–157 ms, no low-latency decoding on c2.qti.avc.decoder. Drag layer (pulse-editor feat(recorder): running timer + reach-the-ends playhead scrub #10; android-s24-preview-1013o-1, its head, debug APK): a plain ExoPlayer on the dragged clip while a finger moves, everything else on the composition: about 31 seeks landed/s while dragging (composition alone 0.5), a drag into another clip shows it in 63–162 ms, the drag picture matched the composition's frame at the same time in 16 of 16 checked pairs (PSNR ≥ 51.8 dB), settle 120–189 ms with no timeouts, seeks 80 of 80, edits 165–354 ms all showing the edit, 28.7–29.2 fps; paused seeks unchanged (the composition). Tried and left out: paused tap-seeks on the layer (wrong frames and settle timeouts in android-s24-preview-1013j-1) and a low-latency AudioTrack (no measurable gain). Play start after a seek on the S24 stays 120–239 ms with or without the layer: from reading Media3 1.11's code (not measured), every seek releases the AudioTrack and the picture waits for the audio clock, which stands still until the new track plays its first sample. Accepted as a Media3 limit (2026-10-14).
After merging main, and at real draft sizes (2026-10-13):iPhone, the four drafts on the merged branch (ios-ios-preview-merged-1013): seeks 78 of 80 on the export's frame (the 2 flagged by the bench as the export's, the expected frame shown), p90 60–64 ms, first frame 54–77 ms, edits 42–66 ms all showing the edit, 58–62 pictures/s while dragging, 30.1–30.2 fps none dropped, the 160 ms lead only on the cold plays with sound: as before the merge. 20 and 40 clips (210.7 s and 418.3 s; trims, a rotation, a crop, 2× and 0.5× clips): iPhone (ios-ios-preview-many-1013) first frame 76–83 ms, edits 60–77 ms all showing the edit, seek p90 64–65 ms, 61 pictures/s while dragging, 30.2 fps none dropped; Pixel 6a (android-pixel-preview-1013-1) first frame 283–314 ms, edits 166–320 ms all showing the edit, seek p90 271–317 ms, 27–31 seeks landed/s while dragging (33–40 pictures/s), 22.2–22.9 fps none dropped, play 91–170 ms after a seek or on a first play. Seeks on the export's frame: iPhone 56 of 68, Pixel 63 of 68. The Pixel's 5 misses are at or just before the start of a clip whose trim starts mid-frame (4: the export still shows the previous clip's last frame); the iPhone's 12 are on the last frames before a join and in the 2× and 0.5× clips (the export's sped-up-clip quirk), and FFmpeg, which the comparison reads the export with, reports 53 / 107 decode warnings in those two iPhone exports (the bench's x264 test clips next to rendered ones, see Known). Where the misses sit is read from the report against each draft's clip layout. Since then the engine snaps every trim to whole frames (pulse-editor feat: adopt more react-native-video-trim features #12, Engine pass 2026-10-14 below). Pixel 6a, the four drafts (android-pixel-preview-1013-2): seeks 80 of 80, first frame 125–516 ms, edits 163–361 ms all showing the edit, seek p90 235–335 ms, 29–30 seeks landed/s while dragging, 19.4–23.5 fps none dropped.
cleanFiles → an expo-file-system sweep at launch of RNVT's leftover trimmedVideo* files in the documents and caches folders (Simulator: removed them, kept other files; not yet run on Android).
saveToDocuments: the export screen's "Save to Files" button is removed; the Share button's sheet offers "Save to Files" on iOS.
Main merged in (2026-10-13)
origin/main at 256e8e8 (app 2.2.4: the UI pass, onboarding tips, universal links, PulseVault 0.6.0) merged in (49bbe38). The 9 conflicts take main's UI and keep this PR's engine side: the pulse-editor merge and its failure copy, the shared progress ring (main's animated sweep moved into it), no "Save to Files", the dev-only bench link inside main's link handler. pulse-editor is pinned to its main, 1ed6cde (3ad1e12); moved to 223acc6 on 2026-10-14 (66d0522), now 5750081 (31193f0; docs since).
After the merge: tsc, lint and the unit tests pass, Android and iOS debug builds succeed, and the iPhone's quick and preview benches read as before the merge (ios-ios-quick-merged-1013: lip sync 0.0–0.1 ms in both players on joins, trims, selective and mixed-rate drafts, 2× −25.0, cancel settled 147 ms; ios-ios-preview-merged-1013, above).
Draft data layer for the editor
Typed edits, latest wins (d3fef1e): setClipEdit(segmentId, edit) stores a typed edit in the shape parseEdit reads. The edit's cover is rendered first and the edit and cover are written in one update (889ac37, Edits: a clip's edit and its cover are saved separately and can disagree after a crash #273), so a stopped app never leaves an edit with another edit's cover; per clip only the edit or revert asked for last is written. Revert (resetEdit) does the same with the pristine cover. File deletes after a committed save can't fail the save.
Atomic clip transactions (1f96ab9): drizzle's expo-sqlite transaction() commits when its callback returns, so the awaited statements in addSegment, reorderSegments and insertImportedDraft ran after the commit and a throw rolled nothing back. Their callbacks are now synchronous, so each commits or rolls back whole.
One mergeOptions() (075c0bf): the export's MergeOptions come from one builder, so the preview can pass the exact object the export merges with. No behaviour change.
On the phones (bench dbcheck, iPhone 17 Pro Max ios-ios-dbcheck-1013 and Pixel 6a android-pixel-dbcheck-1013, real SQLite): adds (2 awaited, then 4 at once) numbered 1–6 in order; two racing reorders end in the later request and an awaited one after them in its order, with no unique-constraint errors; a burst of 4 edits stores the last with one cover; set→Revert and Revert→set, 50 ms apart and at once, end in the later call's state with no leftover covers; an import that hits a unique-constraint error leaves no draft or clip rows; the options builder gives the bench's options. 10 of 11 steps pass on both; the 11th, the import step, fails on the bench's own check that the imported clips' files exist (file: false), while its rollback and delete checks pass.
Engine pass 2026-10-14
Debug builds on the iPhone 17 Pro Max and the Pixel 6a (Android 17 beta). pulse-editor is pinned to its main, 5750081 (31193f0): 223acc6 (66d0522) for #12 and #14, then the README and docs rewrite (pulse-editor #15, #16).
Whole-frame trims, whole-ms clip lengths (pulse-editor feat: adopt more react-native-video-trim features #12, f34b058, both platforms): every trim snaps to the nearest source frame and every clip's length is cut down to a whole ms; merge and the preview read the same window, and the Android join is cut to it too. A clip starting on a fractional ms (e.g. 5733.33) made a seek to its start show the previous clip's last frame on Android (CompositionPlayer.seekTo takes whole ms).
iOS selective merges FFmpeg reads without holes (pulse-editor feat: on-device captions (whisper.rn) with GPU accel + model picker #14, 223acc6): copied clips trimmed at their start are rendered, because next to rendered clips FFmpeg's mov demuxer drops the frames before each such join (trac #6584); and a rendered clip ends at its slot (a 2× clip of 100.5 frames was written 101, so later clips started 16 ms late). iPhone, FFmpeg through the edit list (PulseVault's path): 20 clips 53 → 0 decode errors, 6305 → 6319 frames (the timeline's count); 40 clips 107 → 0, 12516 → 12548; quick sync-select 4 → 0. The trims + edits export 27.400 → 27.383 s (the timeline). Cost: sync-select 3.7 → 5.6 s.
Preview vs export (bench preview, seeks whose screenshot equals the export's frame): Pixel join / trims / edits / mute 20 of 20 each (trims was 13 with whole frames but fractional lengths), 20 clips 30 of 30 (28), 40 clips 38 of 38 (30), trims + edits 17 of 20, odd-length join 20 of 20. iPhone 20 / 20 / 19 / 20, 20 clips 26–27 of 30, 40 clips 38 of 38, trims + edits 16 of 20 (was 13), odd-length join 20 of 20. Every remaining miss is in a 2× clip (±1 frame, accepted).
Untrimmed clips that aren't whole ms (oddjoin: 11966.667 / 11925.333 / 11900 / 11866.667 ms): the Pixel export starts its clips at 11.966 / 23.891 / 35.791 s, the preview's slots; the iPhone's at 11.966 / 23.866 / 35.766 s. iOS cuts an untrimmed clip at its video track's end, Android at the file's (one clip's audio is 25 ms longer), so slot lengths can differ across platforms by a recording's A/V gap; each matches its own export.
Quick passes (merges, lip sync, extract, cancel) on both phones: lip sync unchanged (0.0 / ±0.1 ms; 2× −17.5 Pixel, −25.0 iPhone), 0 decode errors; the trimmed join 16–21 ms shorter than asked (nearest-frame ends).
Android preview frame rate (pulse-editor feat: reliable recorder close, hide Next while reordering, square video previews #13, draft, not merged): the preview's view asks for the high frame-rate category while playing, and framesDropped is counted. Pixel Perfetto trace: the view votes high (749 times), never 30, but the display still drops to 30 Hz in stretches; join plays at 24.1 fps (19.4–22.7 without). Waits for an S24 run.
Timeline spike (2026-10-13 night): iPhone a 120 fps strip, 30–60 seeks/s, settle 25–108 ms; Pixel a 61 fps strip, 8–22 seeks/s (1 s keyframes), settle ~400 ms.
Accepted, not fixed: the 2× clip ±1 frame (both); Android paused seeks 200–340 ms and play after a seek ~150 ms; the fling scrub rate (keyframes); Pixel playback ~24 fps; the iOS vs Android length rule for untrimmed clips (video track vs file).
A clip tapped in the recorder opens /editor paused at that clip's start, nothing selected; the recorder's Edit button (left of the record button, opposite +, with a one-time tip) opens it from the draft's start (c4b8728). Export (top right on the recorder and in the editor) opens the export screen, so a draft can be finished with or without editing; it replaces the recorder's → at the end of the clip bar (c4b8728). The editor replaces the in-recorder clip preview and RNVT's per-clip editor, both removed (d7e235d).
Layout:<PulsePreview> on top; one fixed centre playhead over the clips in two views, switched by an icon pill next to play and remembered across sessions: Clips (thumbnails, the recorder's look) and Timeline (each clip its timeline length: a cover filmstrip and a thin-line peak/RMS waveform from extractAudio, cached per file). Clips show their edits at a glance (speed, rotate, flip, crop, mute).
Selecting: a tap selects a clip (the playhead and playback stay where they are, d8cbc09); the selection holds while the clip is on screen and goes on any tap off a clip (the preview, the black space around the controls). The selected clip's tools: flip, rotate, crop (RNVT's overlay plus aspect presets), mute, speed, reset, delete. Every edit applies at once (optimistic, latest-wins writes per clip), with undo/redo in the header; trims snap to source frames (the engine's rule).
Trims and themes (85a1eb4, d0ee26e; Pixel 6a): a trim resizes the clip live, the clips after it following the right grip, the left grip sliding the clip's footage, and the release lands without a snap (the total 0:37.4 → 0:37.0 with the playhead on the new end); each grip's chevron points inward at the source's own edge and outward once trimmed. The editor follows the app's light and dark themes, the player sized to the picture.
Reordering:react-native-sortables in the Clips view only: hold a thumbnail and drag it, and it's inserted where it's dropped (the clips it passes shift over; the recorder's bar does the same, 31b999c); the dragged clip is lifted above the screen through its portal. The timeline has no hold (a touch there scrubs, taps or trims). Moving a clip in the same touch as a timeline hold, by driving sortables' drag handlers from the strip's gesture, was tried and removed (d7845ab): each timing gap between the two gestures was a new bug on the iPhone. The recorder's clip bar keeps its clips while the editor covers it and is rebuilt on return if they changed (0e0ae71): a reorder applied to it off screen left a thumbnail missing or clips stuck in reorder mode (iPhone, fixed by hand-check).
Engine (both merged; pulse-editor main d5cc913, pinned in 2406c00): clip positions come from <PulsePreview>'s new clipStartsMs (pulse-editor feat: persist recorder camera preferences across launches #17, Pixel: [0, 12000, 24000, 36000] → [0, 8000, 20000, 32000] after a 1.5× edit); on iOS an edit no longer reports time 0 while the rebuilt timeline swaps in, and a seek during the swap waits for it (pulse-editor feat: draft transfer via .pulse export/import #18; iPhone, by hand: an edit while playing keeps the playhead going, a clip tapped right after an edit lands on its start).
Not run yet: the lip-sync film and the silent-switch / record-after-editor checks, frame rates in a Release build, the S24.
Verified
Checks:tsc, lint, 288 unit tests (22 skipped), at 075c0bf. The gated PULSE_E2E=1 import pipeline test (it replayed RNVT's FFmpeg command line) was removed in 0347bc6.
Builds: pulse-editor builds with no warnings in its code, for iOS devices and for Android. After main was merged in, Android and iOS debug builds of the app succeed.
iPhone 17 Pro Max:
joining 3 clips takes 90 ms;
trim + 2× takes 0.4 s;
rotate + flip + crop + 0.5× + mute takes 2.2–2.5 s, with only the edited clips rendered;
full encode of the mixed (20 clips) and wild-imports (12 clips, including HDR, VFR and Opus) seed drafts gives H.264 High 1080×1920 at a constant 30 fps, SDR, 4.2–4.9 Mbps, faststart, audio in sync;
every length is within a frame of the edits. (The wild draft came out 95.67 s for 96.00 s of clips; its odd-timing clips were resampled to 30 fps.)
Captions: extractAudio 80–180 ms, VAD 128 ms, Whisper base.en 123 ms on the GPU.
Galaxy S24 Ultra:
probe on recordings;
joining 3 clips without re-encoding takes 0.65 s, exactly the clips' total length;
trims, rotate + flip, crop, 2×, 0.5× and mute: one hardware encode in 1.7–2.1 s, lengths within a frame, 5.6–6.2 Mbps at a 5 Mbps target;
captions: extractAudio 0.4–0.8 s, VAD 0.2 s, Whisper on the CPU 1.5 s (whisper.rn 0.7 has no Android GPU backend).
Earlier on iPhone:
imports come out upright and letterboxed, HDR included, and a recording interrupted by an alarm is kept;
2-minute and 8-minute drafts join in 0.66 s and 2.4–5.2 s;
cancel works.
Local references:
the iOS merge and extractAudio code run on macOS with real iPhone recordings;
extractAudio's PCM matches an FFmpeg reference decode within 0.1 ms;
the same whisper.cpp (1.9.3), run with whisper.rn's exact settings on the phones' exports, produces the phones' transcripts.
Android emulator: every rotation, flip and crop gives frames identical to iOS, and cancel works.
Left before merging
Timeline editor: the lip-sync film during preview playback and the audio checks (silent switch, background, recording after the editor) on both phones; frame rates in a Release build and on the S24.
By ear and re-runs: the iPhone's cold-audio lead (the click 0.5 s in should land with the white band); the iPhone merge and cover benches with Low Power Mode checked (both engines 1.1–2.3× slower on 2026-10-13).
Manual checks: captions in the app after the latest changes, an export played in Photos and Chrome, a long-draft upload, 5.1 levels on the S24.
RNVT and FFmpeg removed (d7e235d: submodule, Metro/TypeScript/CI entries; iOS pods without them). Android and both store builds not built since.
Known
Android conform doesn't pad frames: a 24 fps or variable-rate import stays variable, 29.97 stays 29.97 (iOS gives a constant 30). Both pass the import contract and the recorder match.
Android, on the emulator: a full-range source comes out 9–10 levels darker (read as limited range). Not on the S24: its full-range HEVC screen recording converts with no level shift (2026-10-13).
Android renders slowed clips at a variable frame rate (an export with a 0.5× clip averaged 19.9 fps). It plays correctly; iOS fills to a constant 30 fps.
iOS: a selective export that mixes our renders with clips from another encoder (e.g. x264 files) got a few FFmpeg decode warnings at the boundaries (8, was 822, in a local fixture); camera recordings decode cleanly. Since pulse-editor feat: on-device captions (whisper.rn) with GPU accel + model picker #14 the iPhone's bench exports of such drafts read with 0 (2026-10-14); the local fixture wasn't re-run.
Android thumbnail on the S24: the first cover of a file takes 144–516 ms (the extractor opens the file), the next covers of that file 10–40 ms (2026-10-13).
A trim snaps to the nearest source frame on both platforms (pulse-editor feat: adopt more react-native-video-trim features #12; the frame grid is minFrameDuration on iOS, the average rate on Android, the same for constant-rate recordings; not run on recordings with variable frame timing). An untrimmed clip ends at its video track's end on iOS and at the file's on Android, so the same draft's clips can start a recording's A/V gap apart across platforms (25 ms in oddjoin); each platform's preview matches its own export.
Accepted (2026-10-14): a 2× clip's frames can be ±1 off the export on both; Android paused seeks 200–340 ms and play after a seek ~150 ms; the fling scrub rate (keyframes); Pixel 6a playback ~24 fps.
<PulsePreview> on the S24 (2026-10-13): paused seeks p90 199–294 ms and play 120–247 ms after a seek or on a first play (10–120 ms after a pause), accepted as Media3 limits (2026-10-14, below); drags about 31 seeks landed/s on the drag layer (9–13 pictures/s on the composition alone). TextureView frames carry no timestamp (matched to Media3's frame callbacks in order). iPhone: a cold play with sound (≥ 5 s without audio, or the first) waits 160 ms before the picture moves, so its first sound isn't cut (by ear next).
Android imports: a clip that differs from the recorder only in its audio layout is imported as it is on Android (no audio-only conform); iOS conforms its audio.
First step of replacing react-native-video-trim with our own editor engine,
pulse-editor (Nitro module: AVFoundation on iOS, Media3 on Android, no
FFmpeg), one method at a time.
Native modules from git submodules under modules/
- react-native-video-trim (the morepriyam fork, same pinned commit) and
pulse-editor are git submodules instead of npm dependencies. Expo
autolinking already scans ./modules, so both link from there.
- Metro resolves each bare import to the module's TypeScript source (no build
step) and blocks modules/*/node_modules and example/ so shared deps resolve
to the app's single react-native copy; tsconfig paths match.
- Build workflows fetch the submodules (iOS after prepare-expo-env, whose
checkout skips them). Prettier ignores modules/.
- A file: dependency was avoided: npm installed the fork's devDependencies
into the submodule, putting a second react-native where Metro finds it.
probe() replaces FFprobe
- pulse-editor's probe() reads AVFoundation's async loaders (about 2 ms a
clip) / Media3 MetadataRetriever and returns one contract on both
platforms: codec, coded size, clockwise rotation, mirrored, average fps,
bitrate, bitDepth, transfer (sdr/hlg/pq), durations, audio layout; video /
audio absent when the track is missing.
- Import rules read bitDepth > 8 and transfer instead of FFmpeg pixel-format
and transfer names, and one fps.
- Rotation is clockwise: the recorder format moves to recorder.format.v2 (iOS
default 270); v1 rows were counter-clockwise and are re-learned from the
next recording. RNVT's compress still takes FFmpeg's degrees, so
decideImport converts at that one call until conform moves.
- Call sites: contract gate, conform-verify, recorder-format learning,
preview sizing, recording-salvage check, getDurationMs, import (the extra
up-front isValidFile is gone). Unit fixtures hold probe's measured values;
the gated e2e maps ffprobe to the new shape.
Follows the module's rename to its npm name (pulse-editor is taken on npm).
The submodule path stays modules/pulse-editor; Metro and TypeScript map the
scoped name to its source, and Android autolinks it as :mieweb_pulse-editor.
The recorder asks for 5 Mbps but recordings probe at 6.4-7.1 Mbps. Every
finished recording is already probed to learn the recorder format; log what
it actually wrote (codec, size, fps, bitrate, length) under [import] so the
overshoot can be measured across scenes and clip lengths.
The export merge goes through pulse-editor's merge() first: clips come from
clipRender (typed edit fields; the editor's counter-clockwise quarter turns
become clockwise degrees), onto the reels canvas at 5 Mbps in the recorder's
audio layout. What pulse-editor doesn't cover yet (encoding, and Android)
rejects and falls back to react-native-video-trim's merge, logged under
[export]. Leaving the export screen or changing the clips cancels a
pulse-editor merge in flight.
Bumps pulse-editor to the merge contract + iOS fast join.
The export is merged in the recorder's audio layout, learned from each
recording in the background. A saved export was reused by its clips alone, so
one saved before the layout was learned (a device's first recording) kept the
old layout; and an export started right after that first recording could read
the default before learning finished. The saved export's key now includes the
layout it was merged in, and reading the format waits for learning in flight.
The abort listener was added only once inference started, so leaving the
screen while the audio was read, the speech check ran or the model loaded let
a full transcription run for nobody (and race a model release). Each of those
steps now stops on a cancel.
Conformed file durations are not reflected in timeline
src/features/draft-transfer/unpack.ts:149
After conformInPlace rewrites an imported original, this path still saves seg.durationMs from the bundle (and for a legacy baked edit, seg.editedDurationMs). Conform can change picture length, so the imported timeline and export trim window may no longer match the files on disk. Probe each stored file after conforming, use its picture duration in the row, and reconcile a settings-based edit whose end now exceeds the new source length.
When the app backgrounds, AppState calls pause(), but that method leaves the editor's playing state true. If the native player does not emit another onTime after pausing in the background, the editor returns with a Pause control for a stopped player, and tapping it pauses again. Set the local playing state to false when explicitly pausing, as beginDrag already does.
Undecodable AAC audio is accepted as passthrough
src/utils/contract-gate.ts:98
If an AAC track is present but its samples cannot be decoded on this device, probe() can still report its metadata and decideImport returns passthrough; only the conform() path attempts to read the audio. Such a clip is copied into the draft despite the stated policy to reject audio the phone cannot decode, and may play/export without sound. Validate audio decodability before accepting an unchanged import, or provide a native passthrough validation that reports unreadable audio without re-encoding the file.
A clip's edit was written before its cover was rendered (160–600 ms on a
Galaxy S24), so an app stopped in between kept the edit with the previous
edit's cover until the clip was edited again. The cover is now rendered first
and the edit written with it in one update; a revert does the same with the
pristine cover. Per clip, only the edit or revert asked for last is written, so
an older save that finishes late stands down. A cover that fails leaves none
(the clip's own first frame) rather than an older edit's.
Fixes#273
…othing
After the conversion, an import created the draft, copied the file, rendered
its cover and saved the clip with no cancel check between, so closing the
recorder then could still add the clip to a draft the person had left; and the
recorder's close-time cleanup could delete a draft the import was writing to.
Each step now checks for a cancel and undoes what was done (the copied file,
its cover), and while an import runs the cleanup of an empty draft is left to
the import, which does it once it has stopped.
Fixes#272
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The native-engine migration and new editor still have unresolved behavior findings and device-level checks pending.
0 open findings
Previously missed (5)
In code that hasn't changed since last review
Conformed clips retain stale durations and trim endpoints
src/features/draft-transfer/unpack.ts:149
When conformInPlace rewrites an imported clip, it can change the picture length (for example, when converting variable-frame-rate video to 30 fps). The row still stores the bundle's seg.durationMs at line 207; legacy baked edits likewise keep seg.editedDurationMs after being conformed. The editor/export can then seek or trim past the actual file's end. Read the rewritten files' picture durations and persist those instead of the bundle metadata; also clamp any saved trim endpoints to the new source length.
Early timeline gestures clamp against zero duration
src/features/editor/timeline-strip.tsx:264
The editor renders both Timeline and Clips before PulsePreview reports a duration, but values.totalMs starts at zero and is set only by onStatus. An early drag in this strip is therefore clamped to 0; the Clips row also caps its swipe time with the same zero value at clip-row.tsx:205, despite already knowing layout.totalMs/geom.total. Use the draft's layout length as the pre-status bound (and the engine's length once available), or disable both gestures until a usable duration is reported.
Minimum trim bounds can produce non-frame-aligned edits
src/features/editor/timeline-strip.tsx:326
The value is clamped after snapToFrame, so the stored edit cannot be shorter than 1 second by this calculation alone. But when the 1-second bound falls between frame times, that final clamp can store a non-frame-aligned trim point (for example, at a 29.97-fps grid, a left bound of 1000 ms clamps a 1001-ms frame back to 1000 ms). The native engine snaps that point again for preview/export, so the actual cut can move beyond the intended bound. Choose the last valid whole-frame start / first valid whole-frame end within the minimum-length bounds rather than clamping a snapped value to an arbitrary millisecond.
Play at timeline end races the asynchronous seek to zero
At the timeline end, c.seek(0) queues an asynchronous seek, but ref.play() runs immediately at the old position. The native seek only resolves when frame 0 is on screen; pressing Play at the end can therefore resume at the end or race the seek instead of starting from frame 0. Start playback only after the queued seek to 0 completes, while respecting c.inflight/c.pending if a previous scrub seek is still running.
When the app backgrounds or a reorder calls ctl.pause(), it pauses the native player but leaves c.playing, playingNow, and the React playing state true until a later onTime event. If none arrives in the background, the playhead continues advancing and the control still says “Pause.” Clear the local playing state when pausing, rather than relying on a native callback.
The timeline editor replaced both, and nothing opened them any more.
- The recorder's in-place clip preview (its player, playhead, scrubbing, ✂,
🗑 and reset buttons, the preview-close audio handoff branch) and the clip
bar's playhead cursor and its scrub lanes. A tapped clip opens the editor.
- RNVT: the submodule, its full-screen editor hook, its custom-speed helpers,
and its Metro, TypeScript and iOS CI entries. Its stray lefthook template goes
too. Custom speeds saved by older versions still join the editor's menu, and
the launch sweep of files RNVT left on upgraded phones stays.
- Helpers only those used (use-tick, utils/math, track-mapping, the preview
geometry), and comments and docs that described RNVT or the preview.
The clip bar keeps its size: the scrub lanes are now plain room around the
thumbs.
- Pause stops the playhead and the play button at once, instead of waiting for the
preview's next report.
- Play at the end waits for the seek to the start before playing.
- The playhead's range is the layout's length, known before the preview is up, so an
early scrub no longer clamps to 0.
- An engine status counts only for the clips it was built from, so a one-frame trim
never keeps the previous clip boundaries.
- The shortest-clip trim limits sit on frames.
- Resetting a legacy baked clip records no undo step (its file can't come back).
… stored picture
- A clip whose legacy baked edit file is missing from the bundle is skipped as
missing, not imported unedited.
- Each imported clip's length is probed from the stored (conformed) file. A saved
trim is bounded to it, and a baked edit's length is probed too.
…e original
When an edited clip's cover fails to render, the runtime fallback on Home and in the
recorder now renders the frame with the edit applied. If that fails too, no cover
shows, rather than the unedited first frame.
Replies to the Copilot review-body findings ("Previously missed"), which have no threads to reply in:
Recompute trims from final video duration after conform (unpack.ts), fixed in 49902ce. Each imported clip's durationMs is now probed from the stored file's video track, after conforming. A saved trim is bounded to that length: an out-point at the sender's end stays at the end, and a window left empty falls back to the whole clip with the rest of the edit kept. A legacy baked edit's length is probed from its conformed file instead of trusting seg.editedDurationMs. A clip with no picture after conforming is skipped.
Early timeline gestures clamp against zero duration (timeline-strip.tsx), fixed in 7cf9c49. The transport's total now comes from the editor's layout (ctl.setTotal(layout.totalMs)). The layout is known as soon as the clips are, so scrubs, flings and the Clips row no longer clamp to 0 before the first status.
Minimum trim bounds can produce non-frame-aligned edits (timeline-strip.tsx), fixed in 7cf9c49. The shortest-clip limits are rounded inward onto frames (ceilToFrame / floorToFrame). The source's own start and end stay as limits.
Play at timeline end races the asynchronous seek to zero (use-preview-transport.ts), fixed in 7cf9c49. At the end, play() seeks to 0 and plays only once the seek queue has drained. A pause or a drag in the meantime cancels the play.
Pause leaves local playing state active (use-preview-transport.ts), fixed in 7cf9c49. pause() now clears the playing state at once, so the playhead stops moving and the button flips. The preview's next report then snaps the playhead to the paused frame.
Checked: typecheck, lint and the 268 jest tests pass. I also checked the frame-limit helpers numerically at 24 to 120 fps. None of these changes has run on a phone yet.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The migration is broad and has unresolved findings involving timeline coverage, clip-error labeling, thumbnail-cache growth, and documentation consistency.
- Export (top right) on the recorder and the editor opens the export screen, so
a draft can be finished with or without editing. It replaces the recorder's →
at the end of the clip bar, which now uses the full width for clips.
- Edit (left of the record button, opposite +) opens the draft in the editor
from its start. A one-time tip points it out once there's a clip.
- A clip tapped in the recorder opens the editor paused on it (no autoplay).
A clip edited by an older version plays its baked file, which can be longer or shorter than the
original, but the editor gave it the original's length as its source (and its default out-point).
It now takes the baked file's length, as the player does.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Moves Pulse's native video work from react-native-video-trim (RNVT) to our own engine, pulse-editor (
@mieweb/pulse-editor): a Nitro module on AVFoundation (iOS) and Media3 (Android), with no FFmpeg. It goes one method at a time: each method is switched over in the app and tested on both phones.conformandthumbnailare switched over and tested on both phones (2026-10-07, re-run on both 2026-10-13), macOS, the Android emulator and the iOS Simulator.<PulsePreview>, the player the timeline editor is built on, shows the export's frames on both phones and meets its speed targets on the iPhone; on the S24 first frame, edits and playback meet theirs, drags run on a plain player (about 31 seeks landed/s), and paused seeks and the start after a seek miss theirs, accepted as Media3 limits (2026-10-14). Since 2026-10-14 every trim is whole frames and every clip length a whole ms on both platforms (pulse-editor #12), so the preview lands on the export's frame everywhere but in 2× clips. RNVT's editor (showEditor) is now the only part of the fork the app still uses. Main (app 2.2.4) is merged in, and the draft data layer the timeline editor writes through is in place. This PR stays open until every RNVT call is replaced; its last commit removes RNVT and FFmpeg, then it merges.Part of #242 (why, plan and status). Squashes #239 (submodules). Relates to #241 (recorder bitrate).
Status
✅ done · ⏳ left to do · 📋 not started. Devices: iPhone 17 Pro Max (iOS) and Galaxy S24 Ultra, Android 16 (Android), and since 2026-10-13 also a Pixel 6a, Android 17 beta; "macOS" = the same iOS code run on a Mac against references; "emulator" = Android 17 emulator.
probeprobeVideo,isValidFilemerge: join, trims, mutemerge(copy path)merge: cancelmerge: edited clips (rotate, flip, crop, 2×, 0.5×)mergewith clip editsmerge: full encodemerge: RNVT fallback removedextractAudio→ Whisper captionsextractAudioconform: import normalization, HDRcompress,cancelCompressthumbnailgetFrameAt<PulsePreview>: composition playershowEditorexpo-file-systemdeleteFile,cleanFiles,saveToDocumentsdeleteFile→File.delete;cleanFiles→ an expo-file-system sweep of RNVT'strimmedVideo*files (Simulator: removed them, kept other files); "Save to Files" button dropped, Share's sheet has it on iOSDone so far
Native modules as git submodules under
modules/pulse-editor, removed frompackage.jsonand the lockfile; Expo autolinks it from./modules.react-native-video-trimwas autolinked the same way until it was removed with its FFmpeg (d7e235d).src/(no build step) and blocksmodules/*/node_modulesandexample/, so there's onereact-native. TypeScriptpathsmatch.prepare-expo-env). Prettier ignoresmodules/.file:dependency: it installed the fork's devDependencies, putting a secondreact-nativewhere Metro finds it.--recurse-submodules.probe(replaces FFprobe){ durationMs, video?: { codec, width, height (coded), rotation (clockwise), mirrored, fps, bitrate, bitDepth, transfer: sdr|hlg|pq, durationMs }, audio?: { codec, sampleRate, channels } }.hevc(its base layer, via Media3'sgetAlternativeCodecMimeType) instead ofdolby-vision, andvideo.durationMsis the video track's own length (Media3'sMediaExtractorCompat), not the container's. Every field now matches the iOS probe on the same 171 files (147 iPhone videos: Dolby Vision HLG, 4K60/120, screen recordings, messaging-app files; plus the dev samples), except fps on 6 synthetic samples (29.83–30.0, all round to 30). The extra parse costs time on the emulator: median 5 → 9 ms per probe.bitDepthandtransfer. The recorder format moves torecorder.format.v2; sinceconformlanded,decideImporthands pulse-editor its clockwise rotation directly.mergemerge(clips, options, { onProgress, signal }).signalcancels; leaving the export screen or changing clips aborts it.AVMutableCompositionwith frame-accurate trims, then a passthrough export.extractAudiouses instead of Media3's linear interpolation (a 10 kHz tone's alias at 13.9 kHz: −21 dB → −117.5 dB). The export code is shared withconform; decoder fallback is on.src/. Before, it collided with the app's generated view managers at dex merge.extractAudioand captions (whisper.rn 0.6.0 → 0.7.4)extractAudio(uri, { sampleRate = 16000 })→{ data: ArrayBuffer, sampleRate, durationMs }: 16-bit mono PCM in memory, empty when there's no audio track.AVAssetReaderpass. Apple's converter decodes, downmixes and resamples; the audio is read as float and turned down only if the downmix would clip (5.1 did).MediaCodec, mono at −3 dB per channel, and a band-limited polyphase resampler (Media3's Sonic interpolates linearly, which aliases). Priming is skipped by the decoder's timestamps, because the S24's decoder already drops it and skipping it again put audio 21 ms early. Output stops at the track's duration.detectSpeechData) and Whisper (transcribeData) read the one buffer. There's no FFmpeg WAV on disk, no second decode and no temp cleanup.beamSize: 1is dropped, because whisper.rn turns on beam search for anybeamSize. Same transcripts and 8–15% faster in a local run of the same whisper.cpp; not measured separately on the phones.useGpu: false. whisper.rn defaultsuseGputo true, so the old fallback asked for the GPU again. It only runs if the GPU context fails to load, which hasn't happened in testing; checked by reading whisper.rn's source.Audit of the migrated methods (both platforms)
Each bug below was reproduced against the code before the fix and re-measured after (iOS: pulse-editor's own sources on macOS; Android: the emulator), with flash/click sync fixtures, FFmpeg decodes and the phone test clips.
iOS
rotation180° off for mirrored videos; it now matches Android.Android
Both: errors reach JS as plain messages (Android sent the Kotlin class name and stack trace, iOS Swift's type description). Merge files a killed app left in the cache are deleted after a day.
Emulator / macOS pass before the device run (2026-10-01)
Measured with a temporary on-device bench (not committed) on the iOS Simulator and the Android emulator, and with pulse-editor's iOS sources on macOS, using the new flash/click sync drafts (
+ s6join,+ s7mixed 48 / 44.1 kHz; regenerated without B-frames, like camera recordings, so an edited+ s6takes the selective path).GL_EXT_YUV_target(OpenGL tone mapping needs it; the emulator lacks it). Such a device now reads HDR as SDR (flatter colours) instead of failing; not run on such a device yet (the emulator can't decode 10-bit HEVC at all). HDR on the S24 ran on 2026-10-07 (below).adb logcat -s PulseEditor.On the phones (2026-10-01, iPhone 17 Pro Max + Galaxy S24 Ultra)
Same scenarios on both engines, alternating order, with the flash/click sync drafts measured in FFmpeg (browsers) and AVFoundation (Photos).
On the phones (2026-10-13)
android-s24-compare-1013h-1, debug APK): pulse-editor faster than RNVT on every merge, 0.37–0.71× its time (2-minute join 8.6 vs 23.2 s, 8-minute 41.0 vs 81.2 s, edited draft 4.2 vs 8.2 s); RNVT's own times within −3…+11% of 2026-10-01. Lip sync unchanged: pulse-editor 0.0 ms in both players (2× clips −17.5), RNVT −24…+15.4. A merge cancelled mid-way settled 12 ms after the abort, nothing left;extractAudio51–126× realtime (android-s24-quick-1013g-2).extractAudio's batch settings when the decoder supports it (logcat on the S24:audio decoder: batched (c2.android.aac.decoder, input 64 KB, output 256 KB)). S24 against 2026-10-01: copied drafts 8–29% faster (heavier join test files on 2026-10-13), the 2× draft 28%, other encodes −3…+5%.extractAudio15–43% faster in Release (2-minute draft 391 vs 690 ms). So the debug numbers in Migrate native media work from react-native-video-trim to pulse-editor (engine for the timeline editor) #242 hold for iOS merges and overstate Android join times by about a third.ios-ios-compare-1013): lip sync as on 2026-10-01 (pulse-editor 0.0 ms in both players, 2× draft −25.0; RNVT +27–32 ms in browsers on joins and trims, +496.5 ms on the 2× draft). The phone was slower that day for both engines: joins 1.2–1.9× (pulse-editor) and 1.1–2.3× (RNVT, unchanged code) of 2026-10-01, covers 2.3× and conforms 1.1× of 2026-10-07; the ratios held (pulse-editor's joins 1.3–1.9× RNVT's). Inference: the phone; whether Low Power Mode was on wasn't checked.Also
setSpeedis@ExperimentalApiand wasn't opted in).preservesPitchexplicitly (expo-video's Android player starts with it off).conformconform(uri, { width, height, rotation (clockwise tag), fps, bitrate, audio: { sampleRate, channels }, copyVideo }, { onProgress, signal })→{ uri, durationMs, encoded, bitrate }. The policy stays in Pulse'sdecideImport;conformcarries it out.copyVideore-encodes only the audio.Transformerexport (frame drop to 30, mirror flip, letterbox, a turn into the coded orientation) with the exact tag written on the muxer's format; every Android SDR encode (merge too) now asks for BT.709 limited range.conformToContractcallsconformonce and verifies as before; the import and.pulseunpack gates use it. RNVT'scompressis no longer called.compressin Pulse: on the iOS Simulator both convert to contract; on the Android emulator RNVT's full conversion fails by its own bug (its FFmpeg command picks thempeg4encoder with contradictory frame-rate options), its audio-only one works. On the phones (2026-10-07): iPhone 42 of 42 inputs to contract from both engines, no decode errors, lip sync 0.0–0.1 ms, cancel settled in 377 ms, pulse-editor faster on 33 of 38 (slower on audio-only), 1080p 5–7× realtime, 4K Dolby Vision 1.5×; S24 38 of 38 incl. HLG / PQ / Dolby Vision (the emulator couldn't), lip sync 0.0 ms, cancel settled in 15 ms, 1080p 4–7× realtime, RNVT's full conform fails there by its bug. Found on the S24 (2026-10-07): a corrupt source (export 4.MP4, 73 decode errors on the Mac) came out with 746 of 3424 frames and gaps where iOS conceals; a 23.976 fps HLG clip came out at 26.4 fps and a 4K HEVC one at 29.3 fps, their sources' variable timing kept (the recorder-match check flags the rate; the bench's decode check had misread the timing as duplicate timestamps and was corrected). 2026-10-13: Androidconformnow rejects an output with fewer than 80% of the frames a clean decode gives, counted from the source's sample times through Media3's own frame-drop rule (pulse-editor feat(dev): realistic dev-seed fixtures (Git LFS) + generator #2). S24, the full corpus (android-s24-conform-pe-1013h-1): 34 converted, 7 passed through (the phone's recording, and 6 clips that differ from the recorder only in audio layout, which Android'sdecideImportnow leaves as they are), the corrupt source rejected ("This phone couldn't decode all of the video (746 of 3430 frames)"); HDR levels −10…−65 below the source (the tone map); the two variable-timing clips as on 2026-10-07; lip sync 0.0 ms; cancel settled 5 ms; no level shift on the full-range HEVC screen recording (the emulator's darkening doesn't happen on the phone). With the merged rule (android-s24-conform-pe-1013k-1) the expected count equals the written one on every clean source (a 60 fps clip 600 of 600, the screen recording 645 of 645). iPhone Release (ios-ios-rel-conform-1013, pulse-editor only): 41 inputs, 38 converted and 3 already matching, the same 7 HDR level flags as 2026-10-07, lip sync 0.0 / 0.1 ms, cancel settled 753 ms after the abort (377 on 2026-10-07).thumbnailthumbnail(uri, { timeMs, maxWidth, maxHeight, quality, rotation, flipped, crop })→{ uri, width, height, timeMs }: the exact frame as a JPEG, fitted inside the maximum, with the clip's edit drawn by merge's own geometry (so a cover matches the export) and HDR tone-mapped.AVAssetImageGenerator(zero tolerance) through aMergeGeometryvideo composition. Android: Media3FrameExtractorwith merge's edit effects (+ mirror flip). Pulse'sgenerateThumbnailFileuses it; RNVT'sgetFrameAtis no longer called.android-s24-thumb-1013j-1, the merged code): 37 of 37 covers, every PSNR unchanged; median 15 ms per call, later covers of a file 10–40 ms, a file's first cover 144–516 ms (RNVT 94–517 ms per cover, still failing the < 1 s clip). iPhone Release (ios-ios-rel-thumb-1013): 37 of 37, every PSNR unchanged; 37–849 ms per cover (median 107), with RNVT's times 2.3× slower than 2026-10-07 as well (the phone that day). (The 2026-10-07 counts here said 39; every thumbnail result file holds 37 covers.)<PulsePreview><PulsePreview clips options onStatus onTime onReady />withplay,pause,seek(timeMs)(resolves once that frame is on screen; a newer seek replaces a pending one) andsetScrubbing.clipsareMergeClips andoptionsthe draft'sMergeOptions, so it plays exactly whatmergewould export.snapshot()andstats()are for the bench.Timeline.compose, the composition merge now renders from (split out ofRender; merge unchanged). Android's oneCompositionPlayeris built from merge's per-clip media items and effects. Every clip, copied or rendered, is trimmed to the nearest source frame with a whole-ms length on both platforms (pulse-editor feat: adopt more react-native-video-trim features #12), so trimmed drafts show the export's frames.TextureView, becauseCompositionPlayer's frame callback fires before rotate/crop/letterbox are drawn (with aSurfaceView, 4 of 6 edit screenshots showed the old picture).previewmode): four test clips carrying each frame's number in the picture, three drafts (whole clips, trims inside frames, rotate/flip/crop/speed), every screenshot compared with the export of the same draft:seek()resolved when the frame was decoded, not displayed (3 / 1 / 1 of 20 seek screenshots per draft right at +0 ms, all at +50 ms). A seek is now done when the layer's displayed buffer changes (display-link watch, 40 / 300 ms caps), the video output is attached per item, and a drag reports each landed frame throughonTime.play()the picture and the reported time stood still ~200 ms. Traces:timeControlStatusplaying within 4–5 ms, but the item's timebase kept rate 0 for ~90 ms then ran up from −108 ms —play()'s start "at a host time in the near future" (AVPlayer.h) for media loading that isn't needed on a prepared local item.play()now sets the rate at the current host time: lag 168–206 → 0 ms on every draft, first new frame +249 → +18–49 ms, everything else unchanged. No effect (A/B'd): preroll,playImmediately, activating the audio session. An audio tap saw the first buffer enter the renderer 16–24 ms afterplay()(5–48 withplay()), PTS 0.0 from position 0; sound at the speaker is an ear check on the phone.TextureViewframes carry no timestamp there, so they're matched to Media3's frame callbacks in order; after a drag, released-but-never-drawn frames in the queue made the next edit go unreported (screenshot right,lastSwapMs−1) and the settle seek hit the 3 s timeout. Stale entries (>300 ms) are now dropped before order-matching and the queue cleared on a rebuild: no unreported edit since; the settle timeout still hits 1 of 3 drafts (4 of 7 before).onTimenow reports the on-screen frame's time (picture 100 → 67 ms ahead on the emulator). A chase-seek layer was tried and reverted: ExoPlayer's scrubbing mode already drops intermediate seeks, and the layer cut the drag picture rate 5–8 → 1–2/s. Each landed seek logs its decode/display split and the default decoder, for the S24 run.ios-ios-preview-t3: seeks 79 of 80 on the export's frame, p95 61–63 ms; first frame 56–122 ms; edits 41–92 ms, 8 of 8; 58–60 pictures/s while dragging; 30 fps, none dropped; play starts in 0 ms on every draft (the host-time start confirmed on hardware; traces: first new frame +34–50 ms). Open by ear: after a play straight from a paused seek the first audio buffer reaches a test tap 106–135 ms afterplay()(4–34 after a pause);prerolldoesn't help (cancelled by the play 23 ms later). S24android-s24-preview-1007: seeks 80 of 80, edits 8 of 8, 29–29.6 fps none dropped, first frame 119–481 ms — the frames are right; the speed targets are missed: seek p90 239–281 ms (141 ms median is Media3 decode + composition, 24 ms the view; hardware decoder), 8–10 pictures/s while dragging, edits 288–491 ms, play 118–173 ms late after a paused seek. ItsTextureViewframes carry no timestamp either (matched by order), the settle seek after the trims drag hit the 3 s timeout once, no player-release timeout. Lip sync while playing: not measured on either.ios-ios-rel-preview-1013): seeks 77 of 80 on the export's frame (the 3: the export's sped-up-clip quirk; the preview shows the expected frame), p90 56–64 ms, first frame 61–86 ms, edits 42–99 ms 8 of 8, 54–62 pictures/s while dragging, 30.1–30.2 fps none dropped: in line with Debug on 2026-10-07. First sound after a play (step 0,ios-ios-audio-step0andios-ios-audio-idle-1013, a per-buffer trace of the audio tap): the seek is not the cause (a play right after a seek: first audio +2 ms); an audio output idle for ≥ 5 s is (+116–125 ms after a 10 s pause, +62 after 6 s, +2–9 after 2–4 s), and a freshly built item adds ~30–40 ms. The buffer times say the start is cut (~100–160 ms), not late (inference). pulse-editor Gesture-driven segment bar: hold-to-edit, drag-to-trash, sticky preview #7: a play on a cold output (≥ 5 s since audio last ran or never ran, and the draft has sound) starts its clock 160 ms ahead; the first buffer then arrived 115–126 ms afterplay(), before the clock starts (ios-ios-audio-coldlead-1013b; Releaseios-ios-rel-audio-1013: a 4 s pause no hold, 6 s held). On pulse-editor main (Debug,ios-ios-main-preview-1013, the join and all-muted drafts): seeks 40 of 40, p90 59–64 ms, the 160 ms lead only on the cold plays with sound, every warm play and every play of the all-muted draft 0 ms. By ear next. S24, composition only (android-s24-preview-1013debug APK;android-s24-rel-preview-1013e-1release APK, timings only): seeks 80 of 80 and edits 8 of 8 on the export's frame, 29.0–29.5 fps none dropped, first frame 112–260 ms, edits 245–407 ms; the settle seek after a drag 145–272 ms (was a 3 s timeout); withonTimereporting the frame on screen while paused, restarts read +37–105 ms (were −22…−89). Missed in both builds: seek p90 199–294 ms, 9–13 pictures/s while dragging, play 136–247 ms after a seek or on a first play. Plain ExoPlayer on the same phone (SeekBench, pulse-editor Bump react-native-video-trim to 8.1.4, drop vendored patch #6, debug and release): exact drags 25–27.5 pictures/s, paused seeks p95 115–157 ms, no low-latency decoding onc2.qti.avc.decoder. Drag layer (pulse-editor feat(recorder): running timer + reach-the-ends playhead scrub #10;android-s24-preview-1013o-1, its head, debug APK): a plain ExoPlayer on the dragged clip while a finger moves, everything else on the composition: about 31 seeks landed/s while dragging (composition alone 0.5), a drag into another clip shows it in 63–162 ms, the drag picture matched the composition's frame at the same time in 16 of 16 checked pairs (PSNR ≥ 51.8 dB), settle 120–189 ms with no timeouts, seeks 80 of 80, edits 165–354 ms all showing the edit, 28.7–29.2 fps; paused seeks unchanged (the composition). Tried and left out: paused tap-seeks on the layer (wrong frames and settle timeouts inandroid-s24-preview-1013j-1) and a low-latency AudioTrack (no measurable gain). Play start after a seek on the S24 stays 120–239 ms with or without the layer: from reading Media3 1.11's code (not measured), every seek releases the AudioTrack and the picture waits for the audio clock, which stands still until the new track plays its first sample. Accepted as a Media3 limit (2026-10-14).ios-ios-preview-merged-1013): seeks 78 of 80 on the export's frame (the 2 flagged by the bench as the export's, the expected frame shown), p90 60–64 ms, first frame 54–77 ms, edits 42–66 ms all showing the edit, 58–62 pictures/s while dragging, 30.1–30.2 fps none dropped, the 160 ms lead only on the cold plays with sound: as before the merge. 20 and 40 clips (210.7 s and 418.3 s; trims, a rotation, a crop, 2× and 0.5× clips): iPhone (ios-ios-preview-many-1013) first frame 76–83 ms, edits 60–77 ms all showing the edit, seek p90 64–65 ms, 61 pictures/s while dragging, 30.2 fps none dropped; Pixel 6a (android-pixel-preview-1013-1) first frame 283–314 ms, edits 166–320 ms all showing the edit, seek p90 271–317 ms, 27–31 seeks landed/s while dragging (33–40 pictures/s), 22.2–22.9 fps none dropped, play 91–170 ms after a seek or on a first play. Seeks on the export's frame: iPhone 56 of 68, Pixel 63 of 68. The Pixel's 5 misses are at or just before the start of a clip whose trim starts mid-frame (4: the export still shows the previous clip's last frame); the iPhone's 12 are on the last frames before a join and in the 2× and 0.5× clips (the export's sped-up-clip quirk), and FFmpeg, which the comparison reads the export with, reports 53 / 107 decode warnings in those two iPhone exports (the bench's x264 test clips next to rendered ones, see Known). Where the misses sit is read from the report against each draft's clip layout. Since then the engine snaps every trim to whole frames (pulse-editor feat: adopt more react-native-video-trim features #12, Engine pass 2026-10-14 below). Pixel 6a, the four drafts (android-pixel-preview-1013-2): seeks 80 of 80, first frame 125–516 ms, edits 163–361 ms all showing the edit, seek p90 235–335 ms, 29–30 seeks landed/s while dragging, 19.4–23.5 fps none dropped.File helpers (no more RNVT)
deleteFile→expo-file-system'sFile.delete(import flow).cleanFiles→ anexpo-file-systemsweep at launch of RNVT's leftovertrimmedVideo*files in the documents and caches folders (Simulator: removed them, kept other files; not yet run on Android).saveToDocuments: the export screen's "Save to Files" button is removed; the Share button's sheet offers "Save to Files" on iOS.Main merged in (2026-10-13)
origin/mainat 256e8e8 (app 2.2.4: the UI pass, onboarding tips, universal links, PulseVault 0.6.0) merged in (49bbe38). The 9 conflicts take main's UI and keep this PR's engine side: the pulse-editor merge and its failure copy, the shared progress ring (main's animated sweep moved into it), no "Save to Files", the dev-only bench link inside main's link handler. pulse-editor is pinned to its main, 1ed6cde (3ad1e12); moved to 223acc6 on 2026-10-14 (66d0522), now 5750081 (31193f0; docs since).tsc, lint and the unit tests pass, Android and iOS debug builds succeed, and the iPhone's quick and preview benches read as before the merge (ios-ios-quick-merged-1013: lip sync 0.0–0.1 ms in both players on joins, trims, selective and mixed-rate drafts, 2× −25.0, cancel settled 147 ms;ios-ios-preview-merged-1013, above).Draft data layer for the editor
setClipEdit(segmentId, edit)stores a typed edit in the shapeparseEditreads. The edit's cover is rendered first and the edit and cover are written in one update (889ac37, Edits: a clip's edit and its cover are saved separately and can disagree after a crash #273), so a stopped app never leaves an edit with another edit's cover; per clip only the edit or revert asked for last is written. Revert (resetEdit) does the same with the pristine cover. File deletes after a committed save can't fail the save.transaction()commits when its callback returns, so the awaited statements inaddSegment,reorderSegmentsandinsertImportedDraftran after the commit and a throw rolled nothing back. Their callbacks are now synchronous, so each commits or rolls back whole.mergeOptions()(075c0bf): the export'sMergeOptionscome from one builder, so the preview can pass the exact object the export merges with. No behaviour change.dbcheck, iPhone 17 Pro Maxios-ios-dbcheck-1013and Pixel 6aandroid-pixel-dbcheck-1013, real SQLite): adds (2 awaited, then 4 at once) numbered 1–6 in order; two racing reorders end in the later request and an awaited one after them in its order, with no unique-constraint errors; a burst of 4 edits stores the last with one cover; set→Revert and Revert→set, 50 ms apart and at once, end in the later call's state with no leftover covers; an import that hits a unique-constraint error leaves no draft or clip rows; the options builder gives the bench's options. 10 of 11 steps pass on both; the 11th, the import step, fails on the bench's own check that the imported clips' files exist (file: false), while its rollback and delete checks pass.Engine pass 2026-10-14
Debug builds on the iPhone 17 Pro Max and the Pixel 6a (Android 17 beta). pulse-editor is pinned to its main, 5750081 (31193f0): 223acc6 (66d0522) for #12 and #14, then the README and docs rewrite (pulse-editor #15, #16).
CompositionPlayer.seekTotakes whole ms).sync-select4 → 0. The trims + edits export 27.400 → 27.383 s (the timeline). Cost:sync-select3.7 → 5.6 s.preview, seeks whose screenshot equals the export's frame): Pixel join / trims / edits / mute 20 of 20 each (trims was 13 with whole frames but fractional lengths), 20 clips 30 of 30 (28), 40 clips 38 of 38 (30), trims + edits 17 of 20, odd-length join 20 of 20. iPhone 20 / 20 / 19 / 20, 20 clips 26–27 of 30, 40 clips 38 of 38, trims + edits 16 of 20 (was 13), odd-length join 20 of 20. Every remaining miss is in a 2× clip (±1 frame, accepted).oddjoin: 11966.667 / 11925.333 / 11900 / 11866.667 ms): the Pixel export starts its clips at 11.966 / 23.891 / 35.791 s, the preview's slots; the iPhone's at 11.966 / 23.866 / 35.766 s. iOS cuts an untrimmed clip at its video track's end, Android at the file's (one clip's audio is 25 ms longer), so slot lengths can differ across platforms by a recording's A/V gap; each matches its own export.framesDroppedis counted. Pixel Perfetto trace: the view voteshigh(749 times), never 30, but the display still drops to 30 Hz in stretches;joinplays at 24.1 fps (19.4–22.7 without). Waits for an S24 run.Timeline editor (2026-10-14, 2bcc68f; pin 2406c00; 85a1eb4–1af6ac9)
A clip tapped in the recorder opens
/editorpaused at that clip's start, nothing selected; the recorder's Edit button (left of the record button, opposite +, with a one-time tip) opens it from the draft's start (c4b8728). Export (top right on the recorder and in the editor) opens the export screen, so a draft can be finished with or without editing; it replaces the recorder's → at the end of the clip bar (c4b8728). The editor replaces the in-recorder clip preview and RNVT's per-clip editor, both removed (d7e235d).<PulsePreview>on top; one fixed centre playhead over the clips in two views, switched by an icon pill next to play and remembered across sessions: Clips (thumbnails, the recorder's look) and Timeline (each clip its timeline length: a cover filmstrip and a thin-line peak/RMS waveform fromextractAudio, cached per file). Clips show their edits at a glance (speed, rotate, flip, crop, mute).react-native-sortablesin the Clips view only: hold a thumbnail and drag it, and it's inserted where it's dropped (the clips it passes shift over; the recorder's bar does the same, 31b999c); the dragged clip is lifted above the screen through its portal. The timeline has no hold (a touch there scrubs, taps or trims). Moving a clip in the same touch as a timeline hold, by driving sortables' drag handlers from the strip's gesture, was tried and removed (d7845ab): each timing gap between the two gestures was a new bug on the iPhone. The recorder's clip bar keeps its clips while the editor covers it and is rebuilt on return if they changed (0e0ae71): a reorder applied to it off screen left a thumbnail missing or clips stuck in reorder mode (iPhone, fixed by hand-check).<PulsePreview>'s newclipStartsMs(pulse-editor feat: persist recorder camera preferences across launches #17, Pixel:[0, 12000, 24000, 36000]→[0, 8000, 20000, 32000]after a 1.5× edit); on iOS an edit no longer reports time 0 while the rebuilt timeline swaps in, and a seek during the swap waits for it (pulse-editor feat: draft transfer via .pulse export/import #18; iPhone, by hand: an edit while playing keeps the playhead going, a clip tapped right after an edit lands on its start).Verified
tsc, lint, 288 unit tests (22 skipped), at 075c0bf. The gatedPULSE_E2E=1import pipeline test (it replayed RNVT's FFmpeg command line) was removed in 0347bc6.extractAudio80–180 ms, VAD 128 ms, Whisper base.en 123 ms on the GPU.extractAudio0.4–0.8 s, VAD 0.2 s, Whisper on the CPU 1.5 s (whisper.rn 0.7 has no Android GPU backend).extractAudiocode run on macOS with real iPhone recordings;extractAudio's PCM matches an FFmpeg reference decode within 0.1 ms;Left before merging
Known
conformdoesn't pad frames: a 24 fps or variable-rate import stays variable, 29.97 stays 29.97 (iOS gives a constant 30). Both pass the import contract and the recorder match.thumbnailon the S24: the first cover of a file takes 144–516 ms (the extractor opens the file), the next covers of that file 10–40 ms (2026-10-13).minFrameDurationon iOS, the average rate on Android, the same for constant-rate recordings; not run on recordings with variable frame timing). An untrimmed clip ends at its video track's end on iOS and at the file's on Android, so the same draft's clips can start a recording's A/V gap apart across platforms (25 ms inoddjoin); each platform's preview matches its own export.<PulsePreview>on the S24 (2026-10-13): paused seeks p90 199–294 ms and play 120–247 ms after a seek or on a first play (10–120 ms after a pause), accepted as Media3 limits (2026-10-14, below); drags about 31 seeks landed/s on the drag layer (9–13 pictures/s on the composition alone).TextureViewframes carry no timestamp (matched to Media3's frame callbacks in order). iPhone: a cold play with sound (≥ 5 s without audio, or the first) waits 160 ms before the picture moves, so its first sound isn't cut (by ear next).extractAudioon Opus comes out ~300 ms short at the start (the platform decoder); Pulse doesn't read Opus there (imports convert it to AAC).