@editframe/assets 0.18.8-beta.0 → 0.18.20-beta.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/dist/Probe.js +2 -2
- package/dist/generateSingleTrack.js +21 -16
- package/package.json +1 -1
- package/types.json +1 -1
package/dist/Probe.js
CHANGED
|
@@ -336,6 +336,7 @@ var ProbeBase = class {
|
|
|
336
336
|
"-frag_duration",
|
|
337
337
|
"4000000"
|
|
338
338
|
] : ["-movflags", "frag_keyframe+empty_moov+default_base_moof"];
|
|
339
|
+
const codecOptions = isAudioTrack && this.mustReencodeAudio ? this.ffmpegAudioOutputOptions : ["-c", "copy"];
|
|
339
340
|
const ffmpegArgs = [
|
|
340
341
|
...this.ffmpegAudioInputOptions,
|
|
341
342
|
...this.ffmpegVideoInputOptions,
|
|
@@ -343,8 +344,7 @@ var ProbeBase = class {
|
|
|
343
344
|
this.absolutePath,
|
|
344
345
|
"-map",
|
|
345
346
|
`0:${trackIndex}`,
|
|
346
|
-
|
|
347
|
-
"copy",
|
|
347
|
+
...codecOptions,
|
|
348
348
|
"-f",
|
|
349
349
|
"mp4",
|
|
350
350
|
"-bitexact",
|
|
@@ -44,25 +44,30 @@ const generateSingleTrackTask = idempotentTask({
|
|
|
44
44
|
runner: async (absolutePath, trackId) => {
|
|
45
45
|
const result = await generateSingleTrackFromPath(absolutePath, trackId);
|
|
46
46
|
const finalStream = new PassThrough();
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const checkCompletion = () => {
|
|
50
|
-
if (streamEnded && fragmentIndexCompleted) finalStream.end();
|
|
51
|
-
};
|
|
52
|
-
result.stream.pipe(finalStream, { end: false });
|
|
53
|
-
result.stream.on("end", () => {
|
|
54
|
-
streamEnded = true;
|
|
55
|
-
checkCompletion();
|
|
47
|
+
const fragmentIndexPromise = result.fragmentIndex.catch((error) => {
|
|
48
|
+
console.warn(`Fragment index generation failed for track ${trackId}:`, error);
|
|
56
49
|
});
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
let progressTimeout = null;
|
|
51
|
+
const resetProgressTimeout = () => {
|
|
52
|
+
if (progressTimeout) clearTimeout(progressTimeout);
|
|
53
|
+
progressTimeout = setTimeout(() => {
|
|
54
|
+
if (!finalStream.destroyed) {
|
|
55
|
+
console.warn(`Progress timeout triggered for track ${trackId} - no activity for 10 seconds`);
|
|
56
|
+
finalStream.end();
|
|
57
|
+
}
|
|
58
|
+
}, 1e4);
|
|
59
|
+
};
|
|
60
|
+
resetProgressTimeout();
|
|
61
|
+
result.stream.on("data", () => {
|
|
62
|
+
resetProgressTimeout();
|
|
59
63
|
});
|
|
60
|
-
result.
|
|
61
|
-
|
|
62
|
-
checkCompletion();
|
|
63
|
-
}).catch((error) => {
|
|
64
|
-
finalStream.destroy(error);
|
|
64
|
+
result.stream.on("end", () => {
|
|
65
|
+
resetProgressTimeout();
|
|
65
66
|
});
|
|
67
|
+
result.stream.pipe(finalStream, { end: false });
|
|
68
|
+
await fragmentIndexPromise;
|
|
69
|
+
finalStream.end();
|
|
70
|
+
if (progressTimeout) clearTimeout(progressTimeout);
|
|
66
71
|
return finalStream;
|
|
67
72
|
}
|
|
68
73
|
});
|