@editframe/assets 0.15.0-beta.13 → 0.15.0-beta.15
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/Probe.d.ts +41 -38
- package/dist/Probe.js +29 -8
- package/dist/idempotentTask.js +24 -0
- package/dist/tasks/cacheRemoteAsset.d.ts +1 -0
- package/package.json +1 -1
- package/src/tasks/cacheRemoteAsset.ts +0 -0
- package/types.json +1 -1
package/dist/Probe.d.ts
CHANGED
|
@@ -10,14 +10,14 @@ export declare const AudioStreamSchema: z.ZodObject<{
|
|
|
10
10
|
sample_fmt: z.ZodString;
|
|
11
11
|
sample_rate: z.ZodString;
|
|
12
12
|
channels: z.ZodNumber;
|
|
13
|
-
channel_layout: z.ZodString
|
|
13
|
+
channel_layout: z.ZodOptional<z.ZodString>;
|
|
14
14
|
bits_per_sample: z.ZodNumber;
|
|
15
15
|
initial_padding: z.ZodOptional<z.ZodNumber>;
|
|
16
16
|
r_frame_rate: z.ZodString;
|
|
17
17
|
avg_frame_rate: z.ZodString;
|
|
18
18
|
time_base: z.ZodString;
|
|
19
|
-
start_pts: z.ZodNumber
|
|
20
|
-
start_time: z.ZodNumber
|
|
19
|
+
start_pts: z.ZodOptional<z.ZodNumber>;
|
|
20
|
+
start_time: z.ZodOptional<z.ZodNumber>;
|
|
21
21
|
duration_ts: z.ZodNumber;
|
|
22
22
|
duration: z.ZodNumber;
|
|
23
23
|
bit_rate: z.ZodString;
|
|
@@ -33,17 +33,17 @@ export declare const AudioStreamSchema: z.ZodObject<{
|
|
|
33
33
|
sample_fmt: string;
|
|
34
34
|
sample_rate: string;
|
|
35
35
|
channels: number;
|
|
36
|
-
channel_layout: string;
|
|
37
36
|
bits_per_sample: number;
|
|
38
37
|
r_frame_rate: string;
|
|
39
38
|
avg_frame_rate: string;
|
|
40
39
|
time_base: string;
|
|
41
|
-
start_pts: number;
|
|
42
|
-
start_time: number;
|
|
43
40
|
duration_ts: number;
|
|
44
41
|
bit_rate: string;
|
|
45
42
|
disposition: Record<string, unknown>;
|
|
43
|
+
channel_layout?: string | undefined;
|
|
46
44
|
initial_padding?: number | undefined;
|
|
45
|
+
start_pts?: number | undefined;
|
|
46
|
+
start_time?: number | undefined;
|
|
47
47
|
}, {
|
|
48
48
|
duration: number;
|
|
49
49
|
index: number;
|
|
@@ -55,17 +55,17 @@ export declare const AudioStreamSchema: z.ZodObject<{
|
|
|
55
55
|
sample_fmt: string;
|
|
56
56
|
sample_rate: string;
|
|
57
57
|
channels: number;
|
|
58
|
-
channel_layout: string;
|
|
59
58
|
bits_per_sample: number;
|
|
60
59
|
r_frame_rate: string;
|
|
61
60
|
avg_frame_rate: string;
|
|
62
61
|
time_base: string;
|
|
63
|
-
start_pts: number;
|
|
64
|
-
start_time: number;
|
|
65
62
|
duration_ts: number;
|
|
66
63
|
bit_rate: string;
|
|
67
64
|
disposition: Record<string, unknown>;
|
|
65
|
+
channel_layout?: string | undefined;
|
|
68
66
|
initial_padding?: number | undefined;
|
|
67
|
+
start_pts?: number | undefined;
|
|
68
|
+
start_time?: number | undefined;
|
|
69
69
|
}>;
|
|
70
70
|
export type AudioStreamSchema = z.infer<typeof AudioStreamSchema>;
|
|
71
71
|
export declare const VideoStreamSchema: z.ZodObject<{
|
|
@@ -154,14 +154,14 @@ declare const StreamSchema: z.ZodDiscriminatedUnion<"codec_type", [z.ZodObject<{
|
|
|
154
154
|
sample_fmt: z.ZodString;
|
|
155
155
|
sample_rate: z.ZodString;
|
|
156
156
|
channels: z.ZodNumber;
|
|
157
|
-
channel_layout: z.ZodString
|
|
157
|
+
channel_layout: z.ZodOptional<z.ZodString>;
|
|
158
158
|
bits_per_sample: z.ZodNumber;
|
|
159
159
|
initial_padding: z.ZodOptional<z.ZodNumber>;
|
|
160
160
|
r_frame_rate: z.ZodString;
|
|
161
161
|
avg_frame_rate: z.ZodString;
|
|
162
162
|
time_base: z.ZodString;
|
|
163
|
-
start_pts: z.ZodNumber
|
|
164
|
-
start_time: z.ZodNumber
|
|
163
|
+
start_pts: z.ZodOptional<z.ZodNumber>;
|
|
164
|
+
start_time: z.ZodOptional<z.ZodNumber>;
|
|
165
165
|
duration_ts: z.ZodNumber;
|
|
166
166
|
duration: z.ZodNumber;
|
|
167
167
|
bit_rate: z.ZodString;
|
|
@@ -177,17 +177,17 @@ declare const StreamSchema: z.ZodDiscriminatedUnion<"codec_type", [z.ZodObject<{
|
|
|
177
177
|
sample_fmt: string;
|
|
178
178
|
sample_rate: string;
|
|
179
179
|
channels: number;
|
|
180
|
-
channel_layout: string;
|
|
181
180
|
bits_per_sample: number;
|
|
182
181
|
r_frame_rate: string;
|
|
183
182
|
avg_frame_rate: string;
|
|
184
183
|
time_base: string;
|
|
185
|
-
start_pts: number;
|
|
186
|
-
start_time: number;
|
|
187
184
|
duration_ts: number;
|
|
188
185
|
bit_rate: string;
|
|
189
186
|
disposition: Record<string, unknown>;
|
|
187
|
+
channel_layout?: string | undefined;
|
|
190
188
|
initial_padding?: number | undefined;
|
|
189
|
+
start_pts?: number | undefined;
|
|
190
|
+
start_time?: number | undefined;
|
|
191
191
|
}, {
|
|
192
192
|
duration: number;
|
|
193
193
|
index: number;
|
|
@@ -199,17 +199,17 @@ declare const StreamSchema: z.ZodDiscriminatedUnion<"codec_type", [z.ZodObject<{
|
|
|
199
199
|
sample_fmt: string;
|
|
200
200
|
sample_rate: string;
|
|
201
201
|
channels: number;
|
|
202
|
-
channel_layout: string;
|
|
203
202
|
bits_per_sample: number;
|
|
204
203
|
r_frame_rate: string;
|
|
205
204
|
avg_frame_rate: string;
|
|
206
205
|
time_base: string;
|
|
207
|
-
start_pts: number;
|
|
208
|
-
start_time: number;
|
|
209
206
|
duration_ts: number;
|
|
210
207
|
bit_rate: string;
|
|
211
208
|
disposition: Record<string, unknown>;
|
|
209
|
+
channel_layout?: string | undefined;
|
|
212
210
|
initial_padding?: number | undefined;
|
|
211
|
+
start_pts?: number | undefined;
|
|
212
|
+
start_time?: number | undefined;
|
|
213
213
|
}>, z.ZodObject<{
|
|
214
214
|
index: z.ZodNumber;
|
|
215
215
|
codec_name: z.ZodString;
|
|
@@ -295,14 +295,14 @@ declare const ProbeSchema: z.ZodObject<{
|
|
|
295
295
|
sample_fmt: z.ZodString;
|
|
296
296
|
sample_rate: z.ZodString;
|
|
297
297
|
channels: z.ZodNumber;
|
|
298
|
-
channel_layout: z.ZodString
|
|
298
|
+
channel_layout: z.ZodOptional<z.ZodString>;
|
|
299
299
|
bits_per_sample: z.ZodNumber;
|
|
300
300
|
initial_padding: z.ZodOptional<z.ZodNumber>;
|
|
301
301
|
r_frame_rate: z.ZodString;
|
|
302
302
|
avg_frame_rate: z.ZodString;
|
|
303
303
|
time_base: z.ZodString;
|
|
304
|
-
start_pts: z.ZodNumber
|
|
305
|
-
start_time: z.ZodNumber
|
|
304
|
+
start_pts: z.ZodOptional<z.ZodNumber>;
|
|
305
|
+
start_time: z.ZodOptional<z.ZodNumber>;
|
|
306
306
|
duration_ts: z.ZodNumber;
|
|
307
307
|
duration: z.ZodNumber;
|
|
308
308
|
bit_rate: z.ZodString;
|
|
@@ -318,17 +318,17 @@ declare const ProbeSchema: z.ZodObject<{
|
|
|
318
318
|
sample_fmt: string;
|
|
319
319
|
sample_rate: string;
|
|
320
320
|
channels: number;
|
|
321
|
-
channel_layout: string;
|
|
322
321
|
bits_per_sample: number;
|
|
323
322
|
r_frame_rate: string;
|
|
324
323
|
avg_frame_rate: string;
|
|
325
324
|
time_base: string;
|
|
326
|
-
start_pts: number;
|
|
327
|
-
start_time: number;
|
|
328
325
|
duration_ts: number;
|
|
329
326
|
bit_rate: string;
|
|
330
327
|
disposition: Record<string, unknown>;
|
|
328
|
+
channel_layout?: string | undefined;
|
|
331
329
|
initial_padding?: number | undefined;
|
|
330
|
+
start_pts?: number | undefined;
|
|
331
|
+
start_time?: number | undefined;
|
|
332
332
|
}, {
|
|
333
333
|
duration: number;
|
|
334
334
|
index: number;
|
|
@@ -340,17 +340,17 @@ declare const ProbeSchema: z.ZodObject<{
|
|
|
340
340
|
sample_fmt: string;
|
|
341
341
|
sample_rate: string;
|
|
342
342
|
channels: number;
|
|
343
|
-
channel_layout: string;
|
|
344
343
|
bits_per_sample: number;
|
|
345
344
|
r_frame_rate: string;
|
|
346
345
|
avg_frame_rate: string;
|
|
347
346
|
time_base: string;
|
|
348
|
-
start_pts: number;
|
|
349
|
-
start_time: number;
|
|
350
347
|
duration_ts: number;
|
|
351
348
|
bit_rate: string;
|
|
352
349
|
disposition: Record<string, unknown>;
|
|
350
|
+
channel_layout?: string | undefined;
|
|
353
351
|
initial_padding?: number | undefined;
|
|
352
|
+
start_pts?: number | undefined;
|
|
353
|
+
start_time?: number | undefined;
|
|
354
354
|
}>, z.ZodObject<{
|
|
355
355
|
index: z.ZodNumber;
|
|
356
356
|
codec_name: z.ZodString;
|
|
@@ -482,17 +482,17 @@ declare const ProbeSchema: z.ZodObject<{
|
|
|
482
482
|
sample_fmt: string;
|
|
483
483
|
sample_rate: string;
|
|
484
484
|
channels: number;
|
|
485
|
-
channel_layout: string;
|
|
486
485
|
bits_per_sample: number;
|
|
487
486
|
r_frame_rate: string;
|
|
488
487
|
avg_frame_rate: string;
|
|
489
488
|
time_base: string;
|
|
490
|
-
start_pts: number;
|
|
491
|
-
start_time: number;
|
|
492
489
|
duration_ts: number;
|
|
493
490
|
bit_rate: string;
|
|
494
491
|
disposition: Record<string, unknown>;
|
|
492
|
+
channel_layout?: string | undefined;
|
|
495
493
|
initial_padding?: number | undefined;
|
|
494
|
+
start_pts?: number | undefined;
|
|
495
|
+
start_time?: number | undefined;
|
|
496
496
|
} | {
|
|
497
497
|
index: number;
|
|
498
498
|
codec_name: string;
|
|
@@ -542,17 +542,17 @@ declare const ProbeSchema: z.ZodObject<{
|
|
|
542
542
|
sample_fmt: string;
|
|
543
543
|
sample_rate: string;
|
|
544
544
|
channels: number;
|
|
545
|
-
channel_layout: string;
|
|
546
545
|
bits_per_sample: number;
|
|
547
546
|
r_frame_rate: string;
|
|
548
547
|
avg_frame_rate: string;
|
|
549
548
|
time_base: string;
|
|
550
|
-
start_pts: number;
|
|
551
|
-
start_time: number;
|
|
552
549
|
duration_ts: number;
|
|
553
550
|
bit_rate: string;
|
|
554
551
|
disposition: Record<string, unknown>;
|
|
552
|
+
channel_layout?: string | undefined;
|
|
555
553
|
initial_padding?: number | undefined;
|
|
554
|
+
start_pts?: number | undefined;
|
|
555
|
+
start_time?: number | undefined;
|
|
556
556
|
} | {
|
|
557
557
|
index: number;
|
|
558
558
|
codec_name: string;
|
|
@@ -638,17 +638,17 @@ export declare class Probe {
|
|
|
638
638
|
sample_fmt: string;
|
|
639
639
|
sample_rate: string;
|
|
640
640
|
channels: number;
|
|
641
|
-
channel_layout: string;
|
|
642
641
|
bits_per_sample: number;
|
|
643
642
|
r_frame_rate: string;
|
|
644
643
|
avg_frame_rate: string;
|
|
645
644
|
time_base: string;
|
|
646
|
-
start_pts: number;
|
|
647
|
-
start_time: number;
|
|
648
645
|
duration_ts: number;
|
|
649
646
|
bit_rate: string;
|
|
650
647
|
disposition: Record<string, unknown>;
|
|
648
|
+
channel_layout?: string | undefined;
|
|
651
649
|
initial_padding?: number | undefined;
|
|
650
|
+
start_pts?: number | undefined;
|
|
651
|
+
start_time?: number | undefined;
|
|
652
652
|
} | {
|
|
653
653
|
index: number;
|
|
654
654
|
codec_name: string;
|
|
@@ -693,10 +693,13 @@ export declare class Probe {
|
|
|
693
693
|
get hasAudio(): boolean;
|
|
694
694
|
get hasVideo(): boolean;
|
|
695
695
|
get isAudioOnly(): boolean;
|
|
696
|
+
get isMp3(): boolean;
|
|
696
697
|
get isVideoOnly(): boolean;
|
|
697
698
|
get mustProcess(): boolean;
|
|
698
|
-
get
|
|
699
|
-
get
|
|
699
|
+
get ffmpegAudioInputOptions(): string[];
|
|
700
|
+
get ffmpegVideoInputOptions(): never[];
|
|
701
|
+
get ffmpegAudioOutputOptions(): string[];
|
|
702
|
+
get ffmpegVideoOutputOptions(): string[];
|
|
700
703
|
createConformingReadstream(): Readable;
|
|
701
704
|
}
|
|
702
705
|
export {};
|
package/dist/Probe.js
CHANGED
|
@@ -15,14 +15,14 @@ const AudioStreamSchema = z.object({
|
|
|
15
15
|
sample_fmt: z.string(),
|
|
16
16
|
sample_rate: z.string(),
|
|
17
17
|
channels: z.number(),
|
|
18
|
-
channel_layout: z.string(),
|
|
18
|
+
channel_layout: z.string().optional(),
|
|
19
19
|
bits_per_sample: z.number(),
|
|
20
20
|
initial_padding: z.number().optional(),
|
|
21
21
|
r_frame_rate: z.string(),
|
|
22
22
|
avg_frame_rate: z.string(),
|
|
23
23
|
time_base: z.string(),
|
|
24
|
-
start_pts: z.number(),
|
|
25
|
-
start_time: z.coerce.number(),
|
|
24
|
+
start_pts: z.number().optional(),
|
|
25
|
+
start_time: z.coerce.number().optional(),
|
|
26
26
|
duration_ts: z.number(),
|
|
27
27
|
duration: z.coerce.number(),
|
|
28
28
|
bit_rate: z.string(),
|
|
@@ -188,13 +188,30 @@ class Probe {
|
|
|
188
188
|
get isAudioOnly() {
|
|
189
189
|
return this.audioStreams.length > 0 && this.videoStreams.length === 0;
|
|
190
190
|
}
|
|
191
|
+
get isMp3() {
|
|
192
|
+
return this.audioStreams.some(
|
|
193
|
+
(stream) => stream.codec_name === "mp3"
|
|
194
|
+
);
|
|
195
|
+
}
|
|
191
196
|
get isVideoOnly() {
|
|
192
197
|
return this.audioStreams.length === 0 && this.videoStreams.length > 0;
|
|
193
198
|
}
|
|
194
199
|
get mustProcess() {
|
|
195
200
|
return this.mustReencodeAudio || this.mustReencodeVideo || this.mustRemux;
|
|
196
201
|
}
|
|
197
|
-
get
|
|
202
|
+
get ffmpegAudioInputOptions() {
|
|
203
|
+
if (!this.hasAudio) {
|
|
204
|
+
return [];
|
|
205
|
+
}
|
|
206
|
+
if (this.isMp3) {
|
|
207
|
+
return ["-c:a", "mp3"];
|
|
208
|
+
}
|
|
209
|
+
return [];
|
|
210
|
+
}
|
|
211
|
+
get ffmpegVideoInputOptions() {
|
|
212
|
+
return [];
|
|
213
|
+
}
|
|
214
|
+
get ffmpegAudioOutputOptions() {
|
|
198
215
|
if (!this.hasAudio) {
|
|
199
216
|
return [];
|
|
200
217
|
}
|
|
@@ -203,12 +220,14 @@ class Probe {
|
|
|
203
220
|
"-c:a",
|
|
204
221
|
"aac",
|
|
205
222
|
"-b:a",
|
|
206
|
-
"192k"
|
|
223
|
+
"192k",
|
|
224
|
+
"-ar",
|
|
225
|
+
"48000"
|
|
207
226
|
];
|
|
208
227
|
}
|
|
209
228
|
return ["-c:a", "copy"];
|
|
210
229
|
}
|
|
211
|
-
get
|
|
230
|
+
get ffmpegVideoOutputOptions() {
|
|
212
231
|
if (!this.hasVideo) {
|
|
213
232
|
return [];
|
|
214
233
|
}
|
|
@@ -239,10 +258,12 @@ class Probe {
|
|
|
239
258
|
return createReadStream(this.absolutePath);
|
|
240
259
|
}
|
|
241
260
|
const ffmpegConformanceArgs = [
|
|
261
|
+
...this.ffmpegAudioInputOptions,
|
|
262
|
+
...this.ffmpegVideoInputOptions,
|
|
242
263
|
"-i",
|
|
243
264
|
this.absolutePath,
|
|
244
|
-
...this.
|
|
245
|
-
...this.
|
|
265
|
+
...this.ffmpegAudioOutputOptions,
|
|
266
|
+
...this.ffmpegVideoOutputOptions,
|
|
246
267
|
"-f",
|
|
247
268
|
"mp4",
|
|
248
269
|
"-movflags",
|
package/dist/idempotentTask.js
CHANGED
|
@@ -12,6 +12,30 @@ const idempotentTask = ({
|
|
|
12
12
|
const tasks = {};
|
|
13
13
|
return async (rootDir, absolutePath, ...args) => {
|
|
14
14
|
const log = debug(`ef:${label}`);
|
|
15
|
+
log(`Running ef:${label} task for ${absolutePath} in ${rootDir}`);
|
|
16
|
+
if (absolutePath.includes("http")) {
|
|
17
|
+
const safePath = absolutePath.replace(/[^a-zA-Z0-9]/g, "_");
|
|
18
|
+
const cachePath2 = path.join(rootDir, ".cache", `${safePath}.file`);
|
|
19
|
+
if (existsSync(absolutePath)) {
|
|
20
|
+
log(`Already cached ${absolutePath}`);
|
|
21
|
+
} else {
|
|
22
|
+
const response = await fetch(absolutePath);
|
|
23
|
+
const stream = response.body;
|
|
24
|
+
if (response.ok && stream) {
|
|
25
|
+
const writeStream = createWriteStream(cachePath2);
|
|
26
|
+
const readable = Readable.fromWeb(stream);
|
|
27
|
+
readable.pipe(writeStream);
|
|
28
|
+
await new Promise((resolve, reject) => {
|
|
29
|
+
readable.on("error", reject);
|
|
30
|
+
writeStream.on("error", reject);
|
|
31
|
+
writeStream.on("finish", resolve);
|
|
32
|
+
});
|
|
33
|
+
absolutePath = cachePath2;
|
|
34
|
+
} else {
|
|
35
|
+
throw new Error(`Failed to fetch file from URL ${absolutePath}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
15
39
|
const md5 = await md5FilePath(absolutePath);
|
|
16
40
|
const cacheDir = path.join(rootDir, ".cache", md5);
|
|
17
41
|
log(`Cache dir: ${cacheDir}`);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
File without changes
|