@rajeev02/video-editor 0.1.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.
@@ -0,0 +1,146 @@
1
+ /**
2
+ * @rajeev02/video-editor — Timeline
3
+ * Multi-track timeline with clips, trim, split, reorder, layers
4
+ */
5
+ export type TrackType = "video" | "audio" | "overlay" | "text" | "sticker";
6
+ export interface VideoClip {
7
+ id: string;
8
+ sourceUri: string;
9
+ /** Start time in source media (ms) */
10
+ sourceStartMs: number;
11
+ /** End time in source media (ms) */
12
+ sourceEndMs: number;
13
+ /** Position on timeline (ms) */
14
+ timelineStartMs: number;
15
+ /** Duration on timeline (ms) */
16
+ durationMs: number;
17
+ /** Playback speed multiplier */
18
+ speed: number;
19
+ /** Whether audio is muted */
20
+ muted: boolean;
21
+ /** Volume (0-1) */
22
+ volume: number;
23
+ /** Thumbnail URI */
24
+ thumbnailUri?: string;
25
+ /** Original file width/height */
26
+ width?: number;
27
+ height?: number;
28
+ }
29
+ export interface AudioClip {
30
+ id: string;
31
+ sourceUri: string;
32
+ title?: string;
33
+ sourceStartMs: number;
34
+ sourceEndMs: number;
35
+ timelineStartMs: number;
36
+ durationMs: number;
37
+ volume: number;
38
+ /** Fade in duration (ms) */
39
+ fadeInMs: number;
40
+ /** Fade out duration (ms) */
41
+ fadeOutMs: number;
42
+ }
43
+ export interface TextClip {
44
+ id: string;
45
+ text: string;
46
+ fontFamily: string;
47
+ fontSize: number;
48
+ color: string;
49
+ backgroundColor?: string;
50
+ position: {
51
+ x: number;
52
+ y: number;
53
+ };
54
+ timelineStartMs: number;
55
+ durationMs: number;
56
+ animation?: TextAnimation;
57
+ }
58
+ export type TextAnimation = "none" | "fade_in" | "fade_out" | "slide_in_left" | "slide_in_right" | "slide_in_bottom" | "typewriter" | "bounce" | "zoom_in" | "scale_up";
59
+ export interface StickerClip {
60
+ id: string;
61
+ source: string;
62
+ position: {
63
+ x: number;
64
+ y: number;
65
+ };
66
+ scale: number;
67
+ rotation: number;
68
+ timelineStartMs: number;
69
+ durationMs: number;
70
+ animation?: "none" | "bounce" | "spin" | "pulse" | "shake";
71
+ }
72
+ export type TransitionType = "none" | "crossfade" | "slide_left" | "slide_right" | "slide_up" | "slide_down" | "zoom_in" | "zoom_out" | "spin" | "blur" | "wipe_left" | "wipe_right" | "dissolve" | "glitch";
73
+ export interface Transition {
74
+ id: string;
75
+ type: TransitionType;
76
+ durationMs: number;
77
+ /** Between which two clip IDs */
78
+ fromClipId: string;
79
+ toClipId: string;
80
+ }
81
+ /**
82
+ * Video Timeline — manages multi-track editing
83
+ */
84
+ export declare class VideoTimeline {
85
+ private videoClips;
86
+ private audioClips;
87
+ private textClips;
88
+ private stickerClips;
89
+ private transitions;
90
+ private currentTimeMs;
91
+ private listeners;
92
+ /** Add a video clip */
93
+ addVideoClip(clip: Omit<VideoClip, "id" | "timelineStartMs">): string;
94
+ /** Add an audio track */
95
+ addAudioClip(clip: Omit<AudioClip, "id">): string;
96
+ /** Add text overlay */
97
+ addTextClip(clip: Omit<TextClip, "id">): string;
98
+ /** Add sticker overlay */
99
+ addStickerClip(clip: Omit<StickerClip, "id">): string;
100
+ /** Trim a video clip */
101
+ trimClip(clipId: string, newStartMs: number, newEndMs: number): boolean;
102
+ /** Split a clip at a given time */
103
+ splitClip(clipId: string, atTimeMs: number): string | null;
104
+ /** Remove a clip */
105
+ removeClip(clipId: string): boolean;
106
+ /** Reorder video clips */
107
+ reorderClip(clipId: string, newIndex: number): boolean;
108
+ /** Set clip speed */
109
+ setClipSpeed(clipId: string, speed: number): void;
110
+ /** Add transition between clips */
111
+ addTransition(fromClipId: string, toClipId: string, type: TransitionType, durationMs?: number): string;
112
+ /** Get total duration of the timeline */
113
+ getTotalDuration(): number;
114
+ /** Seek to position */
115
+ seek(timeMs: number): void;
116
+ /** Get current time */
117
+ getCurrentTime(): number;
118
+ /** Get all clips */
119
+ getVideoClips(): VideoClip[];
120
+ getAudioClips(): AudioClip[];
121
+ getTextClips(): TextClip[];
122
+ getStickerClips(): StickerClip[];
123
+ getTransitions(): Transition[];
124
+ /** Get clip count */
125
+ getClipCount(): number;
126
+ /** Subscribe to events */
127
+ on(listener: (event: TimelineEvent) => void): () => void;
128
+ private recalculateTimeline;
129
+ private emit;
130
+ }
131
+ export type TimelineEvent = {
132
+ type: "clip_added";
133
+ clipId: string;
134
+ trackType: TrackType;
135
+ } | {
136
+ type: "clip_removed";
137
+ clipId: string;
138
+ } | {
139
+ type: "clip_trimmed";
140
+ clipId: string;
141
+ } | {
142
+ type: "clip_split";
143
+ clipId: string;
144
+ newClipId: string;
145
+ };
146
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/timeline/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC;AAE3E,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,sCAAsC;IACtC,aAAa,EAAE,MAAM,CAAC;IACtB,oCAAoC;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,gCAAgC;IAChC,eAAe,EAAE,MAAM,CAAC;IACxB,gCAAgC;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,gCAAgC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,6BAA6B;IAC7B,KAAK,EAAE,OAAO,CAAC;IACf,mBAAmB;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,oBAAoB;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iCAAiC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,K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EAAE,MAAM,CAAA;CAAE,CAAC"}
@@ -0,0 +1,193 @@
1
+ "use strict";
2
+ /**
3
+ * @rajeev02/video-editor — Timeline
4
+ * Multi-track timeline with clips, trim, split, reorder, layers
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.VideoTimeline = void 0;
8
+ /**
9
+ * Video Timeline — manages multi-track editing
10
+ */
11
+ class VideoTimeline {
12
+ constructor() {
13
+ this.videoClips = [];
14
+ this.audioClips = [];
15
+ this.textClips = [];
16
+ this.stickerClips = [];
17
+ this.transitions = [];
18
+ this.currentTimeMs = 0;
19
+ this.listeners = new Set();
20
+ }
21
+ /** Add a video clip */
22
+ addVideoClip(clip) {
23
+ const id = `vclip_${Date.now()}_${Math.random().toString(36).substr(2, 4)}`;
24
+ const timelineStartMs = this.getTotalDuration();
25
+ const fullClip = {
26
+ ...clip,
27
+ id,
28
+ timelineStartMs,
29
+ speed: clip.speed ?? 1,
30
+ muted: clip.muted ?? false,
31
+ volume: clip.volume ?? 1,
32
+ };
33
+ this.videoClips.push(fullClip);
34
+ this.emit({ type: "clip_added", clipId: id, trackType: "video" });
35
+ return id;
36
+ }
37
+ /** Add an audio track */
38
+ addAudioClip(clip) {
39
+ const id = `aclip_${Date.now()}_${Math.random().toString(36).substr(2, 4)}`;
40
+ this.audioClips.push({
41
+ ...clip,
42
+ id,
43
+ fadeInMs: clip.fadeInMs ?? 0,
44
+ fadeOutMs: clip.fadeOutMs ?? 0,
45
+ });
46
+ this.emit({ type: "clip_added", clipId: id, trackType: "audio" });
47
+ return id;
48
+ }
49
+ /** Add text overlay */
50
+ addTextClip(clip) {
51
+ const id = `tclip_${Date.now()}`;
52
+ this.textClips.push({ ...clip, id });
53
+ return id;
54
+ }
55
+ /** Add sticker overlay */
56
+ addStickerClip(clip) {
57
+ const id = `sclip_${Date.now()}`;
58
+ this.stickerClips.push({ ...clip, id });
59
+ return id;
60
+ }
61
+ /** Trim a video clip */
62
+ trimClip(clipId, newStartMs, newEndMs) {
63
+ const clip = this.videoClips.find((c) => c.id === clipId);
64
+ if (!clip)
65
+ return false;
66
+ clip.sourceStartMs = newStartMs;
67
+ clip.sourceEndMs = newEndMs;
68
+ clip.durationMs = (newEndMs - newStartMs) / clip.speed;
69
+ this.recalculateTimeline();
70
+ this.emit({ type: "clip_trimmed", clipId });
71
+ return true;
72
+ }
73
+ /** Split a clip at a given time */
74
+ splitClip(clipId, atTimeMs) {
75
+ const idx = this.videoClips.findIndex((c) => c.id === clipId);
76
+ if (idx < 0)
77
+ return null;
78
+ const clip = this.videoClips[idx];
79
+ const splitPoint = clip.sourceStartMs + (atTimeMs - clip.timelineStartMs) * clip.speed;
80
+ if (splitPoint <= clip.sourceStartMs || splitPoint >= clip.sourceEndMs)
81
+ return null;
82
+ const newClipId = `vclip_${Date.now()}`;
83
+ const newClip = {
84
+ ...clip,
85
+ id: newClipId,
86
+ sourceStartMs: splitPoint,
87
+ timelineStartMs: atTimeMs,
88
+ durationMs: (clip.sourceEndMs - splitPoint) / clip.speed,
89
+ };
90
+ clip.sourceEndMs = splitPoint;
91
+ clip.durationMs = (splitPoint - clip.sourceStartMs) / clip.speed;
92
+ this.videoClips.splice(idx + 1, 0, newClip);
93
+ this.recalculateTimeline();
94
+ this.emit({ type: "clip_split", clipId, newClipId });
95
+ return newClipId;
96
+ }
97
+ /** Remove a clip */
98
+ removeClip(clipId) {
99
+ const before = this.videoClips.length + this.audioClips.length;
100
+ this.videoClips = this.videoClips.filter((c) => c.id !== clipId);
101
+ this.audioClips = this.audioClips.filter((c) => c.id !== clipId);
102
+ this.textClips = this.textClips.filter((c) => c.id !== clipId);
103
+ this.stickerClips = this.stickerClips.filter((c) => c.id !== clipId);
104
+ const removed = this.videoClips.length + this.audioClips.length < before;
105
+ if (removed) {
106
+ this.recalculateTimeline();
107
+ this.emit({ type: "clip_removed", clipId });
108
+ }
109
+ return removed;
110
+ }
111
+ /** Reorder video clips */
112
+ reorderClip(clipId, newIndex) {
113
+ const idx = this.videoClips.findIndex((c) => c.id === clipId);
114
+ if (idx < 0 || newIndex < 0 || newIndex >= this.videoClips.length)
115
+ return false;
116
+ const [clip] = this.videoClips.splice(idx, 1);
117
+ this.videoClips.splice(newIndex, 0, clip);
118
+ this.recalculateTimeline();
119
+ return true;
120
+ }
121
+ /** Set clip speed */
122
+ setClipSpeed(clipId, speed) {
123
+ const clip = this.videoClips.find((c) => c.id === clipId);
124
+ if (clip) {
125
+ clip.speed = Math.max(0.1, Math.min(8, speed));
126
+ clip.durationMs = (clip.sourceEndMs - clip.sourceStartMs) / clip.speed;
127
+ this.recalculateTimeline();
128
+ }
129
+ }
130
+ /** Add transition between clips */
131
+ addTransition(fromClipId, toClipId, type, durationMs = 500) {
132
+ const id = `trans_${Date.now()}`;
133
+ this.transitions.push({ id, type, durationMs, fromClipId, toClipId });
134
+ return id;
135
+ }
136
+ /** Get total duration of the timeline */
137
+ getTotalDuration() {
138
+ if (this.videoClips.length === 0)
139
+ return 0;
140
+ const last = this.videoClips[this.videoClips.length - 1];
141
+ return last.timelineStartMs + last.durationMs;
142
+ }
143
+ /** Seek to position */
144
+ seek(timeMs) {
145
+ this.currentTimeMs = Math.max(0, Math.min(timeMs, this.getTotalDuration()));
146
+ }
147
+ /** Get current time */
148
+ getCurrentTime() {
149
+ return this.currentTimeMs;
150
+ }
151
+ /** Get all clips */
152
+ getVideoClips() {
153
+ return [...this.videoClips];
154
+ }
155
+ getAudioClips() {
156
+ return [...this.audioClips];
157
+ }
158
+ getTextClips() {
159
+ return [...this.textClips];
160
+ }
161
+ getStickerClips() {
162
+ return [...this.stickerClips];
163
+ }
164
+ getTransitions() {
165
+ return [...this.transitions];
166
+ }
167
+ /** Get clip count */
168
+ getClipCount() {
169
+ return this.videoClips.length + this.audioClips.length;
170
+ }
171
+ /** Subscribe to events */
172
+ on(listener) {
173
+ this.listeners.add(listener);
174
+ return () => this.listeners.delete(listener);
175
+ }
176
+ recalculateTimeline() {
177
+ let pos = 0;
178
+ for (const clip of this.videoClips) {
179
+ clip.timelineStartMs = pos;
180
+ pos += clip.durationMs;
181
+ }
182
+ }
183
+ emit(event) {
184
+ for (const l of this.listeners) {
185
+ try {
186
+ l(event);
187
+ }
188
+ catch { }
189
+ }
190
+ }
191
+ }
192
+ exports.VideoTimeline = VideoTimeline;
193
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/timeline/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAwGH;;GAEG;AACH,MAAa,aAAa;IAA1B;QACU,eAAU,GAAgB,EAAE,CAAC;QAC7B,eAAU,GAAgB,EAAE,CAAC;QAC7B,cAAS,GAAe,EAAE,CAAC;QAC3B,iBAAY,GAAkB,EAAE,CAAC;QACjC,gBAAW,GAAiB,EAAE,CAAC;QAC/B,kBAAa,GAAW,CAAC,CAAC;QAC1B,cAAS,GAAwC,IAAI,GAAG,EAAE,CAAC;IAiMrE,CAAC;IA/LC,uBAAuB;IACvB,YAAY,CAAC,IAA+C;QAC1D,MAAM,EAAE,GAAG,SAAS,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;QAC5E,MAAM,eAAe,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAChD,MAAM,QAAQ,GAAc;YAC1B,GAAG,IAAI;YACP,EAAE;YACF,eAAe;YACf,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,CAAC;YACtB,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,KAAK;YAC1B,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,CAAC;SACzB,CAAC;QACF,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC/B,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,EA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,CAAC;IAChC,CAAC;IACD,cAAc;QACZ,OAAO,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC;IAC/B,CAAC;IAED,qBAAqB;IACrB,YAAY;QACV,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;IACzD,CAAC;IAED,0BAA0B;IAC1B,EAAE,CAAC,QAAwC;QACzC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC7B,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC/C,CAAC;IAEO,mBAAmB;QACzB,IAAI,GAAG,GAAG,CAAC,CAAC;QACZ,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACnC,IAAI,CAAC,eAAe,GAAG,GAAG,CAAC;YAC3B,GAAG,IAAI,IAAI,CAAC,UAAU,CAAC;QACzB,CAAC;IACH,CAAC;IAEO,IAAI,CAAC,KAAoB;QAC/B,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YAC/B,IAAI,CAAC;gBACH,CAAC,CAAC,KAAK,CAAC,CAAC;YACX,CAAC;YAAC,MAAM,CAAC,CAAA,CAAC;QACZ,CAAC;IACH,CAAC;CACF;AAxMD,sCAwMC"}
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@rajeev02/video-editor",
3
+ "version": "0.1.0",
4
+ "description": "Video editor — timeline, trim, merge, split, transitions, effects, music, text, stickers, speed, export",
5
+ "main": "lib/index.js",
6
+ "author": "Rajeev Kumar Joshi <rajeevjoshi91@gmail.com> (https://rajeev02.github.io)",
7
+ "license": "MIT",
8
+ "types": "lib/index.d.ts",
9
+ "scripts": {
10
+ "build": "tsc",
11
+ "clean": "rm -rf lib",
12
+ "prepublishOnly": "npm run build"
13
+ },
14
+ "keywords": [
15
+ "react-native",
16
+ "video-editor",
17
+ "trim",
18
+ "transitions",
19
+ "filters"
20
+ ],
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/Rajeev02/rajeev-sdk",
24
+ "directory": "packages/video-editor"
25
+ },
26
+ "homepage": "https://github.com/Rajeev02/rajeev-sdk#readme",
27
+ "bugs": {
28
+ "url": "https://github.com/Rajeev02/rajeev-sdk/issues"
29
+ },
30
+ "files": [
31
+ "lib/",
32
+ "src/",
33
+ "README.md"
34
+ ],
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
38
+ "peerDependencies": {
39
+ "react": ">=18.3.0",
40
+ "react-native": ">=0.84.0"
41
+ },
42
+ "peerDependenciesMeta": {
43
+ "react-native": {
44
+ "optional": true
45
+ }
46
+ },
47
+ "devDependencies": {
48
+ "@types/react": "^19.0.0",
49
+ "typescript": "^5.4.0"
50
+ }
51
+ }
@@ -0,0 +1,172 @@
1
+ /**
2
+ * @rajeev02/video-editor — Effects
3
+ * Color grading, video filters, speed ramp, reverse, ken burns, chroma key
4
+ */
5
+
6
+ export type VideoEffect =
7
+ | "color_grade"
8
+ | "filter"
9
+ | "speed_ramp"
10
+ | "reverse"
11
+ | "ken_burns"
12
+ | "chroma_key"
13
+ | "stabilize"
14
+ | "noise_reduction"
15
+ | "slow_motion"
16
+ | "timelapse"
17
+ | "glitch"
18
+ | "vhs"
19
+ | "cinema_bars";
20
+
21
+ export interface ColorGrade {
22
+ brightness: number;
23
+ contrast: number;
24
+ saturation: number;
25
+ warmth: number;
26
+ tint: number;
27
+ highlights: number;
28
+ shadows: number;
29
+ vibrance: number;
30
+ }
31
+
32
+ export interface SpeedRamp {
33
+ id: string;
34
+ /** Keyframes: [{ timeMs, speed }] */
35
+ keyframes: { timeMs: number; speed: number }[];
36
+ /** Smooth transition between keyframes */
37
+ smooth: boolean;
38
+ }
39
+
40
+ export interface KenBurnsEffect {
41
+ /** Start position and zoom */
42
+ start: { x: number; y: number; zoom: number };
43
+ /** End position and zoom */
44
+ end: { x: number; y: number; zoom: number };
45
+ /** Easing function */
46
+ easing: "linear" | "ease_in" | "ease_out" | "ease_in_out";
47
+ }
48
+
49
+ export interface ChromaKeyConfig {
50
+ /** Key color (hex) — typically #00FF00 for green screen */
51
+ keyColor: string;
52
+ /** Similarity threshold (0-100) */
53
+ similarity: number;
54
+ /** Smoothness (0-100) */
55
+ smoothness: number;
56
+ /** Spill suppression (0-100) */
57
+ spillSuppression: number;
58
+ /** Replacement background URI */
59
+ backgroundUri?: string;
60
+ /** Replacement background color */
61
+ backgroundColor?: string;
62
+ }
63
+
64
+ /** Built-in video filter presets */
65
+ export interface VideoFilterPreset {
66
+ id: string;
67
+ name: string;
68
+ category: string;
69
+ grade: Partial<ColorGrade>;
70
+ }
71
+
72
+ export function getVideoFilterPresets(): VideoFilterPreset[] {
73
+ return [
74
+ { id: "original", name: "Original", category: "basic", grade: {} },
75
+ {
76
+ id: "cinematic",
77
+ name: "Cinematic",
78
+ category: "film",
79
+ grade: {
80
+ contrast: 20,
81
+ saturation: -10,
82
+ warmth: -5,
83
+ shadows: -15,
84
+ highlights: -10,
85
+ },
86
+ },
87
+ {
88
+ id: "teal_orange",
89
+ name: "Teal & Orange",
90
+ category: "film",
91
+ grade: { warmth: 15, tint: -10, saturation: 20, contrast: 15 },
92
+ },
93
+ {
94
+ id: "vintage_film",
95
+ name: "Vintage Film",
96
+ category: "vintage",
97
+ grade: { warmth: 20, saturation: -20, contrast: 10 },
98
+ },
99
+ {
100
+ id: "desaturated",
101
+ name: "Desaturated",
102
+ category: "dramatic",
103
+ grade: { saturation: -40, contrast: 15 },
104
+ },
105
+ {
106
+ id: "warm_glow",
107
+ name: "Warm Glow",
108
+ category: "warm",
109
+ grade: { warmth: 30, brightness: 5, saturation: 10 },
110
+ },
111
+ {
112
+ id: "cold_blue",
113
+ name: "Cold Blue",
114
+ category: "cool",
115
+ grade: { warmth: -25, tint: -10, contrast: 10 },
116
+ },
117
+ {
118
+ id: "bw_film",
119
+ name: "B&W Film",
120
+ category: "bw",
121
+ grade: { saturation: -100, contrast: 25 },
122
+ },
123
+ {
124
+ id: "vhs_retro",
125
+ name: "VHS Retro",
126
+ category: "vintage",
127
+ grade: { saturation: -15, warmth: 10, contrast: -5 },
128
+ },
129
+ {
130
+ id: "neon_night",
131
+ name: "Neon Night",
132
+ category: "night",
133
+ grade: { contrast: 30, saturation: 35, brightness: -10 },
134
+ },
135
+ {
136
+ id: "dreamy",
137
+ name: "Dreamy",
138
+ category: "soft",
139
+ grade: { brightness: 10, contrast: -10, saturation: 10, warmth: 5 },
140
+ },
141
+ {
142
+ id: "high_contrast",
143
+ name: "High Contrast",
144
+ category: "dramatic",
145
+ grade: { contrast: 40, shadows: -20, highlights: 15 },
146
+ },
147
+ ];
148
+ }
149
+
150
+ /** Available video transition types with labels */
151
+ export function getTransitionTypes(): {
152
+ id: string;
153
+ label: string;
154
+ category: string;
155
+ }[] {
156
+ return [
157
+ { id: "none", label: "None", category: "basic" },
158
+ { id: "crossfade", label: "Crossfade", category: "basic" },
159
+ { id: "dissolve", label: "Dissolve", category: "basic" },
160
+ { id: "slide_left", label: "Slide Left", category: "slide" },
161
+ { id: "slide_right", label: "Slide Right", category: "slide" },
162
+ { id: "slide_up", label: "Slide Up", category: "slide" },
163
+ { id: "slide_down", label: "Slide Down", category: "slide" },
164
+ { id: "zoom_in", label: "Zoom In", category: "zoom" },
165
+ { id: "zoom_out", label: "Zoom Out", category: "zoom" },
166
+ { id: "wipe_left", label: "Wipe Left", category: "wipe" },
167
+ { id: "wipe_right", label: "Wipe Right", category: "wipe" },
168
+ { id: "spin", label: "Spin", category: "creative" },
169
+ { id: "blur", label: "Blur", category: "creative" },
170
+ { id: "glitch", label: "Glitch", category: "creative" },
171
+ ];
172
+ }