@lumy-pack/scene-sieve 0.1.0 → 0.2.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/README.md +47 -24
- package/dist/{errors.d.ts → cli/errors/classify-error.d.ts} +5 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/{utils → cli/options}/parse-options.d.ts +6 -1
- package/dist/cli.mjs +755 -319
- package/dist/constants/pipeline-defaults.d.ts +13 -0
- package/dist/core/{analyzer.d.ts → analyzer/analyzer.d.ts} +11 -6
- package/dist/core/{dbscan.d.ts → analyzer/clustering/dbscan.d.ts} +1 -1
- package/dist/core/analyzer/constants/vision-tuning.d.ts +12 -0
- package/dist/core/analyzer/features/feature-diff.d.ts +14 -0
- package/dist/core/analyzer/features/frame-features.d.ts +32 -0
- package/dist/core/analyzer/index.d.ts +3 -0
- package/dist/core/constants/workspace-layout.d.ts +9 -0
- package/dist/core/{extractor.d.ts → extractor/extractor.d.ts} +6 -4
- package/dist/core/extractor/index.d.ts +1 -0
- package/dist/core/index.d.ts +8 -9
- package/dist/core/input-resolver/index.d.ts +1 -0
- package/dist/core/{input-resolver.d.ts → input-resolver/input-resolver.d.ts} +11 -1
- package/dist/core/input-resolver/validation/validate-options.d.ts +8 -0
- package/dist/core/orchestrator/index.d.ts +3 -0
- package/dist/core/{orchestrator.d.ts → orchestrator/orchestrator.d.ts} +1 -1
- package/dist/core/{run-in-worker.d.ts → orchestrator/worker/run-in-worker.d.ts} +5 -1
- package/dist/core/pruner/index.d.ts +1 -0
- package/dist/core/{pruner.d.ts → pruner/pruner.d.ts} +2 -2
- package/dist/{utils/math.d.ts → core/pruner/scoring/normalize-scores.d.ts} +4 -0
- package/dist/core/segmenter/index.d.ts +1 -0
- package/dist/core/{segmenter.d.ts → segmenter/segmenter.d.ts} +11 -11
- package/dist/core/utils/metadata/build-video-metadata.d.ts +14 -0
- package/dist/core/workspace/index.d.ts +1 -0
- package/dist/core/{workspace.d.ts → workspace/workspace.d.ts} +1 -1
- package/dist/index.cjs +910 -434
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +913 -434
- package/dist/pipeline-worker.mjs +635 -278
- package/dist/types/index.d.ts +25 -0
- package/package.json +1 -1
- package/dist/constants.d.ts +0 -32
- /package/dist/{commands → cli/commands}/Sieve.d.ts +0 -0
- /package/dist/{utils → cli/commands}/command-registry.d.ts +0 -0
- /package/dist/{components → cli/components}/PhaseStep.d.ts +0 -0
- /package/dist/{components → cli/components}/ProgressBar.d.ts +0 -0
- /package/dist/core/{pipeline-worker.d.ts → orchestrator/worker/pipeline-worker.d.ts} +0 -0
- /package/dist/{utils → core/pruner/heap}/min-heap.d.ts +0 -0
- /package/dist/{utils → core/segmenter/scheduling}/concurrency.d.ts +0 -0
- /package/dist/{utils → core/utils/filesystem}/paths.d.ts +0 -0
- /package/dist/{utils → logging}/logger.d.ts +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default values for scene-sieve pipeline options (frame count, threshold, extraction, segmentation).
|
|
3
|
+
*/
|
|
4
|
+
export declare const DEFAULT_COUNT = 20;
|
|
5
|
+
export declare const DEFAULT_THRESHOLD = 0.5;
|
|
6
|
+
export declare const DEFAULT_FPS = 5;
|
|
7
|
+
export declare const DEFAULT_SCALE = 720;
|
|
8
|
+
export declare const DEFAULT_QUALITY = 80;
|
|
9
|
+
export declare const DEFAULT_MAX_FRAMES = 300;
|
|
10
|
+
export declare const DEFAULT_MAX_SEGMENT_DURATION = 300;
|
|
11
|
+
export declare const DEFAULT_SEGMENT_CONCURRENCY = 2;
|
|
12
|
+
export declare const IOU_THRESHOLD = 0.9;
|
|
13
|
+
export declare const ANIMATION_FRAME_THRESHOLD = 5;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AnalysisResult, AnimationMetadata, BoundingBox, ProcessContext } from '
|
|
2
|
-
import type { Point2D } from './dbscan.js';
|
|
1
|
+
import type { AnalysisResult, AnimationMetadata, BoundingBox, ProcessContext } from '../../types/index.js';
|
|
2
|
+
import type { Point2D } from './clustering/dbscan.js';
|
|
3
3
|
type CvLib = typeof import('@techstark/opencv-js');
|
|
4
4
|
export declare function preprocessFrame(framePath: string, scale: number): Promise<{
|
|
5
5
|
data: Uint8Array;
|
|
@@ -19,10 +19,6 @@ export declare class IoUTracker {
|
|
|
19
19
|
flushAndGetAnimations(): AnimationMetadata[];
|
|
20
20
|
getAnimationWeight(boxIndex: number, boxes: BoundingBox[]): number;
|
|
21
21
|
}
|
|
22
|
-
export interface AKAZEResult {
|
|
23
|
-
sNew: Point2D[];
|
|
24
|
-
sLoss: Point2D[];
|
|
25
|
-
}
|
|
26
22
|
/**
|
|
27
23
|
* Pixel-level difference fallback for AKAZE blind spots.
|
|
28
24
|
*
|
|
@@ -37,6 +33,12 @@ export interface AKAZEResult {
|
|
|
37
33
|
* 3. threshold → binary mask of significant changes
|
|
38
34
|
* 4. findContours → bounding rects of changed regions
|
|
39
35
|
* 5. Grid sampling within each bounding rect → Point2D[]
|
|
36
|
+
*
|
|
37
|
+
* @param cvLib - Initialized OpenCV runtime shared by the analyzer.
|
|
38
|
+
* @param frame1 - Previous grayscale frame, with the same dimensions as frame2.
|
|
39
|
+
* @param frame2 - Next grayscale frame, with the same dimensions as frame1.
|
|
40
|
+
* @returns Grid-sampled points from changed regions.
|
|
41
|
+
* @throws Propagates allocation or OpenCV errors after releasing acquired handles.
|
|
40
42
|
*/
|
|
41
43
|
export declare function computePixelDiff(cvLib: CvLib, frame1: {
|
|
42
44
|
data: Uint8Array;
|
|
@@ -57,6 +59,9 @@ export declare function computeInformationGain(clusters: BoundingBox[], clusterP
|
|
|
57
59
|
* 2. DBSCAN Spatial Clustering
|
|
58
60
|
* 3. Spatio-temporal IoU Tracking
|
|
59
61
|
* 4. G(t) Information Gain Scoring
|
|
62
|
+
* @param ctx - Frames, analysis options, and the progress callback for this run.
|
|
63
|
+
* @returns Adjacent scores and tracked animations in analysis coordinates.
|
|
64
|
+
* @throws Propagates runtime errors and rejects total failure of two or more pairs after cleanup.
|
|
60
65
|
*/
|
|
61
66
|
export declare function analyzeFrames(ctx: ProcessContext): Promise<AnalysisResult>;
|
|
62
67
|
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tuning constants for the OpenCV-based vision analysis pipeline (DBSCAN, feature matching, pixel-diff fallback).
|
|
3
|
+
*/
|
|
4
|
+
export declare const OPENCV_BATCH_SIZE = 10;
|
|
5
|
+
export declare const DBSCAN_ALPHA = 0.03;
|
|
6
|
+
export declare const DBSCAN_MIN_PTS = 4;
|
|
7
|
+
export declare const DECAY_LAMBDA = 0.95;
|
|
8
|
+
export declare const MATCH_DISTANCE_THRESHOLD = 0.25;
|
|
9
|
+
export declare const PIXELDIFF_GAUSSIAN_KERNEL = 3;
|
|
10
|
+
export declare const PIXELDIFF_BINARY_THRESHOLD = 30;
|
|
11
|
+
export declare const PIXELDIFF_CONTOUR_MIN_AREA = 100;
|
|
12
|
+
export declare const PIXELDIFF_SAMPLE_SPACING = 8;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Point2D } from '../clustering/dbscan.js';
|
|
2
|
+
import type { FrameFeatures } from './frame-features.js';
|
|
3
|
+
/** Initialized OpenCV runtime supplied by the analyzer. */
|
|
4
|
+
type CvLib = typeof import('@techstark/opencv-js');
|
|
5
|
+
/**
|
|
6
|
+
* Match prev to next with Hamming k=2, crossCheck=false and strict ratio 0.25.
|
|
7
|
+
* @param cvLib - Initialized OpenCV runtime.
|
|
8
|
+
* @param prev - Previous frame's live features, owned by the caller.
|
|
9
|
+
* @param next - Next frame's live features, owned by the caller.
|
|
10
|
+
* @returns Unmatched next-frame coordinates without changing input ownership.
|
|
11
|
+
* @throws Propagates matching errors after releasing temporary native handles.
|
|
12
|
+
*/
|
|
13
|
+
export declare function computeNewPoints(cvLib: CvLib, prev: FrameFeatures, next: FrameFeatures): Point2D[];
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { AKAZE, KeyPointVector, Mat } from '@techstark/opencv-js';
|
|
2
|
+
/** Initialized OpenCV runtime supplied by the analyzer. */
|
|
3
|
+
type CvLib = typeof import('@techstark/opencv-js');
|
|
4
|
+
/** Grayscale bytes whose length matches width times height. */
|
|
5
|
+
type PreprocessedFrame = {
|
|
6
|
+
data: Uint8Array;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
};
|
|
10
|
+
/** Caller-owned AKAZE features for one frame; delete releases both handles once. */
|
|
11
|
+
export interface FrameFeatures {
|
|
12
|
+
/** Width of the analyzed grayscale image. */
|
|
13
|
+
readonly width: number;
|
|
14
|
+
/** Height of the analyzed grayscale image. */
|
|
15
|
+
readonly height: number;
|
|
16
|
+
/** Keypoints in descriptor row order. */
|
|
17
|
+
readonly keypoints: KeyPointVector;
|
|
18
|
+
/** Descriptor rows equal keypoints.size(). */
|
|
19
|
+
readonly descriptors: Mat;
|
|
20
|
+
/** Release both native handles; repeated calls have no effect. */
|
|
21
|
+
delete(): void;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Detect one frame's features without retaining its image or mask.
|
|
25
|
+
* @param cvLib - Initialized OpenCV runtime.
|
|
26
|
+
* @param akaze - Detector owned and released by the caller.
|
|
27
|
+
* @param frame - Grayscale bytes with matching width and height.
|
|
28
|
+
* @returns Feature handles that the caller must delete.
|
|
29
|
+
* @throws Propagates native errors after releasing partial allocations.
|
|
30
|
+
*/
|
|
31
|
+
export declare function computeFrameFeatures(cvLib: CvLib, akaze: AKAZE, frame: PreprocessedFrame): FrameFeatures;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Temp workspace naming and frame file layout for pipeline runs.
|
|
3
|
+
*/
|
|
4
|
+
export declare const APP_NAME = "scene-sieve";
|
|
5
|
+
export declare const WORKSPACE_PREFIX = "scene-sieve-";
|
|
6
|
+
export declare const TEMP_BASE_DIR: string;
|
|
7
|
+
export declare const FRAME_OUTPUT_EXTENSION = ".jpg";
|
|
8
|
+
export declare const FRAME_FILENAME_PATTERN = "frame_%06d.jpg";
|
|
9
|
+
export declare function getTempWorkspaceDir(sessionId: string): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FrameNode, ProcessContext } from '
|
|
1
|
+
import type { FrameNode, ProcessContext } from '../../types/index.js';
|
|
2
2
|
export interface FFprobeMetadata {
|
|
3
3
|
format?: {
|
|
4
4
|
format_name?: string;
|
|
@@ -10,8 +10,9 @@ export interface FFprobeMetadata {
|
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Extract frames from video/GIF using FFmpeg.
|
|
13
|
-
*
|
|
14
|
-
*
|
|
13
|
+
* @param ctx Pipeline context; records effectiveFps and sourceDurationSec for video input.
|
|
14
|
+
* @returns Extracted candidates, or the unchanged input array in frames mode.
|
|
15
|
+
* @throws When the input is missing, metadata has no video stream, or FFmpeg fails.
|
|
15
16
|
*/
|
|
16
17
|
export declare function extractFrames(ctx: ProcessContext): Promise<FrameNode[]>;
|
|
17
18
|
export declare function getVideoMetadata(inputPath: string): Promise<FFprobeMetadata>;
|
|
@@ -25,6 +26,7 @@ export declare function getVideoMetadata(inputPath: string): Promise<FFprobeMeta
|
|
|
25
26
|
* @param scale - Height scale for vision analysis
|
|
26
27
|
* @param startTime - Start time in seconds
|
|
27
28
|
* @param duration - Duration in seconds to extract
|
|
29
|
+
* @param frameLimit - Positive output limit; defaults to the range's grid capacity
|
|
28
30
|
* @returns Array of FrameNode with segment-local timestamps (starting from 0)
|
|
29
31
|
*/
|
|
30
|
-
export declare function extractFramesForRange(inputPath: string, outputDir: string, fps: number, scale: number, startTime: number, duration: number): Promise<FrameNode[]>;
|
|
32
|
+
export declare function extractFramesForRange(inputPath: string, outputDir: string, fps: number, scale: number, startTime: number, duration: number, frameLimit?: number): Promise<FrameNode[]>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { extractFrames, extractFramesForRange, getVideoMetadata } from './extractor.js';
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
export { runPipeline } from './orchestrator.js';
|
|
2
|
-
export { analyzeFrames, computeIoU, computeInformationGain, } from './analyzer.js';
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export { createWorkspace, createSegmentWorkspace, cleanupWorkspace, finalizeOutput, readFramesAsBuffers, writeInputBuffer, writeInputFrames, } from './workspace.js';
|
|
1
|
+
export { runPipeline, runPipelineInWorker } from './orchestrator/index.js';
|
|
2
|
+
export { analyzeFrames, computeIoU, computeInformationGain, dbscan, } from './analyzer/index.js';
|
|
3
|
+
export type { Point2D } from './analyzer/index.js';
|
|
4
|
+
export { extractFrames } from './extractor/index.js';
|
|
5
|
+
export { pruneTo, pruneByThreshold, pruneByThresholdWithCap, suppressConsecutiveRuns, } from './pruner/index.js';
|
|
6
|
+
export { resolveInput, resolveOptions } from './input-resolver/index.js';
|
|
7
|
+
export { shouldSegment, computeSegmentPlan, processSegment, mergeSegmentFrames, runSegmentedPipeline, } from './segmenter/index.js';
|
|
8
|
+
export { createWorkspace, createSegmentWorkspace, cleanupWorkspace, cleanupStaleWorkspaces, finalizeOutput, readFramesAsBuffers, writeInputBuffer, writeInputFrames, } from './workspace/index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { resolveInput, resolveOptions } from './input-resolver.js';
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import type { FrameNode, ResolvedOptions, SieveOptions } from '
|
|
1
|
+
import type { FrameNode, ResolvedOptions, SieveOptions } from '../../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Validate supplied options and resolve defaults and paths for the pipeline.
|
|
4
|
+
* @param options - Mode-specific input and optional numeric settings.
|
|
5
|
+
* @returns Complete pipeline settings with absolute file input paths.
|
|
6
|
+
* @throws An input error if a supplied numeric setting is invalid.
|
|
7
|
+
*/
|
|
2
8
|
export declare function resolveOptions(options: SieveOptions): ResolvedOptions;
|
|
3
9
|
/**
|
|
4
10
|
* Resolve the input source to a list of FrameNode[].
|
|
@@ -6,6 +12,10 @@ export declare function resolveOptions(options: SieveOptions): ResolvedOptions;
|
|
|
6
12
|
* - 'file' mode: validate file exists and delegate to extractor (caller's responsibility)
|
|
7
13
|
* - 'buffer' mode: write buffer as temp video file, return path via FrameNode trick (empty list)
|
|
8
14
|
* - 'frames' mode: write frame buffers as JPGs, return FrameNode[]
|
|
15
|
+
* @param options - Input source; encoded frames must have matching dimensions.
|
|
16
|
+
* @param workspacePath - Workspace receiving temporary input files.
|
|
17
|
+
* @returns Frame nodes or a resolved video path for extraction.
|
|
18
|
+
* @throws Propagates metadata or write errors and rejects mismatched frame sizes.
|
|
9
19
|
*/
|
|
10
20
|
export declare function resolveInput(options: SieveOptions, workspacePath: string): Promise<{
|
|
11
21
|
frames: FrameNode[];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SieveOptions } from '../../../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Reject invalid numeric options before defaults or pipeline effects are applied.
|
|
4
|
+
* @param options - Supplied options; omitted numeric fields use pipeline defaults.
|
|
5
|
+
* @returns Nothing when all supplied numeric fields satisfy their contracts.
|
|
6
|
+
* @throws An input error naming the invalid option and its received value.
|
|
7
|
+
*/
|
|
8
|
+
export declare function validateOptions(options: SieveOptions): void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { SieveOptions, SieveResult } from '
|
|
1
|
+
import type { SieveOptions, SieveResult } from '../../types/index.js';
|
|
2
2
|
export declare function runPipeline(options: SieveOptions): Promise<SieveResult>;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import type { ProgressPhase, SieveInput, SieveOptionsBase, SieveResult } from '
|
|
1
|
+
import type { ProgressPhase, SieveInput, SieveOptionsBase, SieveResult } from '../../../types/index.js';
|
|
2
2
|
export type SieveWorkerOptions = Omit<SieveOptionsBase, 'onProgress'> & SieveInput;
|
|
3
3
|
/**
|
|
4
4
|
* Run the pipeline, choosing the best execution strategy:
|
|
5
5
|
*
|
|
6
6
|
* - Production (bundled .mjs): Worker thread — spinner never freezes
|
|
7
7
|
* - Dev mode (tsx .ts): Main thread — simpler, spinner may stutter during CPU work
|
|
8
|
+
* @param options - Serializable input and pipeline settings for this run.
|
|
9
|
+
* @param onProgress - Receives worker progress updates.
|
|
10
|
+
* @returns The pipeline result; settlement is unchanged by later exit events.
|
|
11
|
+
* @throws Rejects worker errors or any worker exit before a result is received.
|
|
8
12
|
*/
|
|
9
13
|
export declare function runPipelineInWorker(options: SieveWorkerOptions, onProgress: (phase: ProgressPhase, percent: number) => void): Promise<SieveResult>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { pruneTo, pruneByThreshold, pruneByThresholdWithCap, suppressConsecutiveRuns, } from './pruner.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FrameNode, ScoreEdge } from '
|
|
1
|
+
import type { FrameNode, ScoreEdge } from '../../types/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Edge-aware greedy merge with re-linking — O(N log N).
|
|
4
4
|
*
|
|
@@ -35,7 +35,7 @@ export declare function pruneTo(graph: ScoreEdge[], frames: FrameNode[], targetC
|
|
|
35
35
|
*/
|
|
36
36
|
export declare function suppressConsecutiveRuns(graph: ScoreEdge[], passingIndices: number[], normalizedScores: number[]): Set<number>;
|
|
37
37
|
/**
|
|
38
|
-
* Threshold-based pruning with NMS -- O(N).
|
|
38
|
+
* Threshold-based pruning with NMS -- including normalization, O(N log N).
|
|
39
39
|
*
|
|
40
40
|
* 1. Scores are normalized to [0, 1] via percentile normalization.
|
|
41
41
|
* 2. Edges with normalized score >= threshold are collected.
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
export declare const NORMALIZATION_LOGISTIC_K = 3;
|
|
2
|
+
export declare const NORMALIZATION_ALPHA = 0.4;
|
|
3
|
+
export declare const NORMALIZATION_MAD_COEFFICIENT = 1.4826;
|
|
4
|
+
export declare const NORMALIZATION_MIN_SAMPLE_SIZE = 10;
|
|
1
5
|
/**
|
|
2
6
|
* Interface for objects that have a numeric score.
|
|
3
7
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { shouldSegment, computeSegmentPlan, processSegment, mergeSegmentFrames, runSegmentedPipeline, } from './segmenter.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AnimationMetadata, FrameNode, ResolvedOptions, ScoreEdge, SegmentPlan, SegmentResult, SieveOptions, SieveResult } from '
|
|
1
|
+
import type { AnimationMetadata, FrameNode, ResolvedOptions, ScoreEdge, SegmentPlan, SegmentResult, SieveOptions, SieveResult } from '../../types/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Determine whether segmentation should be used.
|
|
4
4
|
* Returns false for frames mode and GIF files.
|
|
@@ -6,25 +6,25 @@ import type { AnimationMetadata, FrameNode, ResolvedOptions, ScoreEdge, SegmentP
|
|
|
6
6
|
*/
|
|
7
7
|
export declare function shouldSegment(resolvedOptions: ResolvedOptions, originalOptions: SieveOptions): boolean;
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
9
|
+
* Partition the global extraction grid into nonempty logical segments.
|
|
10
|
+
* @param totalDuration Positive source duration in seconds.
|
|
11
|
+
* @param maxSegmentDuration Positive logical segment width in seconds.
|
|
12
|
+
* @param maxFrames Candidate budget, defensively raised to at least two.
|
|
13
|
+
* @param fps Positive requested sampling frequency.
|
|
14
|
+
* @returns Contiguous plan indices with grid-aligned seeks and overlap-inclusive limits.
|
|
15
15
|
*/
|
|
16
16
|
export declare function computeSegmentPlan(totalDuration: number, maxSegmentDuration: number, maxFrames: number, fps: number): SegmentPlan[];
|
|
17
17
|
/**
|
|
18
18
|
* Merge multiple segment results into a single unified frame/edge/animation set.
|
|
19
|
-
*
|
|
20
|
-
* -
|
|
21
|
-
*
|
|
22
|
-
* - Duplicate edges keep higher score
|
|
19
|
+
* @param segmentResults Local frames, edges and tracker entries with distinct segment indices.
|
|
20
|
+
* @returns Global timestamp-ordered frames, aliased edges and animations without self loops.
|
|
21
|
+
* Duplicate edges keep the higher score; duplicate animations keep the first tracker entry.
|
|
23
22
|
*/
|
|
24
23
|
export declare function mergeSegmentFrames(segmentResults: SegmentResult[]): {
|
|
25
24
|
frames: FrameNode[];
|
|
26
25
|
edges: ScoreEdge[];
|
|
27
26
|
animations: AnimationMetadata[];
|
|
27
|
+
analysisResolution: SegmentResult['analysisResolution'];
|
|
28
28
|
};
|
|
29
29
|
/**
|
|
30
30
|
* Extract frames for a single segment and analyze them.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AnimationMetadata, FrameNode, ProcessContext, VideoMetadata } from '../../../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Read output dimensions and build consistent video and animation metadata.
|
|
4
|
+
* JPEG finalization does not resize, so the source dimensions match the output.
|
|
5
|
+
* @param ctx Pipeline state with source duration, effective FPS and analysis-space animations.
|
|
6
|
+
* @param selected Selected frames in output order; the first candidate is the fallback.
|
|
7
|
+
* @param analysisResolution Analysis dimensions; absent or zero dimensions imply no scaling.
|
|
8
|
+
* @returns Video metadata and new output-space animations, retaining zero-based frame IDs.
|
|
9
|
+
* @throws If sharp cannot read the selected or fallback image. Empty input performs no image I/O.
|
|
10
|
+
*/
|
|
11
|
+
export declare function buildVideoMetadata(ctx: ProcessContext, selected: FrameNode[], analysisResolution: ProcessContext['analysisResolution']): Promise<{
|
|
12
|
+
video: VideoMetadata;
|
|
13
|
+
animations: AnimationMetadata[];
|
|
14
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createWorkspace, createSegmentWorkspace, cleanupWorkspace, cleanupStaleWorkspaces, finalizeOutput, readFramesAsBuffers, writeInputBuffer, writeInputFrames, } from './workspace.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FrameNode, ProcessContext } from '
|
|
1
|
+
import type { FrameNode, ProcessContext } from '../../types/index.js';
|
|
2
2
|
export declare function createWorkspace(sessionId: string): Promise<string>;
|
|
3
3
|
export declare function finalizeOutput(ctx: ProcessContext, selectedFrames: FrameNode[]): Promise<string[]>;
|
|
4
4
|
export declare function createSegmentWorkspace(parentWorkspacePath: string, segmentIndex: number): Promise<string>;
|