simple-ffmpegjs 0.5.2 → 0.5.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/README.md +4 -1
- package/package.json +10 -3
- package/src/core/media_info.js +5 -5
- package/src/core/resolve.js +33 -0
- package/src/core/rotation.js +4 -4
- package/src/core/validation.js +255 -172
- package/src/ffmpeg/audio_builder.js +1 -1
- package/src/ffmpeg/bgm_builder.js +5 -5
- package/src/ffmpeg/command_builder.js +6 -6
- package/src/ffmpeg/effect_builder.js +11 -11
- package/src/ffmpeg/standalone_audio_builder.js +75 -0
- package/src/ffmpeg/strings.js +4 -17
- package/src/ffmpeg/subtitle_builder.js +6 -14
- package/src/ffmpeg/text_passes.js +33 -8
- package/src/ffmpeg/text_renderer.js +17 -17
- package/src/ffmpeg/video_builder.js +6 -4
- package/src/ffmpeg/watermark_builder.js +1 -1
- package/src/lib/utils.js +4 -4
- package/src/loaders.js +8 -8
- package/src/schema/formatter.js +15 -15
- package/src/schema/index.js +4 -4
- package/src/schema/modules/effect.js +5 -4
- package/src/schema/modules/music.js +1 -1
- package/src/schema/modules/text.js +4 -3
- package/src/simpleffmpeg.js +180 -167
- package/types/index.d.mts +33 -39
- package/types/index.d.ts +33 -39
package/types/index.d.mts
CHANGED
|
@@ -4,9 +4,7 @@ declare namespace SIMPLEFFMPEG {
|
|
|
4
4
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
5
5
|
|
|
6
6
|
/** Base error class for all simple-ffmpeg errors */
|
|
7
|
-
class SimpleffmpegError extends Error {
|
|
8
|
-
name: "SimpleffmpegError";
|
|
9
|
-
}
|
|
7
|
+
class SimpleffmpegError extends Error {}
|
|
10
8
|
|
|
11
9
|
/** Thrown when clip validation fails */
|
|
12
10
|
class ValidationError extends SimpleffmpegError {
|
|
@@ -159,8 +157,12 @@ declare namespace SIMPLEFFMPEG {
|
|
|
159
157
|
interface TextClip {
|
|
160
158
|
type: "text";
|
|
161
159
|
text?: string;
|
|
162
|
-
|
|
163
|
-
|
|
160
|
+
/** Start time on timeline in seconds. Required unless fullDuration is true. */
|
|
161
|
+
position?: number;
|
|
162
|
+
/** End time on timeline in seconds. Mutually exclusive with fullDuration. */
|
|
163
|
+
end?: number;
|
|
164
|
+
/** When true, the clip spans the full visual timeline (position 0 to end of last video/image/color clip). Mutually exclusive with end and duration. */
|
|
165
|
+
fullDuration?: boolean;
|
|
164
166
|
mode?: TextMode;
|
|
165
167
|
words?: TextWordWindow[];
|
|
166
168
|
wordTimestamps?: number[];
|
|
@@ -337,12 +339,14 @@ declare namespace SIMPLEFFMPEG {
|
|
|
337
339
|
interface EffectClip {
|
|
338
340
|
type: "effect";
|
|
339
341
|
effect: EffectName;
|
|
340
|
-
/** Start time on timeline in seconds. Required
|
|
341
|
-
position
|
|
342
|
-
/** End time on timeline in seconds. Mutually exclusive with duration. */
|
|
342
|
+
/** Start time on timeline in seconds. Required unless fullDuration is true. */
|
|
343
|
+
position?: number;
|
|
344
|
+
/** End time on timeline in seconds. Mutually exclusive with duration and fullDuration. */
|
|
343
345
|
end?: number;
|
|
344
|
-
/** Duration in seconds (alternative to end). end = position + duration. */
|
|
346
|
+
/** Duration in seconds (alternative to end). end = position + duration. Mutually exclusive with fullDuration. */
|
|
345
347
|
duration?: number;
|
|
348
|
+
/** When true, the clip spans the full visual timeline (position 0 to end of last video/image/color clip). Mutually exclusive with end and duration. */
|
|
349
|
+
fullDuration?: boolean;
|
|
346
350
|
/** Ramp-in duration in seconds */
|
|
347
351
|
fadeIn?: number;
|
|
348
352
|
/** Ramp-out duration in seconds */
|
|
@@ -979,6 +983,26 @@ declare class SIMPLEFFMPEG {
|
|
|
979
983
|
*/
|
|
980
984
|
static getDuration(clips: SIMPLEFFMPEG.Clip[]): number;
|
|
981
985
|
|
|
986
|
+
/**
|
|
987
|
+
* Calculate the total transition overlap for a clips configuration.
|
|
988
|
+
* Returns the total seconds consumed by xfade transition overlaps
|
|
989
|
+
* among visual clips (video, image, color).
|
|
990
|
+
*
|
|
991
|
+
* Pure function — same clips always produce the same result. No file I/O.
|
|
992
|
+
*
|
|
993
|
+
* @param clips - Array of clip objects
|
|
994
|
+
* @returns Total transition overlap in seconds
|
|
995
|
+
*
|
|
996
|
+
* @example
|
|
997
|
+
* const overlap = SIMPLEFFMPEG.getTransitionOverlap([
|
|
998
|
+
* { type: "video", url: "./a.mp4", duration: 5 },
|
|
999
|
+
* { type: "video", url: "./b.mp4", duration: 10,
|
|
1000
|
+
* transition: { type: "fade", duration: 0.5 } },
|
|
1001
|
+
* ]);
|
|
1002
|
+
* // overlap === 0.5
|
|
1003
|
+
*/
|
|
1004
|
+
static getTransitionOverlap(clips: SIMPLEFFMPEG.Clip[]): number;
|
|
1005
|
+
|
|
982
1006
|
/**
|
|
983
1007
|
* Probe a media file and return comprehensive metadata.
|
|
984
1008
|
*
|
|
@@ -1066,36 +1090,6 @@ declare class SIMPLEFFMPEG {
|
|
|
1066
1090
|
*/
|
|
1067
1091
|
static formatValidationResult(result: SIMPLEFFMPEG.ValidationResult): string;
|
|
1068
1092
|
|
|
1069
|
-
/**
|
|
1070
|
-
* Validation error codes for programmatic handling
|
|
1071
|
-
*/
|
|
1072
|
-
static readonly ValidationCodes: typeof SIMPLEFFMPEG.ValidationCodes;
|
|
1073
|
-
|
|
1074
|
-
/**
|
|
1075
|
-
* Base error class for all simple-ffmpeg errors
|
|
1076
|
-
*/
|
|
1077
|
-
static readonly SimpleffmpegError: typeof SIMPLEFFMPEG.SimpleffmpegError;
|
|
1078
|
-
|
|
1079
|
-
/**
|
|
1080
|
-
* Thrown when clip validation fails
|
|
1081
|
-
*/
|
|
1082
|
-
static readonly ValidationError: typeof SIMPLEFFMPEG.ValidationError;
|
|
1083
|
-
|
|
1084
|
-
/**
|
|
1085
|
-
* Thrown when FFmpeg command execution fails
|
|
1086
|
-
*/
|
|
1087
|
-
static readonly FFmpegError: typeof SIMPLEFFMPEG.FFmpegError;
|
|
1088
|
-
|
|
1089
|
-
/**
|
|
1090
|
-
* Thrown when a media file cannot be found or accessed
|
|
1091
|
-
*/
|
|
1092
|
-
static readonly MediaNotFoundError: typeof SIMPLEFFMPEG.MediaNotFoundError;
|
|
1093
|
-
|
|
1094
|
-
/**
|
|
1095
|
-
* Thrown when export is cancelled via AbortSignal
|
|
1096
|
-
*/
|
|
1097
|
-
static readonly ExportCancelledError: typeof SIMPLEFFMPEG.ExportCancelledError;
|
|
1098
|
-
|
|
1099
1093
|
/**
|
|
1100
1094
|
* Get the clip schema as formatted prompt-ready text.
|
|
1101
1095
|
* Returns a structured description of all clip types accepted by load(),
|
package/types/index.d.ts
CHANGED
|
@@ -4,9 +4,7 @@ declare namespace SIMPLEFFMPEG {
|
|
|
4
4
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
5
5
|
|
|
6
6
|
/** Base error class for all simple-ffmpeg errors */
|
|
7
|
-
class SimpleffmpegError extends Error {
|
|
8
|
-
name: "SimpleffmpegError";
|
|
9
|
-
}
|
|
7
|
+
class SimpleffmpegError extends Error {}
|
|
10
8
|
|
|
11
9
|
/** Thrown when clip validation fails */
|
|
12
10
|
class ValidationError extends SimpleffmpegError {
|
|
@@ -159,8 +157,12 @@ declare namespace SIMPLEFFMPEG {
|
|
|
159
157
|
interface TextClip {
|
|
160
158
|
type: "text";
|
|
161
159
|
text?: string;
|
|
162
|
-
|
|
163
|
-
|
|
160
|
+
/** Start time on timeline in seconds. Required unless fullDuration is true. */
|
|
161
|
+
position?: number;
|
|
162
|
+
/** End time on timeline in seconds. Mutually exclusive with fullDuration. */
|
|
163
|
+
end?: number;
|
|
164
|
+
/** When true, the clip spans the full visual timeline (position 0 to end of last video/image/color clip). Mutually exclusive with end and duration. */
|
|
165
|
+
fullDuration?: boolean;
|
|
164
166
|
mode?: TextMode;
|
|
165
167
|
words?: TextWordWindow[];
|
|
166
168
|
wordTimestamps?: number[];
|
|
@@ -337,12 +339,14 @@ declare namespace SIMPLEFFMPEG {
|
|
|
337
339
|
interface EffectClip {
|
|
338
340
|
type: "effect";
|
|
339
341
|
effect: EffectName;
|
|
340
|
-
/** Start time on timeline in seconds. Required
|
|
341
|
-
position
|
|
342
|
-
/** End time on timeline in seconds. Mutually exclusive with duration. */
|
|
342
|
+
/** Start time on timeline in seconds. Required unless fullDuration is true. */
|
|
343
|
+
position?: number;
|
|
344
|
+
/** End time on timeline in seconds. Mutually exclusive with duration and fullDuration. */
|
|
343
345
|
end?: number;
|
|
344
|
-
/** Duration in seconds (alternative to end). end = position + duration. */
|
|
346
|
+
/** Duration in seconds (alternative to end). end = position + duration. Mutually exclusive with fullDuration. */
|
|
345
347
|
duration?: number;
|
|
348
|
+
/** When true, the clip spans the full visual timeline (position 0 to end of last video/image/color clip). Mutually exclusive with end and duration. */
|
|
349
|
+
fullDuration?: boolean;
|
|
346
350
|
/** Ramp-in duration in seconds */
|
|
347
351
|
fadeIn?: number;
|
|
348
352
|
/** Ramp-out duration in seconds */
|
|
@@ -979,6 +983,26 @@ declare class SIMPLEFFMPEG {
|
|
|
979
983
|
*/
|
|
980
984
|
static getDuration(clips: SIMPLEFFMPEG.Clip[]): number;
|
|
981
985
|
|
|
986
|
+
/**
|
|
987
|
+
* Calculate the total transition overlap for a clips configuration.
|
|
988
|
+
* Returns the total seconds consumed by xfade transition overlaps
|
|
989
|
+
* among visual clips (video, image, color).
|
|
990
|
+
*
|
|
991
|
+
* Pure function — same clips always produce the same result. No file I/O.
|
|
992
|
+
*
|
|
993
|
+
* @param clips - Array of clip objects
|
|
994
|
+
* @returns Total transition overlap in seconds
|
|
995
|
+
*
|
|
996
|
+
* @example
|
|
997
|
+
* const overlap = SIMPLEFFMPEG.getTransitionOverlap([
|
|
998
|
+
* { type: "video", url: "./a.mp4", duration: 5 },
|
|
999
|
+
* { type: "video", url: "./b.mp4", duration: 10,
|
|
1000
|
+
* transition: { type: "fade", duration: 0.5 } },
|
|
1001
|
+
* ]);
|
|
1002
|
+
* // overlap === 0.5
|
|
1003
|
+
*/
|
|
1004
|
+
static getTransitionOverlap(clips: SIMPLEFFMPEG.Clip[]): number;
|
|
1005
|
+
|
|
982
1006
|
/**
|
|
983
1007
|
* Probe a media file and return comprehensive metadata.
|
|
984
1008
|
*
|
|
@@ -1066,36 +1090,6 @@ declare class SIMPLEFFMPEG {
|
|
|
1066
1090
|
*/
|
|
1067
1091
|
static formatValidationResult(result: SIMPLEFFMPEG.ValidationResult): string;
|
|
1068
1092
|
|
|
1069
|
-
/**
|
|
1070
|
-
* Validation error codes for programmatic handling
|
|
1071
|
-
*/
|
|
1072
|
-
static readonly ValidationCodes: typeof SIMPLEFFMPEG.ValidationCodes;
|
|
1073
|
-
|
|
1074
|
-
/**
|
|
1075
|
-
* Base error class for all simple-ffmpeg errors
|
|
1076
|
-
*/
|
|
1077
|
-
static readonly SimpleffmpegError: typeof SIMPLEFFMPEG.SimpleffmpegError;
|
|
1078
|
-
|
|
1079
|
-
/**
|
|
1080
|
-
* Thrown when clip validation fails
|
|
1081
|
-
*/
|
|
1082
|
-
static readonly ValidationError: typeof SIMPLEFFMPEG.ValidationError;
|
|
1083
|
-
|
|
1084
|
-
/**
|
|
1085
|
-
* Thrown when FFmpeg command execution fails
|
|
1086
|
-
*/
|
|
1087
|
-
static readonly FFmpegError: typeof SIMPLEFFMPEG.FFmpegError;
|
|
1088
|
-
|
|
1089
|
-
/**
|
|
1090
|
-
* Thrown when a media file cannot be found or accessed
|
|
1091
|
-
*/
|
|
1092
|
-
static readonly MediaNotFoundError: typeof SIMPLEFFMPEG.MediaNotFoundError;
|
|
1093
|
-
|
|
1094
|
-
/**
|
|
1095
|
-
* Thrown when export is cancelled via AbortSignal
|
|
1096
|
-
*/
|
|
1097
|
-
static readonly ExportCancelledError: typeof SIMPLEFFMPEG.ExportCancelledError;
|
|
1098
|
-
|
|
1099
1093
|
/**
|
|
1100
1094
|
* Get the clip schema as formatted prompt-ready text.
|
|
1101
1095
|
* Returns a structured description of all clip types accepted by load(),
|