@adonis-agora/media 0.24.0 → 0.25.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/CHANGELOG.md +12 -0
- package/README.md +12 -4
- package/dist/providers/media_provider.d.ts.map +1 -1
- package/dist/providers/media_provider.js +3 -0
- package/dist/providers/media_provider.js.map +1 -1
- package/dist/src/define_config.d.ts +6 -0
- package/dist/src/define_config.d.ts.map +1 -1
- package/dist/src/define_config.js.map +1 -1
- package/dist/src/index.d.ts +8 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/media_access.d.ts +65 -0
- package/dist/src/media_access.d.ts.map +1 -1
- package/dist/src/media_access.js +106 -7
- package/dist/src/media_access.js.map +1 -1
- package/dist/src/media_library.d.ts +66 -0
- package/dist/src/media_library.d.ts.map +1 -1
- package/dist/src/media_library.js +132 -0
- package/dist/src/media_library.js.map +1 -1
- package/dist/src/media_manager.d.ts +2 -0
- package/dist/src/media_manager.d.ts.map +1 -1
- package/dist/src/media_manager.js +3 -0
- package/dist/src/media_manager.js.map +1 -1
- package/dist/src/streaming.d.ts +78 -0
- package/dist/src/streaming.d.ts.map +1 -0
- package/dist/src/streaming.js +143 -0
- package/dist/src/streaming.js.map +1 -0
- package/dist/src/transformers/dash.d.ts +70 -0
- package/dist/src/transformers/dash.d.ts.map +1 -0
- package/dist/src/transformers/dash.js +80 -0
- package/dist/src/transformers/dash.js.map +1 -0
- package/dist/src/transformers/factory.d.ts +10 -2
- package/dist/src/transformers/factory.d.ts.map +1 -1
- package/dist/src/transformers/factory.js +12 -2
- package/dist/src/transformers/factory.js.map +1 -1
- package/dist/src/transformers/ffmpeg.d.ts +38 -0
- package/dist/src/transformers/ffmpeg.d.ts.map +1 -1
- package/dist/src/transformers/ffmpeg.js +102 -10
- package/dist/src/transformers/ffmpeg.js.map +1 -1
- package/package.json +3 -3
- package/skills/media-stores-delivery/SKILL.md +10 -5
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { isRelativeUri, rewriteHlsPlaylist } from './hls/playlist.js';
|
|
2
|
+
/** Content type of an HLS playlist (RFC 8216). */
|
|
3
|
+
export const HLS_MIME_TYPE = 'application/vnd.apple.mpegurl';
|
|
4
|
+
/** Content type of a DASH manifest (ISO/IEC 23009-1). */
|
|
5
|
+
export const DASH_MIME_TYPE = 'application/dash+xml';
|
|
6
|
+
/** Format of a manifest file, by extension; `undefined` for anything else. */
|
|
7
|
+
export function streamFormatOf(file) {
|
|
8
|
+
const clean = file.split(/[?#]/, 1)[0].toLowerCase();
|
|
9
|
+
if (clean.endsWith('.m3u8'))
|
|
10
|
+
return 'hls';
|
|
11
|
+
if (clean.endsWith('.mpd'))
|
|
12
|
+
return 'dash';
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The streaming entry points of a record. A conversion counts when its entry artifact is a
|
|
17
|
+
* manifest; a CMAF package (`transformers.dash()`) also lists the HLS master it carries
|
|
18
|
+
* (`meta.hlsEntry`), HLS first, so one conversion yields both formats.
|
|
19
|
+
*
|
|
20
|
+
* Without `conversions`, every HLS entry comes before every DASH one (iOS plays only HLS). With
|
|
21
|
+
* `conversions`, they restrict the entries and set their order exactly, conversion by conversion.
|
|
22
|
+
*/
|
|
23
|
+
export function streamEntries(record, conversions) {
|
|
24
|
+
const names = conversions ?? Object.keys(record.conversions);
|
|
25
|
+
const entries = [];
|
|
26
|
+
for (const conversion of names) {
|
|
27
|
+
const variant = record.conversions[conversion];
|
|
28
|
+
if (!variant?.path || !variant.files)
|
|
29
|
+
continue;
|
|
30
|
+
const prefix = variant.prefix ?? variant.path.slice(0, variant.path.lastIndexOf('/') + 1);
|
|
31
|
+
const entry = variant.path.slice(prefix.length);
|
|
32
|
+
const hlsEntry = variant.meta?.hlsEntry;
|
|
33
|
+
if (typeof hlsEntry === 'string' && hlsEntry !== entry && variant.files.includes(hlsEntry)) {
|
|
34
|
+
entries.push({ conversion, format: 'hls', file: hlsEntry });
|
|
35
|
+
}
|
|
36
|
+
const format = streamFormatOf(entry);
|
|
37
|
+
if (format)
|
|
38
|
+
entries.push({ conversion, format, file: entry });
|
|
39
|
+
}
|
|
40
|
+
if (conversions)
|
|
41
|
+
return entries;
|
|
42
|
+
// Stable: HLS first, keeping the conversions' order within a format.
|
|
43
|
+
return [
|
|
44
|
+
...entries.filter((e) => e.format === 'hls'),
|
|
45
|
+
...entries.filter((e) => e.format === 'dash'),
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
/** Content type for one file of a streaming package, by extension. */
|
|
49
|
+
export function streamArtifactContentType(file) {
|
|
50
|
+
const lower = file.toLowerCase();
|
|
51
|
+
if (lower.endsWith('.m3u8'))
|
|
52
|
+
return HLS_MIME_TYPE;
|
|
53
|
+
if (lower.endsWith('.mpd'))
|
|
54
|
+
return DASH_MIME_TYPE;
|
|
55
|
+
if (lower.endsWith('.ts'))
|
|
56
|
+
return 'video/mp2t';
|
|
57
|
+
if (lower.endsWith('.m4s') || lower.endsWith('.mp4'))
|
|
58
|
+
return 'video/mp4';
|
|
59
|
+
if (lower.endsWith('.m4a'))
|
|
60
|
+
return 'audio/mp4';
|
|
61
|
+
if (lower.endsWith('.aac'))
|
|
62
|
+
return 'audio/aac';
|
|
63
|
+
if (lower.endsWith('.mp3'))
|
|
64
|
+
return 'audio/mpeg';
|
|
65
|
+
if (lower.endsWith('.vtt'))
|
|
66
|
+
return 'text/vtt';
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
/** Append a query string (`exp=…&sig=…`, no `?`) to a URI that may already carry one. */
|
|
70
|
+
export function withQuery(uri, query) {
|
|
71
|
+
if (query === '')
|
|
72
|
+
return uri;
|
|
73
|
+
const hash = uri.indexOf('#');
|
|
74
|
+
const base = hash === -1 ? uri : uri.slice(0, hash);
|
|
75
|
+
const fragment = hash === -1 ? '' : uri.slice(hash);
|
|
76
|
+
return `${base}${base.includes('?') ? '&' : '?'}${query}${fragment}`;
|
|
77
|
+
}
|
|
78
|
+
/** DASH attributes holding a URL or URL template. */
|
|
79
|
+
const DASH_URL_ATTRIBUTE = /\b(initialization|media|sourceURL)="([^"]*)"/g;
|
|
80
|
+
const DASH_BASE_URL = /<BaseURL([^>]*)>([^<]*)<\/BaseURL>/g;
|
|
81
|
+
/**
|
|
82
|
+
* Rewrite every **relative** URL of a DASH manifest through `rewrite`: `SegmentTemplate`
|
|
83
|
+
* `initialization`/`media` (templates such as `chunk-$Number%05d$.m4s` included — whatever is
|
|
84
|
+
* appended stays outside the `$…$` identifiers), `SegmentURL`/`Initialization` `sourceURL` and
|
|
85
|
+
* `media`, and `<BaseURL>` text. `rewrite` gets and returns raw URLs; XML escaping is
|
|
86
|
+
* handled here. Absolute references and everything else stay byte for byte.
|
|
87
|
+
*/
|
|
88
|
+
export async function rewriteDashManifest(content, rewrite) {
|
|
89
|
+
const apply = async (escaped) => {
|
|
90
|
+
const uri = unescapeXml(escaped);
|
|
91
|
+
if (uri === '' || !isRelativeUri(uri))
|
|
92
|
+
return escaped;
|
|
93
|
+
return escapeXml(await rewrite(uri));
|
|
94
|
+
};
|
|
95
|
+
let output = await replaceAsync(content, DASH_URL_ATTRIBUTE, async (match) => {
|
|
96
|
+
const [, name, value] = match;
|
|
97
|
+
return `${name}="${await apply(value)}"`;
|
|
98
|
+
});
|
|
99
|
+
output = await replaceAsync(output, DASH_BASE_URL, async (match) => {
|
|
100
|
+
const [, attributes, value] = match;
|
|
101
|
+
return `<BaseURL${attributes}>${await apply(value.trim())}</BaseURL>`;
|
|
102
|
+
});
|
|
103
|
+
return output;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Add `query` to every relative reference of a manifest (`.m3u8` or `.mpd`) — how a signature
|
|
107
|
+
* travels from the manifest request to the segment requests it leads to.
|
|
108
|
+
*/
|
|
109
|
+
export async function signManifest(file, content, query) {
|
|
110
|
+
if (query === '')
|
|
111
|
+
return content;
|
|
112
|
+
const format = streamFormatOf(file);
|
|
113
|
+
if (format === 'hls')
|
|
114
|
+
return rewriteHlsPlaylist(content, (ref) => withQuery(ref.uri, query));
|
|
115
|
+
if (format === 'dash')
|
|
116
|
+
return rewriteDashManifest(content, (uri) => withQuery(uri, query));
|
|
117
|
+
return content;
|
|
118
|
+
}
|
|
119
|
+
async function replaceAsync(input, pattern, replacer) {
|
|
120
|
+
let output = '';
|
|
121
|
+
let consumed = 0;
|
|
122
|
+
for (const match of input.matchAll(pattern)) {
|
|
123
|
+
output += input.slice(consumed, match.index) + (await replacer(match));
|
|
124
|
+
consumed = (match.index ?? 0) + match[0].length;
|
|
125
|
+
}
|
|
126
|
+
return output + input.slice(consumed);
|
|
127
|
+
}
|
|
128
|
+
function escapeXml(value) {
|
|
129
|
+
return value
|
|
130
|
+
.replace(/&/g, '&')
|
|
131
|
+
.replace(/"/g, '"')
|
|
132
|
+
.replace(/</g, '<')
|
|
133
|
+
.replace(/>/g, '>');
|
|
134
|
+
}
|
|
135
|
+
function unescapeXml(value) {
|
|
136
|
+
return value
|
|
137
|
+
.replace(/"/g, '"')
|
|
138
|
+
.replace(/</g, '<')
|
|
139
|
+
.replace(/>/g, '>')
|
|
140
|
+
.replace(/'/g, "'")
|
|
141
|
+
.replace(/&/g, '&');
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=streaming.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming.js","sourceRoot":"","sources":["../../src/streaming.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAiBtE,kDAAkD;AAClD,MAAM,CAAC,MAAM,aAAa,GAAG,+BAA+B,CAAC;AAE7D,yDAAyD;AACzD,MAAM,CAAC,MAAM,cAAc,GAAG,sBAAsB,CAAC;AAqCrD,8EAA8E;AAC9E,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,MAAM,KAAK,GAAI,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K,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;QACvE,QAAQ,GAAG,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAClD,CAAC;IACD,OAAO,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AACxC,CAAC;AAED,SAAS,SAAS,CAAC,KAAa;IAC9B,OAAO,KAAK;SACT,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;SACvB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC3B,CAAC;AAED,SAAS,WAAW,CAAC,KAAa;IAChC,OAAO,KAAK;SACT,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC;SACvB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;SACrB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;SACrB,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC;SACvB,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { Transformer, TransformerContext, TransformResult } from '../transformer.js';
|
|
2
|
+
import type { HlsRemuxSummary } from './hls.js';
|
|
3
|
+
/** What {@link DashPackageEngine.package} receives. */
|
|
4
|
+
export interface DashPackageRequest {
|
|
5
|
+
/** Local path of the source file. */
|
|
6
|
+
sourcePath: string;
|
|
7
|
+
/** Local directory the engine writes the whole package into. */
|
|
8
|
+
outputDir: string;
|
|
9
|
+
/** File name of the DASH manifest, e.g. `manifest.mpd`. */
|
|
10
|
+
manifestName: string;
|
|
11
|
+
/**
|
|
12
|
+
* File name of an HLS master playlist to write over the **same** segments, or `undefined` for a
|
|
13
|
+
* DASH-only package.
|
|
14
|
+
*/
|
|
15
|
+
hlsEntryName?: string | undefined;
|
|
16
|
+
/** Target segment duration in seconds. */
|
|
17
|
+
targetDuration: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The engine seam of {@link DashTransformer}: local file in, a CMAF package (fragmented-MP4
|
|
21
|
+
* segments, an MPD, optionally an HLS master over the same segments) in a local directory out.
|
|
22
|
+
* The default is {@link ffmpegDashEngine}; tests inject a fake that writes files.
|
|
23
|
+
*/
|
|
24
|
+
export interface DashPackageEngine {
|
|
25
|
+
package(request: DashPackageRequest): Promise<HlsRemuxSummary>;
|
|
26
|
+
}
|
|
27
|
+
export interface DashTransformerOptions<Name extends string = 'dash'> {
|
|
28
|
+
/** Conversion name on the record. Default `'dash'`. */
|
|
29
|
+
name?: Name;
|
|
30
|
+
/** Run inside attach. Default `false`: packaging a video takes real time — run it from a job. */
|
|
31
|
+
eager?: boolean;
|
|
32
|
+
/** Target segment duration in seconds. Default 4. */
|
|
33
|
+
targetDuration?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Also write an HLS master playlist over the same segments. Default `true`: the segments are
|
|
36
|
+
* CMAF (fragmented MP4), which both formats play, so HLS costs a few playlists and no extra
|
|
37
|
+
* storage — and Safari/iOS, which play HLS natively but not DASH, are covered by one package.
|
|
38
|
+
*/
|
|
39
|
+
hls?: boolean;
|
|
40
|
+
/** Replace the engine. Default `engines.ffmpegDash()` (remux; pass a `ladder` to transcode). */
|
|
41
|
+
engine?: DashPackageEngine;
|
|
42
|
+
}
|
|
43
|
+
/** File name of the manifest a {@link DashTransformer} produces. */
|
|
44
|
+
export declare const DASH_MANIFEST = "manifest.mpd";
|
|
45
|
+
/** File name of the HLS master playlist a {@link DashTransformer} writes alongside (`hls: true`). */
|
|
46
|
+
export declare const DASH_HLS_ENTRY = "index.m3u8";
|
|
47
|
+
/**
|
|
48
|
+
* Video → a **CMAF** package: fragmented-MP4 segments described by a DASH manifest
|
|
49
|
+
* (`manifest.mpd`, the conversion entry) and, by default, by an HLS master playlist too
|
|
50
|
+
* (`index.m3u8`, recorded as `meta.hlsEntry`) — one encode, one copy of the segments, both
|
|
51
|
+
* formats. Persisted as `record.conversions['dash']`.
|
|
52
|
+
*
|
|
53
|
+
* The default engine is the system ffmpeg (`engines.ffmpegDash()`), remuxing the source as is;
|
|
54
|
+
* `engines.ffmpegDash({ ladder: engines.ladders.standard })` transcodes an adaptive-bitrate ladder.
|
|
55
|
+
* mediabunny has no DASH muxer, so unlike {@link HlsTransformer} there is no pure-JS default.
|
|
56
|
+
*
|
|
57
|
+
* Serve it with `media.access.streamRoute()`, and play it with `useMediaStream` from
|
|
58
|
+
* `@adonis-agora/media-react` — which picks HLS where it plays natively and dash.js/hls.js
|
|
59
|
+
* elsewhere.
|
|
60
|
+
*/
|
|
61
|
+
export declare class DashTransformer<Name extends string = 'dash'> implements Transformer {
|
|
62
|
+
readonly name: Name;
|
|
63
|
+
readonly eager: boolean;
|
|
64
|
+
private readonly targetDuration;
|
|
65
|
+
private readonly hls;
|
|
66
|
+
private readonly engine;
|
|
67
|
+
constructor(options?: DashTransformerOptions<Name>);
|
|
68
|
+
transform(context: TransformerContext): Promise<TransformResult>;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=dash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dash.d.ts","sourceRoot":"","sources":["../../../src/transformers/dash.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAE1F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAIhD,uDAAuD;AACvD,MAAM,WAAW,kBAAkB;IACjC,qCAAqC;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,gEAAgE;IAChE,SAAS,EAAE,MAAM,CAAC;IAClB,2DAA2D;IAC3D,YAAY,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node:fs/promises';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { streamArtifactContentType } from '../streaming.js';
|
|
5
|
+
import { ffmpegDashEngine } from './ffmpeg.js';
|
|
6
|
+
import { compactMeta } from './hls.js';
|
|
7
|
+
import { withSourceFile } from './source_file.js';
|
|
8
|
+
/** File name of the manifest a {@link DashTransformer} produces. */
|
|
9
|
+
export const DASH_MANIFEST = 'manifest.mpd';
|
|
10
|
+
/** File name of the HLS master playlist a {@link DashTransformer} writes alongside (`hls: true`). */
|
|
11
|
+
export const DASH_HLS_ENTRY = 'index.m3u8';
|
|
12
|
+
/**
|
|
13
|
+
* Video → a **CMAF** package: fragmented-MP4 segments described by a DASH manifest
|
|
14
|
+
* (`manifest.mpd`, the conversion entry) and, by default, by an HLS master playlist too
|
|
15
|
+
* (`index.m3u8`, recorded as `meta.hlsEntry`) — one encode, one copy of the segments, both
|
|
16
|
+
* formats. Persisted as `record.conversions['dash']`.
|
|
17
|
+
*
|
|
18
|
+
* The default engine is the system ffmpeg (`engines.ffmpegDash()`), remuxing the source as is;
|
|
19
|
+
* `engines.ffmpegDash({ ladder: engines.ladders.standard })` transcodes an adaptive-bitrate ladder.
|
|
20
|
+
* mediabunny has no DASH muxer, so unlike {@link HlsTransformer} there is no pure-JS default.
|
|
21
|
+
*
|
|
22
|
+
* Serve it with `media.access.streamRoute()`, and play it with `useMediaStream` from
|
|
23
|
+
* `@adonis-agora/media-react` — which picks HLS where it plays natively and dash.js/hls.js
|
|
24
|
+
* elsewhere.
|
|
25
|
+
*/
|
|
26
|
+
export class DashTransformer {
|
|
27
|
+
name;
|
|
28
|
+
eager;
|
|
29
|
+
targetDuration;
|
|
30
|
+
hls;
|
|
31
|
+
engine;
|
|
32
|
+
constructor(options = {}) {
|
|
33
|
+
this.name = options.name ?? 'dash';
|
|
34
|
+
this.eager = options.eager ?? false;
|
|
35
|
+
this.targetDuration = options.targetDuration ?? 4;
|
|
36
|
+
this.hls = options.hls ?? true;
|
|
37
|
+
this.engine = options.engine;
|
|
38
|
+
}
|
|
39
|
+
async transform(context) {
|
|
40
|
+
const engine = this.engine ?? ffmpegDashEngine();
|
|
41
|
+
return withSourceFile(context, async ({ sourcePath, tempDir }) => {
|
|
42
|
+
const outputDir = join(tempDir, 'dash');
|
|
43
|
+
await mkdir(outputDir, { recursive: true });
|
|
44
|
+
const summary = await engine.package({
|
|
45
|
+
sourcePath,
|
|
46
|
+
outputDir,
|
|
47
|
+
manifestName: DASH_MANIFEST,
|
|
48
|
+
hlsEntryName: this.hls ? DASH_HLS_ENTRY : undefined,
|
|
49
|
+
targetDuration: this.targetDuration,
|
|
50
|
+
});
|
|
51
|
+
const files = (await readdir(outputDir, { recursive: true })).sort();
|
|
52
|
+
let segmentCount = 0;
|
|
53
|
+
for (const file of files) {
|
|
54
|
+
const relative = file.split('\\').join('/');
|
|
55
|
+
const local = join(outputDir, file);
|
|
56
|
+
const info = await stat(local);
|
|
57
|
+
if (!info.isFile())
|
|
58
|
+
continue;
|
|
59
|
+
if (!/\.(mpd|m3u8)$/i.test(relative))
|
|
60
|
+
segmentCount += 1;
|
|
61
|
+
const contentType = streamArtifactContentType(relative);
|
|
62
|
+
await context.write(relative, createReadStream(local), {
|
|
63
|
+
contentLength: info.size,
|
|
64
|
+
...(contentType !== undefined ? { contentType } : {}),
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
const relativeFiles = files.map((f) => f.split('\\').join('/'));
|
|
68
|
+
return {
|
|
69
|
+
entry: DASH_MANIFEST,
|
|
70
|
+
meta: compactMeta({
|
|
71
|
+
...summary,
|
|
72
|
+
segmentCount,
|
|
73
|
+
targetDuration: this.targetDuration,
|
|
74
|
+
hlsEntry: this.hls && relativeFiles.includes(DASH_HLS_ENTRY) ? DASH_HLS_ENTRY : undefined,
|
|
75
|
+
}),
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=dash.js.map
|
|
@@ -0,0 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GAAG,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBACtD,CAAC,CAAC;YACL,CAAC;YAED,MAAM,aAAa,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YAChE,OAAO;gBACL,KAAK,EAAE,aAAa;gBACpB,IAAI,EAAE,WAAW,CAAC;oBAChB,GAAG,OAAO;oBACV,YAAY;oBACZ,cAAc,EAAE,IAAI,CAAC,cAAc;oBACnC,QAAQ,EAAE,IAAI,CAAC,GAAG,IAAI,aAAa,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS;iBAC1F,CAAC;aACH,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DashTransformer, type DashTransformerOptions } from './dash.js';
|
|
2
|
+
import { ffmpegDashEngine, ffmpegHlsEngine, ffprobeEngine } from './ffmpeg.js';
|
|
2
3
|
import { HlsTransformer, type HlsTransformerOptions } from './hls.js';
|
|
3
4
|
import { PlaceholderTransformer, type PlaceholderTransformerOptions } from './placeholder.js';
|
|
4
5
|
import { MetadataProbeTransformer, type MetadataProbeTransformerOptions } from './probe.js';
|
|
@@ -26,6 +27,11 @@ import { MetadataProbeTransformer, type MetadataProbeTransformerOptions } from '
|
|
|
26
27
|
export declare const transformers: {
|
|
27
28
|
/** Video → HLS package (MPEG-TS segments + playlists) via mediabunny. Default name `'hls'`. */
|
|
28
29
|
hls<Name extends string = 'hls'>(options?: HlsTransformerOptions<Name>): HlsTransformer<Name>;
|
|
30
|
+
/**
|
|
31
|
+
* Video → CMAF package: a DASH manifest plus (by default) an HLS master over the same
|
|
32
|
+
* fragmented-MP4 segments, via the system ffmpeg. Default name `'dash'`.
|
|
33
|
+
*/
|
|
34
|
+
dash<Name extends string = 'dash'>(options?: DashTransformerOptions<Name>): DashTransformer<Name>;
|
|
29
35
|
/** Metadata-only probe (duration/resolution/codecs) via mediabunny. Default name `'probe'`. */
|
|
30
36
|
probe<Name extends string = 'probe'>(options?: MetadataProbeTransformerOptions<Name>): MetadataProbeTransformer<Name>;
|
|
31
37
|
/**
|
|
@@ -48,9 +54,11 @@ export declare const transformers: {
|
|
|
48
54
|
export declare const engines: {
|
|
49
55
|
/** HLS via system ffmpeg: remux by default, or encode `ladder` into a multi-rendition package. */
|
|
50
56
|
ffmpegHls: typeof ffmpegHlsEngine;
|
|
57
|
+
/** DASH (CMAF, + HLS over the same segments) via system ffmpeg: remux, or encode `ladder`. */
|
|
58
|
+
ffmpegDash: typeof ffmpegDashEngine;
|
|
51
59
|
/** Metadata probe via system ffprobe. */
|
|
52
60
|
ffprobe: typeof ffprobeEngine;
|
|
53
|
-
/** Ready-made ladders for {@link ffmpegHlsEngine}: `standard` (360/720/1080p), `compact` (360/720p). */
|
|
61
|
+
/** Ready-made ladders for {@link ffmpegHlsEngine} / {@link ffmpegDashEngine}: `standard` (360/720/1080p), `compact` (360/720p). */
|
|
54
62
|
ladders: {
|
|
55
63
|
standard: ({
|
|
56
64
|
height: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/transformers/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAW,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/transformers/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,KAAK,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,aAAa,EAAW,MAAM,aAAa,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,KAAK,6BAA6B,EAAE,MAAM,kBAAkB,CAAC;AAC9F,OAAO,EAAE,wBAAwB,EAAE,KAAK,+BAA+B,EAAE,MAAM,YAAY,CAAC;AAE5F;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,YAAY;IACvB,+FAA+F;IAC/F,GAAG,CAAC,IAAI,SAAS,MAAM,GAAG,KAAK,YAAW,qBAAqB,CAAC,IAAI,CAAC;IAGrE;;;OAGG;IACH,IAAI,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,YAAW,sBAAsB,CAAC,IAAI,CAAC;IAGxE,+FAA+F;IAC/F,KAAK,CAAC,IAAI,SAAS,MAAM,GAAG,OAAO,YAAW,+BAA+B,CAAC,IAAI,CAAC;IAGnF;;;OAGG;IACH,WAAW,CAAC,IAAI,SAAS,MAAM,GAAG,aAAa,YACpC,6BAA6B,CAAC,IAAI,CAAC;CAI/C,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,OAAO;IAClB,kGAAkG;;IAElG,8FAA8F;;IAE9F,yCAAyC;;IAEzC,mIAAmI;;;;;;;;;;;;;;;;;;;;;CAEpI,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DashTransformer } from './dash.js';
|
|
2
|
+
import { ffmpegDashEngine, ffmpegHlsEngine, ffprobeEngine, ladders } from './ffmpeg.js';
|
|
2
3
|
import { HlsTransformer } from './hls.js';
|
|
3
4
|
import { PlaceholderTransformer } from './placeholder.js';
|
|
4
5
|
import { MetadataProbeTransformer } from './probe.js';
|
|
@@ -28,6 +29,13 @@ export const transformers = {
|
|
|
28
29
|
hls(options = {}) {
|
|
29
30
|
return new HlsTransformer(options);
|
|
30
31
|
},
|
|
32
|
+
/**
|
|
33
|
+
* Video → CMAF package: a DASH manifest plus (by default) an HLS master over the same
|
|
34
|
+
* fragmented-MP4 segments, via the system ffmpeg. Default name `'dash'`.
|
|
35
|
+
*/
|
|
36
|
+
dash(options = {}) {
|
|
37
|
+
return new DashTransformer(options);
|
|
38
|
+
},
|
|
31
39
|
/** Metadata-only probe (duration/resolution/codecs) via mediabunny. Default name `'probe'`. */
|
|
32
40
|
probe(options = {}) {
|
|
33
41
|
return new MetadataProbeTransformer(options);
|
|
@@ -54,9 +62,11 @@ export const transformers = {
|
|
|
54
62
|
export const engines = {
|
|
55
63
|
/** HLS via system ffmpeg: remux by default, or encode `ladder` into a multi-rendition package. */
|
|
56
64
|
ffmpegHls: ffmpegHlsEngine,
|
|
65
|
+
/** DASH (CMAF, + HLS over the same segments) via system ffmpeg: remux, or encode `ladder`. */
|
|
66
|
+
ffmpegDash: ffmpegDashEngine,
|
|
57
67
|
/** Metadata probe via system ffprobe. */
|
|
58
68
|
ffprobe: ffprobeEngine,
|
|
59
|
-
/** Ready-made ladders for {@link ffmpegHlsEngine}: `standard` (360/720/1080p), `compact` (360/720p). */
|
|
69
|
+
/** Ready-made ladders for {@link ffmpegHlsEngine} / {@link ffmpegDashEngine}: `standard` (360/720/1080p), `compact` (360/720p). */
|
|
60
70
|
ladders,
|
|
61
71
|
};
|
|
62
72
|
//# sourceMappingURL=factory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../src/transformers/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../src/transformers/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAA+B,MAAM,WAAW,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACxF,OAAO,EAAE,cAAc,EAA8B,MAAM,UAAU,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAsC,MAAM,kBAAkB,CAAC;AAC9F,OAAO,EAAE,wBAAwB,EAAwC,MAAM,YAAY,CAAC;AAE5F;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,+FAA+F;IAC/F,GAAG,CAA8B,OAAO,GAAgC,EAAE;QACxE,OAAO,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IACD;;;OAGG;IACH,IAAI,CAA+B,OAAO,GAAiC,EAAE;QAC3E,OAAO,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IACD,+FAA+F;IAC/F,KAAK,CAAgC,OAAO,GAA0C,EAAE;QACtF,OAAO,IAAI,wBAAwB,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC;IACD;;;OAGG;IACH,WAAW,CACT,OAAO,GAAwC,EAAE;QAEjD,OAAO,IAAI,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC;CACF,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,kGAAkG;IAClG,SAAS,EAAE,eAAe;IAC1B,8FAA8F;IAC9F,UAAU,EAAE,gBAAgB;IAC5B,yCAAyC;IACzC,OAAO,EAAE,aAAa;IACtB,mIAAmI;IACnI,OAAO;CACR,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DashPackageEngine } from './dash.js';
|
|
1
2
|
import type { HlsRemuxEngine } from './hls.js';
|
|
2
3
|
import type { MediaProbeEngine } from './probe.js';
|
|
3
4
|
/**
|
|
@@ -95,6 +96,43 @@ export declare function buildHlsArgs(input: {
|
|
|
95
96
|
* (`MediaHlsDeliveryHandler`, playlist rewriting) works unchanged.
|
|
96
97
|
*/
|
|
97
98
|
export declare function ffmpegHlsEngine(options?: FfmpegHlsEngineOptions): HlsRemuxEngine;
|
|
99
|
+
export interface FfmpegDashEngineOptions extends FfmpegBinaryOptions {
|
|
100
|
+
/**
|
|
101
|
+
* Renditions to encode. Omit to **remux** (stream copy into fragmented MP4 — fast, and fMP4
|
|
102
|
+
* carries h264, hevc, vp9 or av1 alike). With a ladder, every rung is transcoded to h264 and
|
|
103
|
+
* listed in the manifest; the audio is encoded once, to AAC, and shared by every rung. Rungs
|
|
104
|
+
* taller than the source are dropped (never upscale).
|
|
105
|
+
*/
|
|
106
|
+
ladder?: FfmpegRendition[];
|
|
107
|
+
/** AAC bitrate of the shared audio track when transcoding. Default: the ladder's highest, else `'128k'`. */
|
|
108
|
+
audioBitrate?: string;
|
|
109
|
+
/** x264 preset when transcoding. Default `'veryfast'`. */
|
|
110
|
+
preset?: string;
|
|
111
|
+
/** Extra ffmpeg arguments, inserted right before the DASH muxer options. */
|
|
112
|
+
extraArgs?: string[];
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Build the ffmpeg argument list for one DASH (CMAF) run — one manifest, fragmented-MP4 segments
|
|
116
|
+
* and, with `hlsEntryName`, an HLS master playlist over the same segments. Exported for tests and
|
|
117
|
+
* for anyone wrapping the engine; `renditions` empty means remux.
|
|
118
|
+
*/
|
|
119
|
+
export declare function buildDashArgs(input: {
|
|
120
|
+
sourcePath: string;
|
|
121
|
+
outputDir: string;
|
|
122
|
+
manifestName: string;
|
|
123
|
+
hlsEntryName?: string | undefined;
|
|
124
|
+
targetDuration: number;
|
|
125
|
+
hasAudio: boolean;
|
|
126
|
+
renditions: FfmpegRendition[];
|
|
127
|
+
audioBitrate: string;
|
|
128
|
+
preset: string;
|
|
129
|
+
extraArgs: string[];
|
|
130
|
+
}): string[];
|
|
131
|
+
/**
|
|
132
|
+
* {@link DashPackageEngine} backed by the system ffmpeg: remux into a CMAF package by default, or
|
|
133
|
+
* an adaptive-bitrate ladder when `ladder` is set. Needs ffmpeg ≥ 4.3 (`-hls_master_name`).
|
|
134
|
+
*/
|
|
135
|
+
export declare function ffmpegDashEngine(options?: FfmpegDashEngineOptions): DashPackageEngine;
|
|
98
136
|
/**
|
|
99
137
|
* {@link MediaProbeEngine} backed by the system ffprobe. Differences from the mediabunny probe:
|
|
100
138
|
* `format` is ffprobe's `format_name` (e.g. `'mov,mp4,m4a,3gp,3g2,mj2'`), and `mimeType` is not
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ffmpeg.d.ts","sourceRoot":"","sources":["../../../src/transformers/ffmpeg.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAoC,MAAM,UAAU,CAAC;AACjF,OAAO,KAAK,EAAE,gBAAgB,EAAqB,MAAM,YAAY,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,8CAA8C;AAC9C,MAAM,WAAW,eAAe;IAC9B,wFAAwF;IACxF,MAAM,EAAE,MAAM,CAAC;IACf,4FAA4F;IAC5F,YAAY,EAAE,MAAM,CAAC;IACrB,sDAAsD;IACtD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,mBAAmB;IAClC,oFAAoF;IACpF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sFAAsF;IACtF,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,sBAAuB,SAAQ,mBAAmB;IACjE;;;;;OAKG;IACH,MAAM,CAAC,EAAE,eAAe,EAAE,CAAC;IAC3B,0DAA0D;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2EAA2E;IAC3E,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAMD,0BAA0B;AAC1B,eAAO,MAAM,OAAO;IAClB,8DAA8D;;;;;;;;;;IAM9D,wDAAwD;;;;;;;;;;CAKb,CAAC;AA0G9C,gGAAgG;AAChG,wBAAgB,eAAe,CAC7B,MAAM,EAAE,eAAe,EAAE,EACzB,YAAY,EAAE,MAAM,GAAG,SAAS,GAC/B,eAAe,EAAE,CAOnB;AAED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AE,CAAC;CACrB,GAAG,MAAM,EAAE,CAgEX;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,uBAA4B,GAAG,iBAAiB,CAmDzF;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,OAAO,GAAE,IAAI,CAAC,mBAAmB,EAAE,aAAa,CAAM,GACrD,gBAAgB,CAOlB"}
|
|
@@ -130,6 +130,20 @@ export function buildHlsArgs(input) {
|
|
|
130
130
|
args.push(...input.extraArgs, '-f', 'hls', '-hls_time', String(targetDuration), '-hls_playlist_type', 'vod', '-hls_segment_filename', join(outputDir, SEGMENT_PATTERN), '-master_pl_name', entryName, '-var_stream_map', streamMap.join(' '), join(outputDir, PLAYLIST_PATTERN));
|
|
131
131
|
return args;
|
|
132
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Validate a ladder while the config is in hand — a bad rung would otherwise fail deep inside
|
|
135
|
+
* libx264 with a cryptic error on the first transcode.
|
|
136
|
+
*/
|
|
137
|
+
function validateLadder(ladder) {
|
|
138
|
+
for (const r of ladder ?? []) {
|
|
139
|
+
if (!Number.isInteger(r.height) || r.height <= 0 || r.height % 2 !== 0) {
|
|
140
|
+
throw new Error(`Invalid rendition height ${r.height} (expected a positive even integer — h264 needs even dimensions)`);
|
|
141
|
+
}
|
|
142
|
+
parseBitrate(r.videoBitrate);
|
|
143
|
+
if (r.audioBitrate !== undefined)
|
|
144
|
+
parseBitrate(r.audioBitrate);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
133
147
|
/** `'2800k'` → 2_800_000. Plain numbers pass through. */
|
|
134
148
|
function parseBitrate(value) {
|
|
135
149
|
const match = /^(\d+(?:\.\d+)?)([kKmM]?)$/.exec(value.trim());
|
|
@@ -148,16 +162,7 @@ function parseBitrate(value) {
|
|
|
148
162
|
export function ffmpegHlsEngine(options = {}) {
|
|
149
163
|
const ffmpegPath = options.ffmpegPath ?? 'ffmpeg';
|
|
150
164
|
const ffprobePath = options.ffprobePath ?? 'ffprobe';
|
|
151
|
-
|
|
152
|
-
// libx264 with a cryptic error on the first transcode.
|
|
153
|
-
for (const r of options.ladder ?? []) {
|
|
154
|
-
if (!Number.isInteger(r.height) || r.height <= 0 || r.height % 2 !== 0) {
|
|
155
|
-
throw new Error(`Invalid rendition height ${r.height} (expected a positive even integer — h264 needs even dimensions)`);
|
|
156
|
-
}
|
|
157
|
-
parseBitrate(r.videoBitrate);
|
|
158
|
-
if (r.audioBitrate !== undefined)
|
|
159
|
-
parseBitrate(r.audioBitrate);
|
|
160
|
-
}
|
|
165
|
+
validateLadder(options.ladder);
|
|
161
166
|
return {
|
|
162
167
|
async remux(request) {
|
|
163
168
|
const summary = await probeSource(ffprobePath, request.sourcePath, 'hls');
|
|
@@ -191,6 +196,93 @@ export function ffmpegHlsEngine(options = {}) {
|
|
|
191
196
|
},
|
|
192
197
|
};
|
|
193
198
|
}
|
|
199
|
+
/** Segment names of a CMAF package; `$…$` are DASH template identifiers ffmpeg fills in. */
|
|
200
|
+
const DASH_INIT_PATTERN = 'init-$RepresentationID$.m4s';
|
|
201
|
+
const DASH_SEGMENT_PATTERN = 'chunk-$RepresentationID$-$Number%05d$.m4s';
|
|
202
|
+
/**
|
|
203
|
+
* Build the ffmpeg argument list for one DASH (CMAF) run — one manifest, fragmented-MP4 segments
|
|
204
|
+
* and, with `hlsEntryName`, an HLS master playlist over the same segments. Exported for tests and
|
|
205
|
+
* for anyone wrapping the engine; `renditions` empty means remux.
|
|
206
|
+
*/
|
|
207
|
+
export function buildDashArgs(input) {
|
|
208
|
+
const { sourcePath, outputDir, targetDuration, hasAudio, renditions } = input;
|
|
209
|
+
const args = ['-hide_banner', '-y', '-i', sourcePath];
|
|
210
|
+
if (renditions.length === 0) {
|
|
211
|
+
args.push('-map', '0:v:0');
|
|
212
|
+
if (hasAudio)
|
|
213
|
+
args.push('-map', '0:a:0');
|
|
214
|
+
args.push('-c', 'copy');
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
const n = renditions.length;
|
|
218
|
+
const splits = renditions.map((_, i) => `[v${i}]`).join('');
|
|
219
|
+
const scales = renditions.map((r, i) => `[v${i}]scale=-2:${r.height}[v${i}o]`).join(';');
|
|
220
|
+
args.push('-filter_complex', `[0:v:0]split=${n}${splits};${scales}`);
|
|
221
|
+
renditions.forEach((r, i) => {
|
|
222
|
+
const peak = `${Math.round(parseBitrate(r.videoBitrate) * 1.5)}`;
|
|
223
|
+
args.push('-map', `[v${i}o]`, `-c:v:${i}`, 'libx264', `-b:v:${i}`, r.videoBitrate, `-maxrate:v:${i}`, peak, `-bufsize:v:${i}`, `${Number(peak) * 2}`);
|
|
224
|
+
});
|
|
225
|
+
// DASH shares one audio track across the video rungs (its own adaptation set).
|
|
226
|
+
if (hasAudio)
|
|
227
|
+
args.push('-map', '0:a:0', '-c:a', 'aac', '-b:a', input.audioBitrate);
|
|
228
|
+
args.push('-preset', input.preset, '-pix_fmt', 'yuv420p', '-sc_threshold', '0', '-force_key_frames', `expr:gte(t,n_forced*${targetDuration})`);
|
|
229
|
+
}
|
|
230
|
+
args.push(...input.extraArgs, '-f', 'dash', '-seg_duration', String(targetDuration), '-use_template', '1', '-use_timeline', '1', '-adaptation_sets', hasAudio ? 'id=0,streams=v id=1,streams=a' : 'id=0,streams=v', '-init_seg_name', DASH_INIT_PATTERN, '-media_seg_name', DASH_SEGMENT_PATTERN);
|
|
231
|
+
if (input.hlsEntryName) {
|
|
232
|
+
args.push('-hls_playlist', '1', '-hls_master_name', input.hlsEntryName);
|
|
233
|
+
}
|
|
234
|
+
args.push(join(outputDir, input.manifestName));
|
|
235
|
+
return args;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* {@link DashPackageEngine} backed by the system ffmpeg: remux into a CMAF package by default, or
|
|
239
|
+
* an adaptive-bitrate ladder when `ladder` is set. Needs ffmpeg ≥ 4.3 (`-hls_master_name`).
|
|
240
|
+
*/
|
|
241
|
+
export function ffmpegDashEngine(options = {}) {
|
|
242
|
+
const ffmpegPath = options.ffmpegPath ?? 'ffmpeg';
|
|
243
|
+
const ffprobePath = options.ffprobePath ?? 'ffprobe';
|
|
244
|
+
validateLadder(options.ladder);
|
|
245
|
+
if (options.audioBitrate !== undefined)
|
|
246
|
+
parseBitrate(options.audioBitrate);
|
|
247
|
+
const audioBitrate = options.audioBitrate ??
|
|
248
|
+
[...(options.ladder ?? [])]
|
|
249
|
+
.map((r) => r.audioBitrate)
|
|
250
|
+
.filter((b) => b !== undefined)
|
|
251
|
+
.sort((a, b) => parseBitrate(b) - parseBitrate(a))[0] ??
|
|
252
|
+
'128k';
|
|
253
|
+
return {
|
|
254
|
+
async package(request) {
|
|
255
|
+
const summary = await probeSource(ffprobePath, request.sourcePath, 'dash');
|
|
256
|
+
if (!summary.hasVideo) {
|
|
257
|
+
throw new HlsSourceUnsupportedError('the source has no video stream', 'DASH packaging needs a video track; this file is audio-only or not a video.');
|
|
258
|
+
}
|
|
259
|
+
const renditions = options.ladder ? effectiveLadder(options.ladder, summary.height) : [];
|
|
260
|
+
await run(ffmpegPath, buildDashArgs({
|
|
261
|
+
sourcePath: request.sourcePath,
|
|
262
|
+
outputDir: request.outputDir,
|
|
263
|
+
manifestName: request.manifestName,
|
|
264
|
+
hlsEntryName: request.hlsEntryName,
|
|
265
|
+
targetDuration: request.targetDuration,
|
|
266
|
+
hasAudio: summary.hasAudio,
|
|
267
|
+
renditions,
|
|
268
|
+
audioBitrate,
|
|
269
|
+
preset: options.preset ?? 'veryfast',
|
|
270
|
+
extraArgs: options.extraArgs ?? [],
|
|
271
|
+
}), 'dash');
|
|
272
|
+
const result = {};
|
|
273
|
+
if (summary.durationSeconds !== undefined)
|
|
274
|
+
result.durationSeconds = summary.durationSeconds;
|
|
275
|
+
if (summary.width !== undefined)
|
|
276
|
+
result.width = summary.width;
|
|
277
|
+
if (summary.height !== undefined)
|
|
278
|
+
result.height = summary.height;
|
|
279
|
+
result.videoCodec = renditions.length > 0 ? 'h264' : (summary.videoCodec ?? null);
|
|
280
|
+
if (summary.hasAudio)
|
|
281
|
+
result.audioCodec = renditions.length > 0 ? 'aac' : (summary.audioCodec ?? null);
|
|
282
|
+
return result;
|
|
283
|
+
},
|
|
284
|
+
};
|
|
285
|
+
}
|
|
194
286
|
/**
|
|
195
287
|
* {@link MediaProbeEngine} backed by the system ffprobe. Differences from the mediabunny probe:
|
|
196
288
|
* `format` is ffprobe's `format_name` (e.g. `'mov,mp4,m4a,3gp,3g2,mj2'`), and `mimeType` is not
|