Batch FFmpeg decoder
Batch FFmpeg decoder
Pinned package: @ffmpeg/core 0.12.10, official single-thread browser build. Distribution: https://registry.npmjs.org/@ffmpeg/core/-/core-0.12.10.tgz Upstream release: https://github.com/ffmpegwasm/ffmpeg.wasm/releases/tag/v12.15 Source/build recipes and dependency references: https://github.com/ffmpegwasm/ffmpeg.wasm/tree/v12.15 License: GPL-2.0-or-later; see COPYING.GPLv2.txt. ffmpeg-core.mjs is the unmodified dist/esm/ffmpeg-core.js with an ESM extension.
Every video is decoded automatically after native metadata loads, independently of Plotly and Rust barcode initialization. Update Barcodes reuses that cache.
The selected local File/Blob is mounted read-only using WORKERFS. The sample is fetched from this site. One FFmpeg command writes every decoded frame, in presentation order, into /frames.gray (raw full-range grayscale). No FPS filter, frame cap, padding, or video upload is used. Frame count is derived from byte length divided by width * height, rather than the inspector’s assumed FPS.
After decoding, readFile obtains the full grayscale array; the filesystem copy is deleted and the input unmounted. The array remains cached in the per-video worker. Rust receives the complete array, thresholds gray >= threshold into 0/1, and computes the eight barcode collections. Threshold/FPS changes do not decode again. File replacement, release, or page reload terminates the worker and drops all caches and both WASM runtimes. No video or barcode data is stored in OPFS, IndexedDB, or localStorage. The page separately remembers only its demo-notice dismissal in localStorage.
This intentionally uses whole-video RAM, including temporary readFile and WASM copies. A 640x360, 300-frame grayscale dump is 69.12 MB, before copies and binary buffers. The single-thread core needs no SharedArrayBuffer or isolation headers.
The binary preview buffers two small batches of the same cached grayscale array, never a browser RGB-to-gray conversion. Batches contain up to 16 frames and at most 4 MiB (or one frame if larger). The next batch is prefetched two frames before the current one ends. Worker transfers copy only those batches and leave the whole-video cache intact. Threshold changes apply to the displayed cached frame immediately; previews remain visible while delayed batches arrive. Until decoding completes the binary panel shows a placeholder. FFmpeg’s showinfo filter records presentation timestamps in the same decoding pass. After decoding, the slider steps through actual frame indices and playback selects cached frames by those timestamps; assumed FPS is only used before decoding. Native color video seeking can still be approximate. Endpoint values retain zigzag level indices: source frames at 2i, compositions at 2i+1.
SHA-256:
- ffmpeg-core.mjs: 67a48f11645f85439f3fde4f2119042c16b374b910206b7a7a24f342e28dcae3
- ffmpeg-core.wasm: 9f57947a5bd530d8f00c5b3f2cb2a3492faa7e5d823315342d6a8656d0a6b7b7