simple-ffmpegjs 0.4.2 → 0.4.4
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/package.json +1 -1
- package/src/ffmpeg/bgm_builder.js +16 -12
- package/src/simpleffmpeg.js +8 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "simple-ffmpegjs",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"description": "Declarative video composition for Node.js — define clips, transitions, text, and audio as simple objects, and let FFmpeg handle the rest.",
|
|
5
5
|
"author": "Brayden Blackwell <braydenblackwell21@gmail.com> (https://github.com/Fats403)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -12,19 +12,23 @@ function buildBackgroundMusicMix(
|
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
// Prefer the caller-supplied visualEnd which accounts for transition
|
|
16
|
+
// compression, falling back to clip end values for audio-only projects.
|
|
15
17
|
const projectDuration =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
typeof visualEnd === "number" && visualEnd > 0
|
|
19
|
+
? visualEnd
|
|
20
|
+
: project.videoOrAudioClips.filter(
|
|
21
|
+
(c) => c.type === "video" || c.type === "image"
|
|
22
|
+
).length > 0
|
|
23
|
+
? Math.max(
|
|
24
|
+
...project.videoOrAudioClips
|
|
25
|
+
.filter((c) => c.type === "video" || c.type === "image")
|
|
26
|
+
.map((c) => c.end)
|
|
27
|
+
)
|
|
28
|
+
: Math.max(
|
|
29
|
+
0,
|
|
30
|
+
...backgroundClips.map((c) => (typeof c.end === "number" ? c.end : 0))
|
|
31
|
+
);
|
|
28
32
|
|
|
29
33
|
let filter = "";
|
|
30
34
|
const bgLabels = [];
|
package/src/simpleffmpeg.js
CHANGED
|
@@ -469,17 +469,11 @@ class SIMPLEFFMPEG {
|
|
|
469
469
|
finalVideoLabel = vres.finalVideoLabel;
|
|
470
470
|
hasVideo = vres.hasVideo;
|
|
471
471
|
|
|
472
|
-
// Use the actual video output length
|
|
473
|
-
//
|
|
474
|
-
//
|
|
475
|
-
// transition compression.
|
|
472
|
+
// Use the actual video output length so that audio trim and BGM
|
|
473
|
+
// duration match the real video stream length, which may be shorter
|
|
474
|
+
// than the original-timeline positions due to transition compression.
|
|
476
475
|
if (typeof vres.videoDuration === "number" && vres.videoDuration > 0) {
|
|
477
476
|
totalVideoDuration = vres.videoDuration;
|
|
478
|
-
}
|
|
479
|
-
if (
|
|
480
|
-
typeof vres.videoDuration === "number" &&
|
|
481
|
-
vres.videoDuration > finalVisualEnd
|
|
482
|
-
) {
|
|
483
477
|
finalVisualEnd = vres.videoDuration;
|
|
484
478
|
}
|
|
485
479
|
}
|
|
@@ -800,9 +794,12 @@ class SIMPLEFFMPEG {
|
|
|
800
794
|
|
|
801
795
|
const wmConfig = exportOptions.watermark;
|
|
802
796
|
|
|
803
|
-
// For image watermarks, we need to add an input
|
|
797
|
+
// For image watermarks, we need to add an input.
|
|
798
|
+
// Use the actual file input count (from _inputIndexMap) rather than
|
|
799
|
+
// videoOrAudioClips.length, because flat color clips use the color=
|
|
800
|
+
// filter source and don't produce file inputs.
|
|
804
801
|
if (wmConfig.type === "image" && wmConfig.url) {
|
|
805
|
-
watermarkInputIndex = this.
|
|
802
|
+
watermarkInputIndex = this._inputIndexMap.size;
|
|
806
803
|
watermarkInputString = ` -i "${escapeFilePath(wmConfig.url)}"`;
|
|
807
804
|
}
|
|
808
805
|
|