@flow-player/software-decoder-ffmpeg 0.6.3 → 0.7.1
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.
|
@@ -25,7 +25,7 @@ var init_ffdecoder_assets = __esm({
|
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
-
// src/ffmpeg-software-decoder-adapter.ts
|
|
28
|
+
// ../../packages/software-decoder-ffmpeg/src/ffmpeg-software-decoder-adapter.ts
|
|
29
29
|
var FfmpegSimdSoftwareDecoder = class {
|
|
30
30
|
#closed = false;
|
|
31
31
|
#configured = false;
|
|
@@ -226,7 +226,11 @@ var FfmpegSimdSoftwareDecoder = class {
|
|
|
226
226
|
async function loadFfmpegAssets() {
|
|
227
227
|
return await Promise.resolve().then(() => (init_ffdecoder_assets(), ffdecoder_assets_exports));
|
|
228
228
|
}
|
|
229
|
-
function resolveSoftwareDecoderWasmUrl() {
|
|
229
|
+
function resolveSoftwareDecoderWasmUrl(options) {
|
|
230
|
+
const explicit = options.wasmUrl;
|
|
231
|
+
if (typeof explicit === "string" && explicit.length > 0) {
|
|
232
|
+
return explicit;
|
|
233
|
+
}
|
|
230
234
|
const url = globalThis.__FLOW_PLAYER_SOFTWARE_DECODER_WASM_URL__;
|
|
231
235
|
if (typeof url !== "string" || url.length === 0) {
|
|
232
236
|
throw new Error(
|
|
@@ -248,9 +252,9 @@ async function instantiateFfmpegWasm(url, imports) {
|
|
|
248
252
|
const { instance } = await WebAssembly.instantiate(bytes, imports);
|
|
249
253
|
return instance;
|
|
250
254
|
}
|
|
251
|
-
async function loadFfmpegSimdModule() {
|
|
255
|
+
async function loadFfmpegSimdModule(options) {
|
|
252
256
|
const { glueText: glueText2 } = await loadFfmpegAssets();
|
|
253
|
-
const wasmUrl = resolveSoftwareDecoderWasmUrl();
|
|
257
|
+
const wasmUrl = resolveSoftwareDecoderWasmUrl(options);
|
|
254
258
|
const loader = new Function(
|
|
255
259
|
"Module",
|
|
256
260
|
"module",
|
|
@@ -302,12 +306,13 @@ return module.exports;`
|
|
|
302
306
|
return module;
|
|
303
307
|
}
|
|
304
308
|
async function createSoftwareVideoDecoder(options) {
|
|
305
|
-
const module = await loadFfmpegSimdModule();
|
|
309
|
+
const module = await loadFfmpegSimdModule(options);
|
|
306
310
|
return new FfmpegSimdSoftwareDecoder(module, options);
|
|
307
311
|
}
|
|
308
312
|
var ffmpeg_software_decoder_adapter_default = { createSoftwareVideoDecoder };
|
|
309
313
|
export {
|
|
310
314
|
FfmpegSimdSoftwareDecoder,
|
|
311
315
|
createSoftwareVideoDecoder,
|
|
312
|
-
ffmpeg_software_decoder_adapter_default as default
|
|
316
|
+
ffmpeg_software_decoder_adapter_default as default,
|
|
317
|
+
resolveSoftwareDecoderWasmUrl
|
|
313
318
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -19,6 +19,11 @@
|
|
|
19
19
|
* 运行时经 softwareDecoderWasmUrl fetch wasm(instantiateStreaming,MIME 不支持
|
|
20
20
|
* 时回退 arrayBuffer + instantiate)。零 base64 内联:网络体积与解码开销均按
|
|
21
21
|
* 真实 wasm 资产路径走。
|
|
22
|
+
*
|
|
23
|
+
* adapter 的 `createSoftwareVideoDecoder` options 支持可选 `wasmUrl`(显式
|
|
24
|
+
* 传参,runtime R4 起优先使用);未提供时回退 deprecated 全局兜底
|
|
25
|
+
* `globalThis.__FLOW_PLAYER_SOFTWARE_DECODER_WASM_URL__`(老版 runtime
|
|
26
|
+
* 兼容,计划下个次版本移除)。
|
|
22
27
|
*/
|
|
23
28
|
/** 软解 adapter 产物 URL(对应 FlowPlayerRuntimeOptions.softwareDecoderUrl)。 */
|
|
24
29
|
export declare const softwareDecoderUrl: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//
|
|
1
|
+
// ../../packages/browser-runtime/src/worker/protocol.ts
|
|
2
2
|
var WORKER_MESSAGE = Object.freeze({
|
|
3
3
|
Init: "init",
|
|
4
4
|
Play: "play",
|
|
@@ -11,11 +11,38 @@ var WORKER_MESSAGE = Object.freeze({
|
|
|
11
11
|
SetBufferTime: "set-buffer-time",
|
|
12
12
|
SetRate: "set-rate",
|
|
13
13
|
SetPlaybackDirection: "set-playback-direction",
|
|
14
|
-
QueryGopRange: "query-gop-range",
|
|
15
14
|
Seek: "seek",
|
|
16
15
|
Destroy: "destroy",
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
SetVisualFrameSink: "set-visual-frame-sink",
|
|
17
|
+
// 以下为历史裸字符串消息的收编(wire 值保持原字符串不变,双向兼容)。
|
|
18
|
+
/** 主线程 → worker:转移 OffscreenCanvas。 */
|
|
19
|
+
AttachCanvas: "attach-canvas",
|
|
20
|
+
/** 主线程 → worker:fMP4 分片(历史别名,等价 PushChunk 的 fmp4 路径)。 */
|
|
21
|
+
PushFmp4Chunk: "push-fmp4-chunk",
|
|
22
|
+
/** 主线程 → worker:MP4 分片(历史别名,等价 PushChunk 的 mp4 路径)。 */
|
|
23
|
+
PushMp4Chunk: "push-mp4-chunk",
|
|
24
|
+
/** 主线程 → worker:带字节偏移的 MP4 range 分片。 */
|
|
25
|
+
PushMp4Range: "push-mp4-range",
|
|
26
|
+
/** 主线程 → worker:MP4 flush(历史别名,等价 Flush 的 mp4 路径)。 */
|
|
27
|
+
FlushMp4: "flush-mp4",
|
|
28
|
+
/** 主线程 → worker:MP4 增量 flush。 */
|
|
29
|
+
FlushMp4Incremental: "flush-mp4-incremental",
|
|
30
|
+
/** 主线程 → worker:MP4 输入结束(触发 playback-ended 判定)。 */
|
|
31
|
+
Mp4InputComplete: "mp4-input-complete",
|
|
32
|
+
/** 主线程 → worker:查询 keyframe 字节偏移(响应 KeyframeOffset)。 */
|
|
33
|
+
QueryKeyframeOffset: "query-keyframe-offset",
|
|
34
|
+
/** worker → 主线程:QueryKeyframeOffset 的响应。 */
|
|
35
|
+
KeyframeOffset: "keyframe-offset",
|
|
36
|
+
/** 主线程 → worker:查询 precise seek 偏移(响应 PreciseSeekOffset)。 */
|
|
37
|
+
QueryPreciseSeekOffset: "query-precise-seek-offset",
|
|
38
|
+
/** worker → 主线程:QueryPreciseSeekOffset 的响应。 */
|
|
39
|
+
PreciseSeekOffset: "precise-seek-offset",
|
|
40
|
+
/** worker → 主线程:播放方向切换通知(SetPlaybackDirection 的确认)。 */
|
|
41
|
+
DirectionChange: "directionchange",
|
|
42
|
+
/** worker → 主线程:倒放/倍速导致音频被抑制的通知。 */
|
|
43
|
+
AudioSuppressed: "audio-suppressed",
|
|
44
|
+
/** worker → 主线程:倒放 GOP 缓冲重置通知(resetGopState)。 */
|
|
45
|
+
ReverseGopReset: "reverse-gop-reset"
|
|
19
46
|
});
|
|
20
47
|
var SOFTWARE_DECODE_WORKER_MESSAGE = Object.freeze({
|
|
21
48
|
/** in: import 适配器并创建解码器。 */
|
|
@@ -56,7 +83,7 @@ var MSE_WORKER_MESSAGE = Object.freeze({
|
|
|
56
83
|
Ack: "mse-ack"
|
|
57
84
|
});
|
|
58
85
|
|
|
59
|
-
//
|
|
86
|
+
// ../../packages/browser-runtime/src/worker/software-decode-worker.ts
|
|
60
87
|
var decoder = null;
|
|
61
88
|
var inflight = Promise.resolve();
|
|
62
89
|
var FRAME_BUFFER_POOL_CAPACITY = 3;
|
|
@@ -149,7 +176,8 @@ self.onmessage = (event) => {
|
|
|
149
176
|
onError: (error) => {
|
|
150
177
|
post({ type: SOFTWARE_DECODE_WORKER_MESSAGE.Error, message: String(error) });
|
|
151
178
|
},
|
|
152
|
-
acquireFrameBuffers: acquireFrameBuffersWithActivation
|
|
179
|
+
acquireFrameBuffers: acquireFrameBuffersWithActivation,
|
|
180
|
+
wasmUrl: message.wasmUrl
|
|
153
181
|
});
|
|
154
182
|
post({ type: SOFTWARE_DECODE_WORKER_MESSAGE.Ready });
|
|
155
183
|
startWasmMemoryReporting();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flow-player/software-decoder-ffmpeg",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "FFmpeg (ffdecoder) WASM software decode backend for @flow-player/browser-runtime: prebuilt adapter + decode worker, drop-in HEVC software decoding.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"esm",
|
|
@@ -34,6 +34,6 @@
|
|
|
34
34
|
"tag": "latest"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@flow-player/browser-runtime": "^0.
|
|
37
|
+
"@flow-player/browser-runtime": "^0.7.1"
|
|
38
38
|
}
|
|
39
39
|
}
|