libav-wasm 0.8.3 → 0.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -30,7 +30,7 @@ Timestamps are reported relative to the start of the content, so a format whose
30
30
  import { makeRemuxer } from 'libav-wasm'
31
31
 
32
32
  const remuxer = await makeRemuxer({
33
- // where libav.wasm is served from
33
+ // where libav.wasm AND libav-jspi.wasm are served from; the worker picks one at runtime
34
34
  publicPath: new URL('/dist/', new URL(import.meta.url).origin).toString(),
35
35
  workerUrl: new URL('../build/worker.js', import.meta.url).toString(),
36
36
  workerOptions: { type: 'module' },
@@ -45,7 +45,7 @@ const { data, info, indexes, subtitles, attachments, chapters } = await remuxer.
45
45
  const codecs = [info.output.videoMimeType, info.output.audioMimeType].filter(Boolean).join(',')
46
46
  const mime = `video/mp4; codecs="${codecs}"`
47
47
 
48
- // { data, pts, duration, offset, finished } — data appends straight to a SourceBuffer
48
+ // { data, pts, duration, offset, finished }: data appends straight to a SourceBuffer
49
49
  const chunk = await remuxer.read()
50
50
 
51
51
  // rebuilds the muxer and starts again from the keyframe at or before this timestamp
@@ -64,6 +64,21 @@ cannot follow, and a thumbnailer has no muxer to damage.
64
64
  the library and the worker, and emits types. Only the last step re-runs when you touch C++, so the loop is
65
65
  about 25 seconds.
66
66
 
67
+ ### Two builds, one source
68
+
69
+ `make` emits **both** `libav.wasm` and `libav-jspi.wasm`, and the worker picks between them at runtime on
70
+ `typeof WebAssembly.Suspending === 'function'`. **Both files have to be reachable at `publicPath`**, since
71
+ the choice happens in the browser rather than at build time.
72
+
73
+ The JSPI build lets the engine switch stacks, so nothing is instrumented: it remuxes the same file in
74
+ 549.3ms against the Asyncify build's 641.5ms, and its wasm is 2.2 MB smaller. Chrome and Edge have had JSPI
75
+ since 137 and Firefox since 153; Safari has none, and iOS is Safari whatever the badge says, which is the
76
+ whole reason the Asyncify build still ships.
77
+
78
+ The Chrome-only suite would exercise JSPI and nothing else, so `tests/no-jspi-worker.js` blanks the
79
+ constructor before the worker evaluates and the `without JSPI` tests run the fallback for real. They assert
80
+ byte-identical output, not merely "it ran".
81
+
67
82
  ## Tests
68
83
 
69
84
  `npm test` runs a browser suite against fixtures it synthesizes with ffmpeg on first run. Nothing is
@@ -93,6 +108,15 @@ For C++ autocompletion, clone into the repo root:
93
108
  - `sourceBuffer.timestampOffset` with always-increasing timestamps, to avoid re-initialising on a backwards seek
94
109
  - video transcoding, the only thing that would make mpeg2, mpeg4 part 2 and theora playable
95
110
  - audio codec reference: https://cconcolato.github.io/media-mime-support/#audio_codecs
111
+ - `getIndexes()` on the remuxer, re-running the same keyframe walk `init` does, so the index can grow
112
+ as `read()` demuxes. `indexes` is the container's declared index rather than a scan, so a file with
113
+ no Cues comes back with about two entries and no way to tell that apart from a short file. Measured
114
+ on three 38MB matroska files differing only in Cues placement: at the front, 20 entries; at the end,
115
+ the same 20 at the cost of one read at the tail; with no Cues at all, 2. The C++ already has the
116
+ walk in `init` and `initThumbnail`, so the plumbing is small. **Not planned**, on two findings since:
117
+ `seek()` calls `destroy_input()`, so every accumulated entry is discarded on each seek and rebuilt
118
+ from Cues alone; and `Index.index` is the loop counter over the full AVIndexEntry array rather than a
119
+ keyframe ordinal, which matroska inserts into in timestamp order, so it shifts between calls.
96
120
 
97
121
  <!-- https://www.ffmpeg.org/doxygen/trunk/remuxing_8c-example.html -->
98
122
  <!-- https://github.com/leandromoreira/ffmpeg-libav-tutorial -->
Binary file
package/build/libav.wasm CHANGED
Binary file