@hyperframes/parsers 0.8.183 → 0.8.184
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/mediaAlpha.d.ts +12 -0
- package/dist/mediaAlpha.js +22 -0
- package/package.json +6 -2
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare function pixelFormatHasAlpha(pixFmt: string | undefined): boolean;
|
|
2
|
+
interface FfprobeAlphaFields {
|
|
3
|
+
pix_fmt?: string;
|
|
4
|
+
tags?: Record<string, string | undefined>;
|
|
5
|
+
}
|
|
6
|
+
/** True when an ffprobe video stream carries alpha. VP8/VP9 alpha rides in a side channel:
|
|
7
|
+
* ffprobe reports `yuv420p` plus an `alpha_mode=1` tag, whose casing differs across builds. */
|
|
8
|
+
declare function videoStreamHasAlpha(stream: FfprobeAlphaFields): boolean;
|
|
9
|
+
/** The decoder that reads a VP8/VP9 alpha side channel; ffmpeg's native ones drop it. */
|
|
10
|
+
declare function alphaDecoderFor(codecName: string | undefined): "libvpx-vp9" | "libvpx" | null;
|
|
11
|
+
|
|
12
|
+
export { type FfprobeAlphaFields, alphaDecoderFor, pixelFormatHasAlpha, videoStreamHasAlpha };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// src/mediaAlpha.ts
|
|
2
|
+
var ALPHA_PIX_FMT_RE = /^(?:yuva|rgba|argb|bgra|abgr|gbrap|ya|ayuv)/i;
|
|
3
|
+
function pixelFormatHasAlpha(pixFmt) {
|
|
4
|
+
return pixFmt !== void 0 && ALPHA_PIX_FMT_RE.test(pixFmt);
|
|
5
|
+
}
|
|
6
|
+
function videoStreamHasAlpha(stream) {
|
|
7
|
+
if (pixelFormatHasAlpha(stream.pix_fmt)) return true;
|
|
8
|
+
return Object.entries(stream.tags ?? {}).some(
|
|
9
|
+
([key, value]) => key.toLowerCase() === "alpha_mode" && value === "1"
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
function alphaDecoderFor(codecName) {
|
|
13
|
+
const codec = codecName?.toLowerCase();
|
|
14
|
+
if (codec === "vp9") return "libvpx-vp9";
|
|
15
|
+
if (codec === "vp8") return "libvpx";
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
alphaDecoderFor,
|
|
20
|
+
pixelFormatHasAlpha,
|
|
21
|
+
videoStreamHasAlpha
|
|
22
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperframes/parsers",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.184",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/heygen-com/hyperframes",
|
|
@@ -88,6 +88,10 @@
|
|
|
88
88
|
"import": "./dist/ffBinaries.js",
|
|
89
89
|
"types": "./dist/ffBinaries.d.ts"
|
|
90
90
|
},
|
|
91
|
+
"./media-alpha": {
|
|
92
|
+
"import": "./dist/mediaAlpha.js",
|
|
93
|
+
"types": "./dist/mediaAlpha.d.ts"
|
|
94
|
+
},
|
|
91
95
|
"./asset-resolution": {
|
|
92
96
|
"import": "./dist/assetResolution.js",
|
|
93
97
|
"types": "./dist/assetResolution.d.ts"
|
|
@@ -131,7 +135,7 @@
|
|
|
131
135
|
"tsx": "^4.21.0",
|
|
132
136
|
"typescript": "^5.0.0",
|
|
133
137
|
"vitest": "^4.1.11",
|
|
134
|
-
"@hyperframes/core": "0.8.
|
|
138
|
+
"@hyperframes/core": "0.8.184"
|
|
135
139
|
},
|
|
136
140
|
"scripts": {
|
|
137
141
|
"build": "tsup",
|