@uploadfilm/sdk 0.0.0-stage → 0.1.0
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/LICENSE +4 -0
- package/README.md +509 -2
- package/dist/ai/embed.d.ts +58 -0
- package/dist/ai/fake.d.ts +41 -0
- package/dist/ai/http.d.ts +17 -0
- package/dist/ai/index.d.ts +27 -0
- package/dist/ai/languages.d.ts +2 -0
- package/dist/ai/ollama.d.ts +23 -0
- package/dist/ai/openaiCompatible.d.ts +54 -0
- package/dist/ai/passages.d.ts +28 -0
- package/dist/ai/transcribe.d.ts +84 -0
- package/dist/ai/types.d.ts +141 -0
- package/dist/ai/usage.d.ts +66 -0
- package/dist/ai/whisperJson.d.ts +15 -0
- package/dist/ai/workersAi.d.ts +56 -0
- package/dist/ai.js +1 -0
- package/dist/ai.mjs +1 -0
- package/dist/cards/files.d.ts +91 -0
- package/dist/cards/index.d.ts +15 -0
- package/dist/cards/layouts.d.ts +121 -0
- package/dist/cards/probe.d.ts +69 -0
- package/dist/cards/proxies.d.ts +70 -0
- package/dist/cards/select.d.ts +68 -0
- package/dist/cards/volumes.d.ts +170 -0
- package/dist/cards/xml.d.ts +80 -0
- package/dist/cards.js +1 -0
- package/dist/cards.mjs +1 -0
- package/dist/copy/checksums.d.ts +66 -0
- package/dist/copy/engine.d.ts +24 -0
- package/dist/copy/errors.d.ts +109 -0
- package/dist/copy/index.d.ts +15 -0
- package/dist/copy/steps.d.ts +28 -0
- package/dist/copy/sweep.d.ts +24 -0
- package/dist/copy/types.d.ts +336 -0
- package/dist/embed/player.js +2 -0
- package/dist/host/adapters.d.ts +107 -0
- package/dist/host/detect.d.ts +68 -0
- package/dist/host/encoders.d.ts +34 -0
- package/dist/host/environment.d.ts +53 -0
- package/dist/host/index.d.ts +20 -0
- package/dist/host/linux.d.ts +94 -0
- package/dist/host/mac.d.ts +47 -0
- package/dist/host/network.d.ts +54 -0
- package/dist/host/node.d.ts +13 -0
- package/dist/host/policy.d.ts +101 -0
- package/dist/host/tuner.d.ts +48 -0
- package/dist/host/types.d.ts +118 -0
- package/dist/host-node.js +1 -0
- package/dist/host-node.mjs +1 -0
- package/dist/host.js +1 -0
- package/dist/host.mjs +1 -0
- package/dist/images/index.d.ts +11 -0
- package/dist/images/settings.d.ts +43 -0
- package/dist/images/types.d.ts +83 -0
- package/dist/images/url.d.ts +65 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/dist/player/adapters/hlsjs.d.ts +28 -0
- package/dist/player/bandwidthMemory.d.ts +28 -0
- package/dist/player/captions/index.d.ts +55 -0
- package/dist/player/embed/code.d.ts +195 -0
- package/dist/player/embed/constants.d.ts +4 -0
- package/dist/player/embed/controller.d.ts +62 -0
- package/dist/player/embed/element.d.ts +32 -0
- package/dist/player/embed/frame.d.ts +65 -0
- package/dist/player/embed/global.d.ts +14 -0
- package/dist/player/embed/index.d.ts +15 -0
- package/dist/player/embed/loader.d.ts +1 -0
- package/dist/player/embed/oembed.d.ts +74 -0
- package/dist/player/embed/protocol.d.ts +64 -0
- package/dist/player/engine.d.ts +215 -0
- package/dist/player/index.d.ts +18 -0
- package/dist/player/start.d.ts +62 -0
- package/dist/player/store.d.ts +10 -0
- package/dist/player/storyboard/index.d.ts +161 -0
- package/dist/player/stream.d.ts +206 -0
- package/dist/player/tracks.d.ts +41 -0
- package/dist/player.js +1 -0
- package/dist/player.mjs +1 -0
- package/dist/proxies/args.d.ts +19 -0
- package/dist/proxies/budget.d.ts +57 -0
- package/dist/proxies/camera.d.ts +104 -0
- package/dist/proxies/formats.d.ts +36 -0
- package/dist/proxies/index.d.ts +18 -0
- package/dist/proxies/jobs.d.ts +98 -0
- package/dist/proxies/node.d.ts +32 -0
- package/dist/proxies/plan.d.ts +89 -0
- package/dist/proxies/probe.d.ts +39 -0
- package/dist/proxies/render.d.ts +104 -0
- package/dist/proxies/safety.d.ts +45 -0
- package/dist/proxies/types.d.ts +83 -0
- package/dist/proxies/upload.d.ts +14 -0
- package/dist/react/BigPlay.d.ts +26 -0
- package/dist/react/Player.d.ts +58 -0
- package/dist/react/embed/index.d.ts +45 -0
- package/dist/react/examples/CustomControls.d.ts +8 -0
- package/dist/react/images/Image.d.ts +16 -0
- package/dist/react/images/index.d.ts +4 -0
- package/dist/react/images/useImage.d.ts +47 -0
- package/dist/react/index.d.ts +17 -0
- package/dist/react/storyboard/index.d.ts +58 -0
- package/dist/react/theme.d.ts +37 -0
- package/dist/react/useAdapterErrors.d.ts +8 -0
- package/dist/react/usePlaybackStart.d.ts +18 -0
- package/dist/react/usePlayer.d.ts +28 -0
- package/dist/react/useReducedMotion.d.ts +2 -0
- package/dist/react/useTimedTrack.d.ts +22 -0
- package/dist/react.js +1 -0
- package/dist/react.mjs +1 -0
- package/dist/server/auth/apiKeys.d.ts +30 -0
- package/dist/server/auth/cache.d.ts +21 -0
- package/dist/server/auth/deviceTokens.d.ts +38 -0
- package/dist/server/auth/envelope.d.ts +15 -0
- package/dist/server/auth/grants.d.ts +76 -0
- package/dist/server/auth/index.d.ts +19 -0
- package/dist/server/auth/jwt.d.ts +65 -0
- package/dist/server/auth/keyring.d.ts +31 -0
- package/dist/server/auth/kv.d.ts +12 -0
- package/dist/server/auth/repository.d.ts +45 -0
- package/dist/server/auth/revocations.d.ts +21 -0
- package/dist/server/auth/scope.d.ts +4 -0
- package/dist/server/auth/serviceAuth.d.ts +24 -0
- package/dist/server/auth/signedUrls.d.ts +28 -0
- package/dist/server/embed/index.d.ts +36 -0
- package/dist/server/embed/lifecycle.d.ts +53 -0
- package/dist/server/embed/playerScript.d.ts +4 -0
- package/dist/server/images/index.d.ts +15 -0
- package/dist/server/images/job.d.ts +80 -0
- package/dist/server/images/layout.d.ts +24 -0
- package/dist/server/images/params.d.ts +90 -0
- package/dist/server/images/route.d.ts +101 -0
- package/dist/server/images/sign.d.ts +55 -0
- package/dist/server/index.d.ts +42 -0
- package/dist/server/media/client.d.ts +66 -0
- package/dist/server/media/frameCheck.d.ts +62 -0
- package/dist/server/media/index.d.ts +10 -0
- package/dist/server/media/protocol.d.ts +318 -0
- package/dist/server/media/storyboard.d.ts +144 -0
- package/dist/server/media/transcript.d.ts +143 -0
- package/dist/server/pipeline/index.d.ts +12 -0
- package/dist/server/pipeline/match.d.ts +10 -0
- package/dist/server/pipeline/pipeline.d.ts +182 -0
- package/dist/server/pipeline/queues.d.ts +108 -0
- package/dist/server/pipeline/sources.d.ts +54 -0
- package/dist/server/r2/client.d.ts +150 -0
- package/dist/server/r2/crc32.d.ts +24 -0
- package/dist/server/r2/encoding.d.ts +35 -0
- package/dist/server/r2/errors.d.ts +9 -0
- package/dist/server/r2/integrity.d.ts +25 -0
- package/dist/server/r2/parts.d.ts +46 -0
- package/dist/server/r2/sign.d.ts +47 -0
- package/dist/server/redis/index.d.ts +39 -0
- package/dist/server/state/memory.d.ts +18 -0
- package/dist/server/state/r2.d.ts +73 -0
- package/dist/server/state/types.d.ts +57 -0
- package/dist/server/storage/chunked.d.ts +21 -0
- package/dist/server/storage/index.d.ts +12 -0
- package/dist/server/storage/r2.d.ts +96 -0
- package/dist/server/storage/s3.d.ts +93 -0
- package/dist/server/testing/fake-r2.d.ts +390 -0
- package/dist/server/testing/index.d.ts +10 -0
- package/dist/server/testing/kv-contract.d.ts +14 -0
- package/dist/server/transfer/handler.d.ts +167 -0
- package/dist/server/transfer/keys.d.ts +45 -0
- package/dist/server/transfer/protocol.d.ts +141 -0
- package/dist/server/zip/client.d.ts +32 -0
- package/dist/server/zip/generations.d.ts +83 -0
- package/dist/server/zip/index.d.ts +12 -0
- package/dist/server/zip/planner.d.ts +94 -0
- package/dist/server/zip/sign.d.ts +22 -0
- package/dist/server-media.js +1 -0
- package/dist/server-media.mjs +1 -0
- package/dist/server-redis.js +1 -0
- package/dist/server-redis.mjs +1 -0
- package/dist/server-testing.js +1 -0
- package/dist/server-testing.mjs +1 -0
- package/dist/server.js +1 -0
- package/dist/server.mjs +1 -0
- package/dist/storage/browserFile.d.ts +19 -0
- package/dist/storage/index.d.ts +12 -0
- package/dist/storage/local.d.ts +9 -0
- package/dist/storage/presigned.d.ts +22 -0
- package/dist/sync/ffmpeg.d.ts +44 -0
- package/dist/sync/index.d.ts +17 -0
- package/dist/sync/match.d.ts +28 -0
- package/dist/sync/probe.d.ts +30 -0
- package/dist/sync/timecode.d.ts +50 -0
- package/dist/sync/transcript.d.ts +35 -0
- package/dist/sync/types.d.ts +172 -0
- package/dist/sync/waveform.d.ts +89 -0
- package/dist/sync.js +1 -0
- package/dist/sync.mjs +1 -0
- package/dist/transfer/claims.d.ts +41 -0
- package/dist/transfer/client.d.ts +256 -0
- package/dist/transfer/download.d.ts +192 -0
- package/dist/transfer/engine.d.ts +382 -0
- package/dist/transfer/errors.d.ts +50 -0
- package/dist/transfer/index.d.ts +39 -0
- package/dist/transfer/integrity.d.ts +93 -0
- package/dist/transfer/limits.d.ts +34 -0
- package/dist/transfer/node.d.ts +63 -0
- package/dist/transfer/pool.d.ts +83 -0
- package/dist/transfer/protocol.d.ts +167 -0
- package/dist/transfer/signer.d.ts +29 -0
- package/dist/transfer/storage.d.ts +110 -0
- package/dist/transfer/timing.d.ts +132 -0
- package/dist/transfer/transports/electronNet.d.ts +62 -0
- package/dist/transfer/transports/fetch.d.ts +15 -0
- package/dist/transfer/transports/retryAfter.d.ts +12 -0
- package/dist/transfer/transports/undici.d.ts +72 -0
- package/dist/transfer/tuner.d.ts +56 -0
- package/dist/zip/index.d.ts +13 -0
- package/dist/zip/layout.d.ts +129 -0
- package/dist/zip/names.d.ts +34 -0
- package/dist/zip/plan.d.ts +115 -0
- package/dist/zip/sw.d.ts +7 -0
- package/package.json +265 -4
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The proxy job journal and queue: which clips need a light proxy, what is rendering, what is proven and ready, and
|
|
3
|
+
* what failed for good. It survives a kill: every state change is saved before it matters (the store writes atomically),
|
|
4
|
+
* a render the journal says was running when the process died is cleaned up at the next start (its own ffmpeg killed,
|
|
5
|
+
* only if it is still exactly that process, and its temporary file removed) and queued again without counting as a
|
|
6
|
+
* failure. A proxy marked ready is used only while its file is still the size the render proved and its record was
|
|
7
|
+
* made by this pipeline version for this revision of the clip.
|
|
8
|
+
*
|
|
9
|
+
* Losing any of this loses no footage: proxies are derived files, and nothing here is read by "safe to clear".
|
|
10
|
+
*/
|
|
11
|
+
import type { BudgetVerdict } from "./budget";
|
|
12
|
+
import type { ProxyPlan } from "./plan";
|
|
13
|
+
import { type RenderResult } from "./render";
|
|
14
|
+
import { type FileStamp } from "./types";
|
|
15
|
+
/** Bump when the light proxy's recipe changes: records of an older recipe are rendered again. */
|
|
16
|
+
export declare const PROXY_PIPELINE_VERSION = "light-1";
|
|
17
|
+
export type ProxyJobState = "queued" | "rendering" | "ready" | "failed";
|
|
18
|
+
export interface ProxyJobRecord {
|
|
19
|
+
id: string;
|
|
20
|
+
/**
|
|
21
|
+
* The clip revision the job is for (the product's: e.g. the original's storage key plus its stamp). A render that
|
|
22
|
+
* finishes for an older revision is discarded, never attached to the new one.
|
|
23
|
+
*/
|
|
24
|
+
revision: string;
|
|
25
|
+
version: string;
|
|
26
|
+
state: ProxyJobState;
|
|
27
|
+
/** Counted failures of this revision (interrupted renders aren't counted). */
|
|
28
|
+
failures: number;
|
|
29
|
+
/** Interruptions in a row (not failures): they only space out the next try. */
|
|
30
|
+
interruptions?: number;
|
|
31
|
+
output: string;
|
|
32
|
+
/** While rendering: the temporary file and the ffmpeg pid, for cleanup after a kill. */
|
|
33
|
+
tmp?: string;
|
|
34
|
+
pid?: number;
|
|
35
|
+
result?: RenderResult;
|
|
36
|
+
lastError?: string;
|
|
37
|
+
/** Not before (epoch ms): backoff after a failure, or a short wait after an interruption. */
|
|
38
|
+
notBefore?: number;
|
|
39
|
+
}
|
|
40
|
+
export interface ProxyJobStore {
|
|
41
|
+
load(): Promise<Record<string, ProxyJobRecord>>;
|
|
42
|
+
/** Atomic: after a crash either the old or the new journal is there, never half of one. */
|
|
43
|
+
save(all: Record<string, ProxyJobRecord>): Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
export interface QueueDeps {
|
|
46
|
+
store: ProxyJobStore;
|
|
47
|
+
/** Render one job (renderLightProxy with the product's paths and tools bound). */
|
|
48
|
+
render(job: ProxyJobRecord, plan: Extract<ProxyPlan, {
|
|
49
|
+
kind: "render";
|
|
50
|
+
}>, ctx: {
|
|
51
|
+
signal: AbortSignal;
|
|
52
|
+
threads: number;
|
|
53
|
+
nice: number;
|
|
54
|
+
onPrepare: (tmp: string) => Promise<void>;
|
|
55
|
+
onStart: (tmp: string, pid?: number) => void;
|
|
56
|
+
}): Promise<RenderResult>;
|
|
57
|
+
/**
|
|
58
|
+
* Kill our ffmpeg still writing `tmp`: by `pid` when it was saved, else by finding the process whose command line
|
|
59
|
+
* ends with `tmp`. Never another process (a reused pid, another app's ffmpeg).
|
|
60
|
+
*/
|
|
61
|
+
killOrphan(pid: number | undefined, tmp: string): Promise<void>;
|
|
62
|
+
remove(path: string): Promise<void>;
|
|
63
|
+
/** stat; undefined when gone. */
|
|
64
|
+
stat(path: string): Promise<FileStamp | undefined>;
|
|
65
|
+
/** A journal write failed (reported; later writes still happen). */
|
|
66
|
+
onSaveError?: (e: unknown) => void;
|
|
67
|
+
/** Freeze or thaw running encoders (EncoderGroup.freeze). */
|
|
68
|
+
freeze(on: boolean): void;
|
|
69
|
+
now?: () => number;
|
|
70
|
+
/** Backoff after the n-th counted failure, ms. Default 30 s × 2^(n-1). */
|
|
71
|
+
backoffMs?: (n: number) => number;
|
|
72
|
+
maxTries?: number;
|
|
73
|
+
onChange?: (job: ProxyJobRecord) => void;
|
|
74
|
+
}
|
|
75
|
+
export interface ProxyQueue {
|
|
76
|
+
/** Load the journal and clean up after a previous run. Call once before anything else. */
|
|
77
|
+
recover(): Promise<void>;
|
|
78
|
+
/** Add or update a clip's job. A new revision starts over (failures forgotten, a running render for the old one discarded). */
|
|
79
|
+
want(id: string, revision: string, output: string, plan: Extract<ProxyPlan, {
|
|
80
|
+
kind: "render";
|
|
81
|
+
}>): Promise<ProxyJobRecord>;
|
|
82
|
+
/** The clip no longer needs a proxy (deleted, or it turned out not to need one): stop its render, remove its files. */
|
|
83
|
+
drop(id: string): Promise<void>;
|
|
84
|
+
/** Start what the budget allows now; freeze or thaw what runs. */
|
|
85
|
+
pump(verdict: BudgetVerdict): Promise<void>;
|
|
86
|
+
get(id: string): ProxyJobRecord | undefined;
|
|
87
|
+
/** A ready proxy that is still provably the file the render made, else undefined (and the job is queued again). */
|
|
88
|
+
ready(id: string): Promise<RenderResult | undefined>;
|
|
89
|
+
running(): {
|
|
90
|
+
total: number;
|
|
91
|
+
software: number;
|
|
92
|
+
};
|
|
93
|
+
/** Wait for every running render to settle (tests, shutdown). */
|
|
94
|
+
idle(): Promise<void>;
|
|
95
|
+
/** Stop everything (quit): renders are killed and count as interrupted. */
|
|
96
|
+
stop(): Promise<void>;
|
|
97
|
+
}
|
|
98
|
+
export declare function createProxyQueue(d: QueueDeps): ProxyQueue;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ProxyTools } from "./camera";
|
|
2
|
+
import type { ProxyJobStore } from "./jobs";
|
|
3
|
+
import type { ProcessRunner, RenderTools } from "./render";
|
|
4
|
+
import type { FileStamp } from "./types";
|
|
5
|
+
export * from "./index";
|
|
6
|
+
export interface NodeProxyToolsOptions {
|
|
7
|
+
ffmpeg?: string;
|
|
8
|
+
ffprobe?: string;
|
|
9
|
+
/** Niceness for checks and counts (default 15). */
|
|
10
|
+
nice?: number;
|
|
11
|
+
/** Per command, ms (default 120 s; a full decode count gets 30 min). */
|
|
12
|
+
timeoutMs?: number;
|
|
13
|
+
}
|
|
14
|
+
export declare function statStamp(path: string): Promise<FileStamp | undefined>;
|
|
15
|
+
export declare function createNodeProxyTools(o?: NodeProxyToolsOptions): ProxyTools & RenderTools;
|
|
16
|
+
/** ffmpeg children at the given niceness; SIGSTOP/SIGCONT work on them as on any process. */
|
|
17
|
+
export declare const nodeRunner: ProcessRunner;
|
|
18
|
+
/** Our ffmpeg writing `tmp`: the command line starts with the exact executable and ends with `tmp` (our renders' last
|
|
19
|
+
* argument is their output). Paths with spaces are compared whole, never split. */
|
|
20
|
+
export declare function isOurEncoder(command: string, tmp: string, ffmpeg: string): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Kill the ffmpeg a previous run left writing `tmp`: the recorded `pid` if its command line is still ours, else (a run
|
|
23
|
+
* that died before the pid was saved) any process whose command line is. A pid reused by another process (another
|
|
24
|
+
* app's ffmpeg, the owner's own render, an ffmpeg reading that file) is never touched. true when one was killed.
|
|
25
|
+
*/
|
|
26
|
+
export declare function killOrphanEncoder(pid: number | undefined, tmp: string, ffmpeg?: string): Promise<boolean>;
|
|
27
|
+
/** Free bytes on the volume of `dir`; undefined when it can't be read. */
|
|
28
|
+
export declare function diskFree(dir: string): Promise<number | undefined>;
|
|
29
|
+
/** The journal as one JSON file, written atomically (temp file, fsync, rename, fsync of the folder). */
|
|
30
|
+
export declare function fileJobStore(path: string): ProxyJobStore;
|
|
31
|
+
/** Encoder options this ffmpeg build has: `-power_efficient 1` on VideoToolbox (FFmpeg 8+) lowers the encode's energy. */
|
|
32
|
+
export declare function probeEncoderOptions(ffmpeg: string, encoder: string): Promise<string[]>;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which proxy a clip gets. In order:
|
|
3
|
+
* 1. The camera recorded one and it proved itself (camera.ts): uploaded as is, nothing rendered.
|
|
4
|
+
* 2. The original already plays everywhere at proxy size: none needed.
|
|
5
|
+
* 3. A light local proxy (lower quality is fine: a preview, 960 px long edge by default) with the host's verified
|
|
6
|
+
* HARDWARE encoder, decoded on the media engine when the format allows. Software decode only when the product
|
|
7
|
+
* turns it on (`cpuDecode`), and then only within the CPU budget (budget.ts).
|
|
8
|
+
* 4. Otherwise none, with the reason (the share can offer the original or a server preview instead).
|
|
9
|
+
* A proxy is never the original: nothing here touches what is uploaded as the original or when a card is safe to clear.
|
|
10
|
+
* Pure: no I/O.
|
|
11
|
+
*/
|
|
12
|
+
import type { CameraProxyCheck } from "./camera";
|
|
13
|
+
import type { FileStamp, NoProxyReason, ProxyMedia } from "./types";
|
|
14
|
+
export interface ProxySettings {
|
|
15
|
+
/** Make proxies on this machine at all (camera proxies are used either way). Default true. */
|
|
16
|
+
local: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Formats only the CPU decodes (FX30/FX3/A7S III XAVC S-I 4:2:2 10-bit, DNx, MPEG-2 …) get a light proxy decoded on
|
|
19
|
+
* the CPU, within the budget. Default false: the CPU-PROXIES-SETTING.md brief keeps it off by default (an M5 Max froze
|
|
20
|
+
* at 800–1300 % CPU rendering four at once).
|
|
21
|
+
*/
|
|
22
|
+
cpuDecode: boolean;
|
|
23
|
+
/** Longest side of the light proxy, pixels (never upscaled). */
|
|
24
|
+
longEdge: number;
|
|
25
|
+
/** Video bitrate ceiling, kbit/s (lowered for low-bitrate sources). */
|
|
26
|
+
bitrateK: number;
|
|
27
|
+
/** Renders that may fail before a clip gets "render-failed" (never a retry loop). */
|
|
28
|
+
maxTries: number;
|
|
29
|
+
/** Allow a software encoder (libx264) when no hardware one is verified. Default false: the budget assumes hardware. */
|
|
30
|
+
softwareEncoder: boolean;
|
|
31
|
+
}
|
|
32
|
+
/** Defaults: the shipped behaviour (local renders for media-engine formats, CPU decode off), lighter output. */
|
|
33
|
+
export declare const DEFAULT_PROXY_SETTINGS: ProxySettings;
|
|
34
|
+
/** The encoder the host profile verified (TuneDecision.encode). */
|
|
35
|
+
export interface ProxyEncoder {
|
|
36
|
+
encoder: string | null;
|
|
37
|
+
api: string | null;
|
|
38
|
+
hardware: boolean;
|
|
39
|
+
}
|
|
40
|
+
export type RenderDecode =
|
|
41
|
+
/** Decode and scale on the media engine (8-bit 4:2:0, limited range, upright, progressive). */
|
|
42
|
+
"hardware-gpu"
|
|
43
|
+
/** Decode on the media engine, convert in memory (range, bit depth, rotation, deinterlace). */
|
|
44
|
+
| "hardware"
|
|
45
|
+
/** Decode on the CPU (only with cpuDecode). */
|
|
46
|
+
| "software";
|
|
47
|
+
export type ProxyPlan = {
|
|
48
|
+
kind: "camera";
|
|
49
|
+
check: Extract<CameraProxyCheck, {
|
|
50
|
+
ok: true;
|
|
51
|
+
}>;
|
|
52
|
+
} | {
|
|
53
|
+
kind: "render";
|
|
54
|
+
/** What is decoded: the original, or a camera proxy browsers can't play (cheaper than a 4K original). */
|
|
55
|
+
from: "original" | "camera-proxy";
|
|
56
|
+
sourcePath: string;
|
|
57
|
+
/** The clip's original (the render must never write it; a camera-proxy render re-checks its approval against it). */
|
|
58
|
+
originalPath?: string;
|
|
59
|
+
/** The source as stat'ed when its probe was made: a render refuses another file at that path (a swapped card). */
|
|
60
|
+
sourceStamp?: FileStamp;
|
|
61
|
+
media: ProxyMedia;
|
|
62
|
+
decode: RenderDecode;
|
|
63
|
+
width: number;
|
|
64
|
+
height: number;
|
|
65
|
+
bitrateK: number;
|
|
66
|
+
check?: Extract<CameraProxyCheck, {
|
|
67
|
+
ok: true;
|
|
68
|
+
}>;
|
|
69
|
+
} | {
|
|
70
|
+
kind: "none";
|
|
71
|
+
reason: NoProxyReason;
|
|
72
|
+
};
|
|
73
|
+
export interface PlanInput {
|
|
74
|
+
path: string;
|
|
75
|
+
kind: "video" | "photo" | "audio" | "other";
|
|
76
|
+
original?: ProxyMedia;
|
|
77
|
+
/** The proven camera proxy, if any (pickCameraProxy's `chosen`). */
|
|
78
|
+
camera?: Extract<CameraProxyCheck, {
|
|
79
|
+
ok: true;
|
|
80
|
+
}>;
|
|
81
|
+
encoder: ProxyEncoder;
|
|
82
|
+
hwaccels?: readonly string[];
|
|
83
|
+
/** The original as stat'ed when `original` was probed (bound into the plan: see sourceStamp). */
|
|
84
|
+
stamp?: FileStamp;
|
|
85
|
+
/** Renders of this revision that failed (interrupted ones aren't counted). */
|
|
86
|
+
failures?: number;
|
|
87
|
+
settings?: Partial<ProxySettings>;
|
|
88
|
+
}
|
|
89
|
+
export declare function planProxy(i: PlanInput): ProxyPlan;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** ffprobe JSON → ProxyMedia, pure (tested against real ffprobe output in test/proxies). */
|
|
2
|
+
import type { ProxyMedia } from "./types";
|
|
3
|
+
interface FfStream {
|
|
4
|
+
codec_type?: string;
|
|
5
|
+
codec_name?: string;
|
|
6
|
+
profile?: string;
|
|
7
|
+
pix_fmt?: string;
|
|
8
|
+
width?: number;
|
|
9
|
+
height?: number;
|
|
10
|
+
avg_frame_rate?: string;
|
|
11
|
+
r_frame_rate?: string;
|
|
12
|
+
duration?: string;
|
|
13
|
+
nb_frames?: string;
|
|
14
|
+
bit_rate?: string;
|
|
15
|
+
color_range?: string;
|
|
16
|
+
color_space?: string;
|
|
17
|
+
color_primaries?: string;
|
|
18
|
+
color_transfer?: string;
|
|
19
|
+
field_order?: string;
|
|
20
|
+
channels?: number;
|
|
21
|
+
tags?: Record<string, string>;
|
|
22
|
+
side_data_list?: {
|
|
23
|
+
side_data_type?: string;
|
|
24
|
+
rotation?: number;
|
|
25
|
+
}[];
|
|
26
|
+
disposition?: {
|
|
27
|
+
attached_pic?: number;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
interface FfProbe {
|
|
31
|
+
streams?: FfStream[];
|
|
32
|
+
format?: {
|
|
33
|
+
duration?: string;
|
|
34
|
+
bit_rate?: string;
|
|
35
|
+
tags?: Record<string, string>;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export declare function parseFfprobe(json: string | FfProbe): ProxyMedia | undefined;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Render one light proxy and prove it. The result is used only when ffmpeg reported no dropped or duplicated frame and
|
|
3
|
+
* no decoder error, the media engine never fell back to the CPU (a fallback is killed at once), and the output has the
|
|
4
|
+
* source's frame count and duration. It is written to a unique temporary file and renamed into place only then, so a
|
|
5
|
+
* crash, a kill or a full disk never leaves something that looks like a proxy.
|
|
6
|
+
*
|
|
7
|
+
* Every failure says whether it counts against the clip: a render stopped from outside (the app quitting, the card
|
|
8
|
+
* pulled, the disk full, the budget freezing it too long) taught nothing about the clip and is retried later for free.
|
|
9
|
+
*/
|
|
10
|
+
import { type LightArgsInput } from "./args";
|
|
11
|
+
import { type ProxyTools } from "./camera";
|
|
12
|
+
import type { ProxyPlan } from "./plan";
|
|
13
|
+
import { type FileStamp } from "./types";
|
|
14
|
+
/** The process interface a render needs (Node: ./node nodeRunner; tests: fakes). */
|
|
15
|
+
export interface RunningProcess {
|
|
16
|
+
readonly pid?: number;
|
|
17
|
+
onStdout(cb: (chunk: string) => void): void;
|
|
18
|
+
onStderr(cb: (chunk: string) => void): void;
|
|
19
|
+
/** Called once, when the process has exited and its pipes closed. */
|
|
20
|
+
onClose(cb: (code: number | null, signal: string | null) => void): void;
|
|
21
|
+
kill(signal: "SIGKILL" | "SIGSTOP" | "SIGCONT" | "SIGTERM"): void;
|
|
22
|
+
}
|
|
23
|
+
export interface ProcessRunner {
|
|
24
|
+
spawn(cmd: string, args: string[], o: {
|
|
25
|
+
nice: number;
|
|
26
|
+
}): RunningProcess;
|
|
27
|
+
}
|
|
28
|
+
/** The tools a render needs on top of a check's: rename, remove, and a full decode count for edit-list lead-ins. */
|
|
29
|
+
export interface RenderTools extends Pick<ProxyTools, "countFrames" | "probe" | "stat"> {
|
|
30
|
+
rename(from: string, to: string): Promise<void>;
|
|
31
|
+
remove(path: string): Promise<void>;
|
|
32
|
+
writeFile(path: string, data: string): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
/** Freezes and thaws every running encoder together (SIGSTOP/SIGCONT), the budget's lever. */
|
|
35
|
+
export declare class EncoderGroup {
|
|
36
|
+
private readonly live;
|
|
37
|
+
private frozenAt;
|
|
38
|
+
private frozenTotal;
|
|
39
|
+
private readonly now;
|
|
40
|
+
constructor(now?: () => number);
|
|
41
|
+
get frozen(): boolean;
|
|
42
|
+
get size(): number;
|
|
43
|
+
/** Milliseconds spent frozen so far (a watchdog doesn't count them as a stall). */
|
|
44
|
+
frozenMs(): number;
|
|
45
|
+
add(p: RunningProcess): void;
|
|
46
|
+
delete(p: RunningProcess): void;
|
|
47
|
+
freeze(on: boolean): void;
|
|
48
|
+
killAll(): void;
|
|
49
|
+
}
|
|
50
|
+
export type RenderFailure =
|
|
51
|
+
/** Counts against the clip: the format or the machine can't make a proven proxy of it. */
|
|
52
|
+
"failed"
|
|
53
|
+
/** Doesn't count: stopped from outside, nothing learned. */
|
|
54
|
+
| "interrupted";
|
|
55
|
+
export declare class ProxyRenderError extends Error {
|
|
56
|
+
readonly outcome: RenderFailure;
|
|
57
|
+
/** "cancelled", "source-gone", "source-changed", "disk-full", "stalled", "hw-fallback", "frames", "duration", … */
|
|
58
|
+
readonly code: string;
|
|
59
|
+
constructor(message: string, outcome: RenderFailure, code: string);
|
|
60
|
+
}
|
|
61
|
+
export interface RenderResult {
|
|
62
|
+
path: string;
|
|
63
|
+
size: number;
|
|
64
|
+
frames: number;
|
|
65
|
+
duration: number;
|
|
66
|
+
width: number;
|
|
67
|
+
height: number;
|
|
68
|
+
encoder: string;
|
|
69
|
+
decode: Extract<ProxyPlan, {
|
|
70
|
+
kind: "render";
|
|
71
|
+
}>["decode"];
|
|
72
|
+
/** The source as it was when the render started (and still was when it ended). */
|
|
73
|
+
source: FileStamp;
|
|
74
|
+
/** The proxy file as written: a ready proxy is handed out only while it is still exactly this file. */
|
|
75
|
+
output: FileStamp;
|
|
76
|
+
/** Wall-clock ms the render ran, frozen time excluded. */
|
|
77
|
+
ms: number;
|
|
78
|
+
}
|
|
79
|
+
export interface RenderInput extends Omit<LightArgsInput, "output"> {
|
|
80
|
+
ffmpeg: string;
|
|
81
|
+
/** Where the proven proxy ends up. */
|
|
82
|
+
output: string;
|
|
83
|
+
runner: ProcessRunner;
|
|
84
|
+
tools: RenderTools;
|
|
85
|
+
nice: number;
|
|
86
|
+
group?: EncoderGroup;
|
|
87
|
+
signal?: AbortSignal;
|
|
88
|
+
onProgress?: (fraction: number) => void;
|
|
89
|
+
/** No progress for this long (frozen time excluded) and the render is killed. Default 120 s. */
|
|
90
|
+
stallMs?: number;
|
|
91
|
+
now?: () => number;
|
|
92
|
+
/** Unique suffix for the temporary file (default random). */
|
|
93
|
+
tag?: string;
|
|
94
|
+
/** Awaited with the temporary file before ffmpeg starts (the journal saves it: kill-and-resume finds the process by it). */
|
|
95
|
+
onPrepare?: (tmp: string) => Promise<void>;
|
|
96
|
+
/** Called with the temporary file and pid once started. */
|
|
97
|
+
onStart?: (tmp: string, pid: number | undefined) => void;
|
|
98
|
+
}
|
|
99
|
+
/** ffmpeg fell back to its CPU decoder: the media engine refused this stream. */
|
|
100
|
+
export declare const HW_FALLBACK: RegExp;
|
|
101
|
+
/** Edit-list lead-in frames a container may count beyond the stream's duration before a full decode is asked (the bound
|
|
102
|
+
* grows with what the duration says the edit list hides). */
|
|
103
|
+
export declare const MAX_LEAD_IN = 3;
|
|
104
|
+
export declare function renderLightProxy(i: RenderInput): Promise<RenderResult>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "Safe to clear the card" and proxies: they have nothing to do with each other.
|
|
3
|
+
*
|
|
4
|
+
* A card is safe to clear when every original recorded on it is stored and verified. A proxy is a derived file: a
|
|
5
|
+
* camera's own proxy or a light local one can always be made again from the stored original (here, or in the cloud),
|
|
6
|
+
* so losing one never loses footage, and waiting for one would hold a card for nothing (UploadFilm once did: a render
|
|
7
|
+
* that kept failing held "safe to clear" forever, 894266a/3fd74ba). So the verdict takes the originals only. Its input
|
|
8
|
+
* type has no place for a proxy, and `cardOriginals` drops every proxy of a card reader's clip before anything sees it.
|
|
9
|
+
*/
|
|
10
|
+
/** One original on the card, and whether its stored copy is verified (size + checksum, by the transfer engine). */
|
|
11
|
+
export interface OriginalOnCard {
|
|
12
|
+
/** The card file (path on the card). */
|
|
13
|
+
path: string;
|
|
14
|
+
verified: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface SafeToClear {
|
|
17
|
+
safe: boolean;
|
|
18
|
+
/** Originals not yet verified (what the card is still needed for). */
|
|
19
|
+
waitingFor: string[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The verdict, from the originals alone. An empty card is not "safe" by default here: with nothing to check, a caller
|
|
23
|
+
* that lost its list would otherwise say "safe" (the product decides what an empty card means).
|
|
24
|
+
*/
|
|
25
|
+
export declare function safeToClear(originals: readonly OriginalOnCard[]): SafeToClear;
|
|
26
|
+
/** The shape of a card reader clip this needs (@uploadfilm/sdk/cards Clip), structurally. */
|
|
27
|
+
export interface ClipFiles {
|
|
28
|
+
originals: readonly {
|
|
29
|
+
rel: string;
|
|
30
|
+
}[];
|
|
31
|
+
/** Other files of the recording (Panasonic P2's per-channel audio): originals too. */
|
|
32
|
+
tracks?: readonly {
|
|
33
|
+
rel: string;
|
|
34
|
+
}[];
|
|
35
|
+
/** The camera's proxies: never originals for this purpose. */
|
|
36
|
+
proxies?: readonly {
|
|
37
|
+
rel: string;
|
|
38
|
+
}[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Every file of the card's clips that "safe to clear" depends on: originals and tracks. Proxies are left out, and so is
|
|
42
|
+
* any file that is both (a card reader never makes one, but if it did the file would count as an original: when in
|
|
43
|
+
* doubt, a file is footage).
|
|
44
|
+
*/
|
|
45
|
+
export declare function cardOriginals(clips: readonly ClipFiles[]): string[];
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Proxies: what the SDK knows about a clip, a camera-made proxy and a light local one. docs/platform/PROXIES.md.
|
|
3
|
+
*
|
|
4
|
+
* Every field is optional where a probe can't tell it: `undefined` means "not known", and an unknown that a check needs
|
|
5
|
+
* fails that check (a proxy is only used when it is proven, never on a guess).
|
|
6
|
+
*/
|
|
7
|
+
/** What a probe (ffprobe, or the camera's own metadata for a RAW nothing here decodes) says about a recording. */
|
|
8
|
+
export interface ProxyMedia {
|
|
9
|
+
/** ffprobe codec_name: "h264", "hevc", "prores", "dnxhd" … */
|
|
10
|
+
videoCodec?: string;
|
|
11
|
+
/** ffprobe profile: "High", "High 4:2:2", "Main 10" … */
|
|
12
|
+
profile?: string;
|
|
13
|
+
/** ffprobe pix_fmt: "yuv420p", "yuv422p10le" … */
|
|
14
|
+
pixFmt?: string;
|
|
15
|
+
width?: number;
|
|
16
|
+
height?: number;
|
|
17
|
+
/** Display rotation in degrees (phones). */
|
|
18
|
+
rotation?: number;
|
|
19
|
+
/** Average frame rate, frames per second. */
|
|
20
|
+
fps?: number;
|
|
21
|
+
/** The video's length in seconds (the stream's, after any edit list). */
|
|
22
|
+
duration?: number;
|
|
23
|
+
/** Video frames as the container counts them (nb_frames, or packets counted without decoding). */
|
|
24
|
+
frames?: number;
|
|
25
|
+
/** Overall bits per second. */
|
|
26
|
+
bitrate?: number;
|
|
27
|
+
/** "tv" (limited) or "pc" (full). */
|
|
28
|
+
colorRange?: string;
|
|
29
|
+
colorSpace?: string;
|
|
30
|
+
colorPrimaries?: string;
|
|
31
|
+
colorTransfer?: string;
|
|
32
|
+
/** "progressive", "tt", "bb", "tb", "bt" (ffprobe field_order). */
|
|
33
|
+
fieldOrder?: string;
|
|
34
|
+
/** Start timecode as written ("01:00:00:00", drop-frame "01:00:00;00"). */
|
|
35
|
+
timecode?: string;
|
|
36
|
+
/** Recording time (ISO 8601). */
|
|
37
|
+
createdAt?: string;
|
|
38
|
+
/** The first audio track's codec ("aac", "pcm_s24le"), undefined when there is none. */
|
|
39
|
+
audioCodec?: string;
|
|
40
|
+
/** Channels of every audio track, in order. */
|
|
41
|
+
audioTracks?: number[];
|
|
42
|
+
/** Indexes into audioTracks that ffmpeg can decode (iPhone APAC spatial audio can't be). Default: all of them. */
|
|
43
|
+
audioDecodable?: number[];
|
|
44
|
+
}
|
|
45
|
+
/** A file as stat saw it: the identity a check or a render is tied to (a replaced file is a different file). */
|
|
46
|
+
export interface FileStamp {
|
|
47
|
+
dev: number;
|
|
48
|
+
ino: number;
|
|
49
|
+
size: number;
|
|
50
|
+
mtimeMs: number;
|
|
51
|
+
}
|
|
52
|
+
export declare const sameStamp: (a: FileStamp | undefined, b: FileStamp | undefined) => boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Which camera rule paired the clip with its proxy (the card reader's `Clip.proxyBrand`). It decides what may differ:
|
|
55
|
+
* DJI and Insta360 record the low-res copy at a lower frame rate; Canon and LUMIX pair across cards, so they must also
|
|
56
|
+
* prove the take by timecode or recording time; Canon's loose names by timecode.
|
|
57
|
+
*/
|
|
58
|
+
export type ProxyBrand = "sony" | "panasonic" | "lumix" | "canon" | "canon-loose" | "dji" | "gopro" | "insta360" | "nikon" | "blackmagic" | "red" | "other";
|
|
59
|
+
/** Why a clip gets no proxy from this machine. */
|
|
60
|
+
export type NoProxyReason =
|
|
61
|
+
/** Not a video (a still, audio). */
|
|
62
|
+
"not-video"
|
|
63
|
+
/** The original already plays everywhere at proxy size: 1080p-or-less 8-bit 4:2:0 H.264 in MP4/MOV under 8 Mbps. */
|
|
64
|
+
| "original-is-proxy"
|
|
65
|
+
/** Nothing here reads the format (no probe, no codec, a damaged file). */
|
|
66
|
+
| "unknown-format"
|
|
67
|
+
/** Only the CPU decodes it (10-bit/4:2:2 H.264 like the FX30's XAVC S-I, DNx, MPEG-2 …) and CPU decoding is off. */
|
|
68
|
+
| "cpu-only"
|
|
69
|
+
/** A camera RAW nothing here decodes, and no camera proxy proved itself. */
|
|
70
|
+
| "raw-no-proxy"
|
|
71
|
+
/** No verified encoder on this machine. */
|
|
72
|
+
| "no-encoder"
|
|
73
|
+
/** Local proxies are turned off. */
|
|
74
|
+
| "local-off"
|
|
75
|
+
/** Renders failed every allowed try (they never retry forever). */
|
|
76
|
+
| "render-failed";
|
|
77
|
+
/** One camera-made proxy candidate, as the card reader grouped it with its clip. */
|
|
78
|
+
export interface CameraProxyCandidate {
|
|
79
|
+
path: string;
|
|
80
|
+
brand?: ProxyBrand;
|
|
81
|
+
/** Its probe, when the card reader already made one. Checked again (fresh) before use. */
|
|
82
|
+
media?: ProxyMedia;
|
|
83
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { LaneSpec } from "../transfer/engine";
|
|
2
|
+
export declare const ORIGINALS_LANE = "original";
|
|
3
|
+
export declare const PROXY_LANE = "proxy";
|
|
4
|
+
/** Lanes for createTransferEngine: originals primary (⅔), proxies borrowing. A product with posters puts its "first" lane before. */
|
|
5
|
+
export declare const PROXY_LANES: LaneSpec[];
|
|
6
|
+
/** The upload request for a proxy: always the proxy lane. `key` is the product's (it decides its layout). */
|
|
7
|
+
export declare function proxyUploadRequest(o: {
|
|
8
|
+
key: string;
|
|
9
|
+
path: string;
|
|
10
|
+
}): {
|
|
11
|
+
readonly key: string;
|
|
12
|
+
readonly path: string;
|
|
13
|
+
readonly lane: "proxy";
|
|
14
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type Ref } from "react";
|
|
2
|
+
import type { Player } from "@uploadfilm/sdk/player";
|
|
3
|
+
/**
|
|
4
|
+
* The big play button's behaviour, headless: hidden the instant it's pressed (without waiting for "play", which then
|
|
5
|
+
* removes it for good), back with the focus on it when play() is refused, back when the video pauses before playing.
|
|
6
|
+
* `focusTarget`: where the focus goes on press (the skin's container, so its hotkeys keep working); without one the
|
|
7
|
+
* button is blurred, so the focus isn't left on a hidden button.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useBigPlay(player: Player, opts?: {
|
|
10
|
+
focusTarget?: () => HTMLElement | null | undefined;
|
|
11
|
+
}): {
|
|
12
|
+
started: boolean;
|
|
13
|
+
pressed: boolean;
|
|
14
|
+
hidden: boolean;
|
|
15
|
+
play: () => void;
|
|
16
|
+
reset: () => void;
|
|
17
|
+
buttonRef: import("react").RefObject<HTMLButtonElement | null>;
|
|
18
|
+
setPressed: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
19
|
+
};
|
|
20
|
+
/** The big play button over the poster, with the title on top. Render it over the skin; it takes clicks only on itself. */
|
|
21
|
+
export declare function BigPlayButton({ onPlay, hidden, title, buttonRef, }: {
|
|
22
|
+
onPlay: () => void;
|
|
23
|
+
hidden?: boolean;
|
|
24
|
+
title?: string;
|
|
25
|
+
buttonRef?: Ref<HTMLButtonElement>;
|
|
26
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { ComponentType, CSSProperties, ReactNode } from "react";
|
|
2
|
+
import type { Player as Engine, StoryboardSource } from "@uploadfilm/sdk/player";
|
|
3
|
+
import { usePlayer, type UsePlayerOptions } from "./usePlayer";
|
|
4
|
+
import { type PlayerTheme } from "./theme";
|
|
5
|
+
/**
|
|
6
|
+
* Video.js 10's React components, passed in (this package has no hard import of Video.js; you choose its version):
|
|
7
|
+
*
|
|
8
|
+
* ```tsx
|
|
9
|
+
* import "@videojs/react/video/skin.css";
|
|
10
|
+
* import { Video, VideoPlayer, VideoSkin } from "@videojs/react/video";
|
|
11
|
+
* import { HlsJsVideo } from "@videojs/react/media/hlsjs-video";
|
|
12
|
+
* <Player components={{ Video, VideoPlayer, VideoSkin, HlsJsVideo }} sources={{ hls, mp4 }} />
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export interface VideoJsComponents {
|
|
16
|
+
VideoPlayer: ComponentType<any>;
|
|
17
|
+
VideoSkin: ComponentType<any>;
|
|
18
|
+
Video: ComponentType<any>;
|
|
19
|
+
/** Without it, HLS isn't used (the MP4 plays). */
|
|
20
|
+
HlsJsVideo?: ComponentType<any>;
|
|
21
|
+
}
|
|
22
|
+
export interface PlayerProps extends Omit<UsePlayerOptions, "loader"> {
|
|
23
|
+
/** The default skin's components (Video.js). Without them: a plain <video controls> loaded by the engine. */
|
|
24
|
+
components?: VideoJsComponents;
|
|
25
|
+
theme?: PlayerTheme;
|
|
26
|
+
poster?: string;
|
|
27
|
+
/** Shown by the skin (and on the big play button). */
|
|
28
|
+
title?: string;
|
|
29
|
+
muted?: boolean;
|
|
30
|
+
loop?: boolean;
|
|
31
|
+
preload?: "auto" | "metadata" | "none";
|
|
32
|
+
/** A big play button until the first play. */
|
|
33
|
+
bigPlay?: boolean;
|
|
34
|
+
/** Hide the control bar (hotkeys and click-to-play stay). */
|
|
35
|
+
hideBar?: boolean;
|
|
36
|
+
/** Extra attributes on the media element (data-*). */
|
|
37
|
+
mediaProps?: Record<string, unknown>;
|
|
38
|
+
className?: string;
|
|
39
|
+
style?: CSSProperties;
|
|
40
|
+
/** Overlays inside the skin. */
|
|
41
|
+
children?: ReactNode;
|
|
42
|
+
/**
|
|
43
|
+
* Timeline hover previews in the skin: the storyboard's WebVTT thumbnails track (its URL, or a descriptor's { vtt }).
|
|
44
|
+
* Video.js's skin draws the thumbnail over its time slider from it (a metadata track labelled "thumbnails"), read
|
|
45
|
+
* by the SDK (useThumbnailsTrack: absolute sheet URLs, http(s) only). The VTT is fetched like any storyboard (CORS for
|
|
46
|
+
* another origin). Or a descriptor with its layout (no VTT fetch). For your own controls: useTimelinePreview.
|
|
47
|
+
*/
|
|
48
|
+
storyboard?: StoryboardSource;
|
|
49
|
+
/** An engine you made with usePlayer (custom wiring): the component then only renders it. */
|
|
50
|
+
player?: ReturnType<typeof usePlayer>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The default player: Video.js's skin over the headless engine (usePlayer). The engine decides HLS or MP4, recovers,
|
|
54
|
+
* falls back and keeps the viewer's pause; the skin draws the controls. No poster is held while loading unless you pass
|
|
55
|
+
* one. Every part of it is a hook: usePlayer, usePlayerState, useBigPlay, useTimedTrack, useCaptions.
|
|
56
|
+
*/
|
|
57
|
+
export declare function Player(props: PlayerProps): import("react").JSX.Element;
|
|
58
|
+
export type { Engine };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Embeds in React, headless first: useEmbedController drives any embed <iframe> through the control API, and
|
|
3
|
+
* <EmbedFrame> is the responsive iframe (the same frame iframeSnippet writes as HTML) for pages that render embeds.
|
|
4
|
+
*
|
|
5
|
+
* const { ref, controller, ready, state } = useEmbedController({ onEvent: (e) => e === "ended" && next() });
|
|
6
|
+
* <EmbedFrame ref={ref} base="https://host" embedId={id} title="Reel" size={{ w: 1920, h: 1080 }} />
|
|
7
|
+
* <button onClick={() => controller?.play()} disabled={!ready}>Play</button>
|
|
8
|
+
*/
|
|
9
|
+
import { type CSSProperties } from "react";
|
|
10
|
+
import { EmbedController, type EmbedControllerEvent, type EmbedControllerState, type EmbedOptions, type EmbedPaths } from "@uploadfilm/sdk/player";
|
|
11
|
+
export interface UseEmbedControllerOptions {
|
|
12
|
+
/** Every event the player reports, with its state (always the latest callback; no need to memoise it). */
|
|
13
|
+
onEvent?: (event: EmbedControllerEvent, state: EmbedControllerState) => void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A controller for the embed iframe you give `ref` to (`<EmbedFrame ref={ref}>` or any `<iframe ref={ref}>`), whether
|
|
17
|
+
* it is ready for commands, and the state it last reported. `ref` is a callback ref, so the hook follows the iframe
|
|
18
|
+
* actually in the page wherever it is rendered: one that mounts later or is replaced gets a new controller (the old one
|
|
19
|
+
* is destroyed). `ready` drops when the iframe reloads or gets a new src, until the new page answers. Commands given
|
|
20
|
+
* before it's ready wait for the player.
|
|
21
|
+
*/
|
|
22
|
+
export declare function useEmbedController(opts?: UseEmbedControllerOptions): {
|
|
23
|
+
ref: (el: HTMLIFrameElement | null) => void;
|
|
24
|
+
controller: EmbedController | null;
|
|
25
|
+
ready: boolean;
|
|
26
|
+
state: EmbedControllerState;
|
|
27
|
+
};
|
|
28
|
+
export interface EmbedFrameProps {
|
|
29
|
+
/** The product's host (https://host), its embed id, and the player options for the URL. */
|
|
30
|
+
base: string;
|
|
31
|
+
embedId: string;
|
|
32
|
+
options?: EmbedOptions;
|
|
33
|
+
/** The video's size (only its aspect counts); 16:9 when unknown. */
|
|
34
|
+
size?: {
|
|
35
|
+
w: number;
|
|
36
|
+
h: number;
|
|
37
|
+
};
|
|
38
|
+
title: string;
|
|
39
|
+
paths?: EmbedPaths;
|
|
40
|
+
loading?: "lazy" | "eager";
|
|
41
|
+
className?: string;
|
|
42
|
+
style?: CSSProperties;
|
|
43
|
+
}
|
|
44
|
+
/** The responsive embed iframe: full width of its container at the video's aspect ratio. */
|
|
45
|
+
export declare const EmbedFrame: import("react").ForwardRefExoticComponent<EmbedFrameProps & import("react").RefAttributes<HTMLIFrameElement>>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Cue, PlayerSources, StreamLoader } from "@uploadfilm/sdk/player";
|
|
2
|
+
export declare function CustomControls({ sources, stream, markers, captions, autoplay, }: {
|
|
3
|
+
sources: PlayerSources;
|
|
4
|
+
stream?: StreamLoader;
|
|
5
|
+
markers: Cue[];
|
|
6
|
+
captions?: Cue[];
|
|
7
|
+
autoplay?: boolean;
|
|
8
|
+
}): import("react").JSX.Element;
|