@hyperframes/core 0.9.16 → 0.9.17
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/dist/compiler/inlineSubCompositions.js +9 -2
- package/dist/compiler/staticGuard.js +2 -4
- package/dist/compiler/svgIdNamespacing.d.ts +3 -0
- package/dist/compiler/svgIdNamespacing.js +9 -0
- package/dist/compositionReadiness.js +0 -1
- package/dist/generated/runtime-inline.js +1 -1
- package/dist/hdrToneMap.d.ts +10 -1
- package/dist/hdrToneMap.js +27 -1
- package/dist/hyperframe.runtime.iife.js +62 -62
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/runtime/clipWindow.d.ts +2 -0
- package/dist/runtime/clipWindow.js +6 -0
- package/dist/runtime/timeline.d.ts +0 -1
- package/dist/runtime/timeline.js +2 -7
- package/package.json +4 -4
package/dist/hdrToneMap.d.ts
CHANGED
|
@@ -3,14 +3,23 @@ export interface ToneMapSourceColour {
|
|
|
3
3
|
colorPrimaries?: string;
|
|
4
4
|
colorTransfer?: string;
|
|
5
5
|
}
|
|
6
|
+
export interface ToneMapFrameColour extends ToneMapSourceColour {
|
|
7
|
+
keyframeTransfers?: readonly string[];
|
|
8
|
+
}
|
|
9
|
+
/** One zscale serves a stream: only an all-HLG one takes HLG's white, so a mixed one's PQ stays as is. */
|
|
10
|
+
export declare const toneMapReferenceNits: (keyframeTransfers: readonly string[] | undefined) => number;
|
|
11
|
+
export declare const readsKeyframeTransfers: ({ colorTransfer }: ToneMapSourceColour) => boolean;
|
|
6
12
|
/**
|
|
7
13
|
* HDR to SDR BT.709 with zscale and hable. zscale reads each frame's own tags, so only those the
|
|
8
14
|
* first frame lacks are set: from ffprobe, which may see the container's, else BT.2020.
|
|
9
15
|
*/
|
|
10
|
-
export declare function hdrToSdrToneMapFilter(probed: ToneMapSourceColour, firstFrame:
|
|
16
|
+
export declare function hdrToSdrToneMapFilter(probed: ToneMapSourceColour, firstFrame: ToneMapFrameColour, size?: {
|
|
11
17
|
width: string;
|
|
12
18
|
height: string;
|
|
13
19
|
}): string;
|
|
14
20
|
/** ffmpeg args printing the first shown frame's tags; ffprobe's packet-bounded reads miss edit-list pre-roll. */
|
|
15
21
|
export declare function firstFrameColourArgs(videoPath: string): string[];
|
|
22
|
+
/** ffmpeg args tracing the transfer of each SPS, in the header and in keyframes, without decoding a picture. */
|
|
23
|
+
export declare function keyframeTransferArgs(videoPath: string, codec?: string): string[];
|
|
24
|
+
export declare const parseKeyframeTransfers: (stderr: string) => string[];
|
|
16
25
|
export declare function parseFirstFrameColour(stderr: string): ToneMapSourceColour;
|
package/dist/hdrToneMap.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
const BT2408_HLG_REFERENCE_WHITE_NITS = 203;
|
|
2
|
+
const SDR_NOMINAL_PEAK_NITS = 100;
|
|
3
|
+
/** One zscale serves a stream: only an all-HLG one takes HLG's white, so a mixed one's PQ stays as is. */
|
|
4
|
+
export const toneMapReferenceNits = (keyframeTransfers) => keyframeTransfers?.length && keyframeTransfers.every((transfer) => transfer === "arib-std-b67")
|
|
5
|
+
? BT2408_HLG_REFERENCE_WHITE_NITS
|
|
6
|
+
: SDR_NOMINAL_PEAK_NITS;
|
|
7
|
+
export const readsKeyframeTransfers = ({ colorTransfer }) => colorTransfer === "arib-std-b67" || !known(colorTransfer);
|
|
1
8
|
function known(value) {
|
|
2
9
|
return value && value !== "unknown" && value !== "reserved" ? value : undefined;
|
|
3
10
|
}
|
|
@@ -14,7 +21,9 @@ export function hdrToSdrToneMapFilter(probed, firstFrame, size) {
|
|
|
14
21
|
].filter(([, value]) => value);
|
|
15
22
|
const setTags = tags.length ? `setparams=${tags.map((tag) => tag.join("=")).join(":")},` : "";
|
|
16
23
|
const resizeBeforeToneMap = size ? `w=${size.width}:h=${size.height}:` : "";
|
|
17
|
-
|
|
24
|
+
const stream = known(firstFrame.colorTransfer) ?? known(probed.colorTransfer);
|
|
25
|
+
const npl = toneMapReferenceNits(firstFrame.keyframeTransfers?.map((transfer) => transfer === "unspecified" ? (stream ?? transfer) : transfer));
|
|
26
|
+
return `${setTags}zscale=${resizeBeforeToneMap}t=linear:npl=${npl},tonemap=hable:desat=0,zscale=p=bt709:t=bt709:m=bt709:r=tv`;
|
|
18
27
|
}
|
|
19
28
|
/** ffmpeg args printing the first shown frame's tags; ffprobe's packet-bounded reads miss edit-list pre-roll. */
|
|
20
29
|
export function firstFrameColourArgs(videoPath) {
|
|
@@ -23,6 +32,23 @@ export function firstFrameColourArgs(videoPath) {
|
|
|
23
32
|
...["-vf", "showinfo", "-f", "null", "-"],
|
|
24
33
|
];
|
|
25
34
|
}
|
|
35
|
+
const SPS_UNIT_TYPES = { h264: "7", hevc: "33" };
|
|
36
|
+
const TRANSFER_NAMES = {
|
|
37
|
+
"1": "bt709",
|
|
38
|
+
"2": "unspecified",
|
|
39
|
+
"16": "smpte2084",
|
|
40
|
+
"18": "arib-std-b67",
|
|
41
|
+
};
|
|
42
|
+
/** ffmpeg args tracing the transfer of each SPS, in the header and in keyframes, without decoding a picture. */
|
|
43
|
+
export function keyframeTransferArgs(videoPath, codec) {
|
|
44
|
+
const sps = codec ? SPS_UNIT_TYPES[codec] : undefined;
|
|
45
|
+
const trace = sps ? `filter_units=pass_types=${sps},trace_headers` : "trace_headers";
|
|
46
|
+
return [
|
|
47
|
+
...["-hide_banner", "-nostats", "-discard", "nokey", "-i", videoPath, "-map", "0:v:0"],
|
|
48
|
+
...["-c", "copy", "-bsf:v", trace, "-f", "null", "-"],
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
export const parseKeyframeTransfers = (stderr) => [...stderr.matchAll(/transfer_characteristics +[01]+ = (\d+)/g)].map(([, code = ""]) => TRANSFER_NAMES[code] ?? `code ${code}`);
|
|
26
52
|
export function parseFirstFrameColour(stderr) {
|
|
27
53
|
const tags = / color_space:(\S+) color_primaries:(\S+) color_trc:(\S+)/.exec(stderr);
|
|
28
54
|
return tags ? { colorSpace: tags[1], colorPrimaries: tags[2], colorTransfer: tags[3] } : {};
|