Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Add effect bypass: optional enabled flag, skipped in preview and export

Bitti867879abf716
diff --git a/src-tauri/src/project/timeline.rs b/src-tauri/src/project/timeline.rs
index c2f58c8..7d4afa0 100644
--- a/src-tauri/src/project/timeline.rs
+++ b/src-tauri/src/project/timeline.rs
@@ -66,33 +66,57 @@ pub(crate) struct ClipTransform {
pub(crate) struct ClipLook {
pub(crate) opacity: f64,
pub(crate) temperature: f64,
+ /// Effect bypass: `Some(false)` keeps the settings but renders without
+ /// them. Absent in every project written before bypass existed.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub(crate) enabled: Option<bool>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub(crate) struct ClipChromaKey {
pub(crate) color: String,
pub(crate) tolerance: f64,
+ /// Effect bypass: `Some(false)` keeps the settings but renders without
+ /// them. Absent in every project written before bypass existed.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub(crate) enabled: Option<bool>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub(crate) struct ClipAmount {
pub(crate) amount: f64,
+ /// Effect bypass: `Some(false)` keeps the settings but renders without
+ /// them. Absent in every project written before bypass existed.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub(crate) enabled: Option<bool>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub(crate) struct ClipBlur {
pub(crate) radius: f64,
+ /// Effect bypass: `Some(false)` keeps the settings but renders without
+ /// them. Absent in every project written before bypass existed.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub(crate) enabled: Option<bool>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub(crate) struct ClipColorCorrection {
pub(crate) exposure: f64,
pub(crate) contrast: f64,
pub(crate) saturation: f64,
+ /// Effect bypass: `Some(false)` keeps the settings but renders without
+ /// them. Absent in every project written before bypass existed.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub(crate) enabled: Option<bool>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub(crate) struct ClipLut {
pub(crate) intensity: f64,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub(crate) table: Option<LutTable>,
+ /// Effect bypass: `Some(false)` keeps the settings but renders without
+ /// them. Absent in every project written before bypass existed.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub(crate) enabled: Option<bool>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
@@ -109,6 +133,10 @@ pub(crate) struct LutTable {
pub(crate) struct ClipTransition {
pub(crate) r#type: String,
pub(crate) duration_ms: u64,
+ /// Effect bypass: `Some(false)` keeps the settings but renders without
+ /// them. Absent in every project written before bypass existed.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub(crate) enabled: Option<bool>,
}
pub(crate) fn default_clip_status() -> String {
diff --git a/src-tauri/src/tests/persistence.rs b/src-tauri/src/tests/persistence.rs
index 1b04b27..3819ba7 100644
--- a/src-tauri/src/tests/persistence.rs
+++ b/src-tauri/src/tests/persistence.rs
@@ -106,12 +106,45 @@ fn complete_project_create_open_save_reopen_is_lossless() {
assert_eq!(files, [PROJECT_FILE_NAME]);
}
+#[test]
+fn effect_bypass_round_trips_and_stays_absent_when_unset() {
+ let mut config = fixture();
+ let clip = &mut config.timeline.tracks[0].clips[0];
+ clip.chroma_key = Some(ClipChromaKey {
+ color: "#00ff00".into(),
+ tolerance: 20.0,
+ enabled: Some(false),
+ });
+ clip.look = Some(ClipLook {
+ opacity: 80.0,
+ temperature: 0.0,
+ enabled: None,
+ });
+ let config = without_derived_project_state(validate_and_normalize_config(config).unwrap());
+ let root = tempfile::tempdir().unwrap();
+ let created = create_project_in(root.path(), &config).unwrap();
+ let folder = PathBuf::from(&created.folder_path);
+ write_project(&folder, &config).unwrap();
+ assert_eq!(read_project(&folder).unwrap().config, config);
+ let json = serde_json::to_value(&config).unwrap();
+ let clip = &json["timeline"]["tracks"][0]["clips"][0];
+ assert_eq!(clip["chromaKey"]["enabled"], false);
+ // Unset stays unset: a project written before bypass keeps its shape.
+ assert!(clip["look"].as_object().unwrap().get("enabled").is_none());
+ // A file that carries the flag (written by the frontend) loads with it.
+ let parsed: ClipLook = serde_json::from_str(r#"{"opacity":50,"temperature":10,"enabled":false}"#).unwrap();
+ assert_eq!(parsed.enabled, Some(false));
+ let legacy: ClipLook = serde_json::from_str(r#"{"opacity":50,"temperature":10}"#).unwrap();
+ assert_eq!(legacy.enabled, None);
+}
+
#[test]
fn chroma_key_survives_save_and_reopen_and_validates_settings() {
let mut config = fixture();
config.timeline.tracks[0].clips[0].chroma_key = Some(ClipChromaKey {
color: "#12ABef".into(),
tolerance: 27.0,
+ enabled: None,
});
let config = without_derived_project_state(validate_and_normalize_config(config).unwrap());
let root = tempfile::tempdir().unwrap();
@@ -135,6 +168,7 @@ fn chroma_key_survives_save_and_reopen_and_validates_settings() {
invalid.timeline.tracks[0].clips[0].chroma_key = Some(ClipChromaKey {
color: color.into(),
tolerance,
+ enabled: None,
});
assert!(validate_and_normalize_config(invalid)
.unwrap_err()
diff --git a/src/components/workspace/ClipEffects.test.tsx b/src/components/workspace/ClipEffects.test.tsx
index ceafe6a..abfb23f 100644
--- a/src/components/workspace/ClipEffects.test.tsx
+++ b/src/components/workspace/ClipEffects.test.tsx
@@ -41,6 +41,29 @@ async function inTauri(answers: Record<string, (args: unknown) => unknown>, body
const CUBE = "LUT_3D_SIZE 2\n0 0 0\n1 0 0\n0 1 0\n1 1 0\n0 0 1\n1 0 1\n0 1 1\n1 1 1";
describe("clip effects", () => {
+ it("bypasses an effect from its header checkbox, keeping its settings", () => {
+ render(<Harness />);
+ add("Sharpen");
+ add("Look");
+ fireEvent.change(screen.getByLabelText("Sharpen amount"), { target: { value: "120" } });
+ const sharpenOn = screen.getByRole("checkbox", { name: "Sharpen on" }) as HTMLInputElement;
+ expect(sharpenOn.checked).toBe(true);
+ // A fresh effect carries no flag at all: the file keeps its old shape.
+ expect(saved().sharpen).toEqual({ amount: 120 });
+ fireEvent.click(sharpenOn);
+ expect(saved().sharpen).toEqual({ amount: 120, enabled: false });
+ expect(screen.getByRole("region", { name: "Sharpen effect" }).className).toContain("clip-effect--bypassed");
+ // Editing or resetting a bypassed effect leaves it off.
+ fireEvent.change(screen.getByLabelText("Sharpen amount"), { target: { value: "80" } });
+ expect(saved().sharpen).toEqual({ amount: 80, enabled: false });
+ fireEvent.click(screen.getByRole("button", { name: "Reset Sharpen" }));
+ expect(saved().sharpen).toEqual({ amount: 50, enabled: false });
+ fireEvent.click(sharpenOn);
+ expect(saved().sharpen).toEqual({ amount: 50 });
+ fireEvent.click(screen.getByRole("checkbox", { name: "Look on" }));
+ expect(saved().look).toMatchObject({ enabled: false });
+ });
+
it("adds, edits and removes effects independently", () => {
render(<Harness />);
for (const name of ["Sharpen", "Gaussian blur", "Colour correction", "Vignette"]) add(name);
diff --git a/src/components/workspace/ClipEffects.tsx b/src/components/workspace/ClipEffects.tsx
index 32ee054..93f37a3 100644
--- a/src/components/workspace/ClipEffects.tsx
+++ b/src/components/workspace/ClipEffects.tsx
@@ -1,10 +1,10 @@
import { ChevronRight, Ellipsis, FolderOpen, Plus, RotateCcw } from "lucide-react";
import { useEffect, useRef, useState, type KeyboardEvent, type ReactNode } from "react";
import { DEFAULT_CLIP_CHROMA_KEY, DEFAULT_CLIP_LOOK, type TimelineClip } from "../../lib/project";
-import { parseCube } from "../../lib/effectSettings";
+import { isEffectOn, parseCube } from "../../lib/effectSettings";
import { readLutFile } from "../../lib/exportPipeline";
import { inTauri, pickFile } from "../../lib/nativeShell";
-import { ComboBox, Flyout, PropRow, Slider, tooltipProps, useContextMenu } from "../ui";
+import { Checkbox, ComboBox, Flyout, PropRow, Slider, tooltipProps, useContextMenu } from "../ui";
import { ColorSwatch } from "./ColorPicker";
type EffectId = "look" | "transition" | "chromaKey" | "sharpen" | "blur" | "colorCorrection" | "vignette" | "lut";
@@ -142,12 +142,12 @@ const EFFECTS: readonly EffectDefinition[] = [
{
id: "sharpen", name: "Sharpen", description: "Enhance fine edges and detail",
defaults: { sharpen: { amount: 50 } },
- editor: ({ clip, update, disabled }) => <Param label="Amount" ariaLabel="Sharpen amount" value={clip.sharpen!.amount} max={200} defaultValue={50} disabled={disabled} onChange={(amount) => update({ sharpen: { amount } })} />,
+ editor: ({ clip, update, disabled }) => <Param label="Amount" ariaLabel="Sharpen amount" value={clip.sharpen!.amount} max={200} defaultValue={50} disabled={disabled} onChange={(amount) => update({ sharpen: { ...clip.sharpen!, amount } })} />,
},
{
id: "blur", name: "Gaussian blur", description: "Soften the picture with a Gaussian blur",
defaults: { blur: { radius: 4 } },
- editor: ({ clip, update, disabled }) => <Param label="Radius" ariaLabel="Blur radius" value={clip.blur!.radius} max={24} step={0.5} suffix=" px" defaultValue={4} disabled={disabled} onChange={(radius) => update({ blur: { radius } })} />,
+ editor: ({ clip, update, disabled }) => <Param label="Radius" ariaLabel="Blur radius" value={clip.blur!.radius} max={24} step={0.5} suffix=" px" defaultValue={4} disabled={disabled} onChange={(radius) => update({ blur: { ...clip.blur!, radius } })} />,
},
{
id: "colorCorrection", name: "Colour correction", description: "Adjust exposure, contrast and saturation",
@@ -164,7 +164,7 @@ const EFFECTS: readonly EffectDefinition[] = [
{
id: "vignette", name: "Vignette", description: "Darken the edges of the picture",
defaults: { vignette: { amount: 35 } },
- editor: ({ clip, update, disabled }) => <Param label="Amount" ariaLabel="Vignette amount" value={clip.vignette!.amount} defaultValue={35} disabled={disabled} onChange={(amount) => update({ vignette: { amount } })} />,
+ editor: ({ clip, update, disabled }) => <Param label="Amount" ariaLabel="Vignette amount" value={clip.vignette!.amount} defaultValue={35} disabled={disabled} onChange={(amount) => update({ vignette: { ...clip.vignette!, amount } })} />,
},
{
id: "lut", name: "3D LUT", description: "Apply a colour look from a .cube file",
@@ -174,10 +174,12 @@ const EFFECTS: readonly EffectDefinition[] = [
},
];
-/* Each effect is an Expander-style block with a 32px header — chevron and
- name, Reset, and a ⋯ menu — the way Premiere's Effect Controls and
- Clipchamp's effect panel stack them. There is no per-effect bypass: effect
- settings carry no "enabled" flag in the project schema yet. */
+/* Each effect is an Expander-style block with a 32px header — the bypass
+ checkbox, chevron and name, Reset, and a ⋯ menu — the way Premiere's
+ Effect Controls and Clipchamp's effect panel stack them. Unticking the
+ checkbox writes `enabled: false` into the effect's settings: the monitor
+ and the export render without it, and its values stay for when it is
+ ticked again (which removes the flag, so the file keeps its old shape). */
function EffectBlock({ effect, clip, disabled, update, onRemove }: {
effect: EffectDefinition; clip: TimelineClip; disabled: boolean;
update: Update; onRemove: () => void;
@@ -188,9 +190,19 @@ function EffectBlock({ effect, clip, disabled, update, onRemove }: {
is one step rather than sixty. */
const keyed: Update = (patch, key) => update(patch, key ?? effect.id);
const menu = useContextMenu();
- const reset = () => update(effect.reset?.(clip) ?? effect.defaults);
- return <section className={`clip-effect${open ? " clip-effect--open" : ""}`} aria-label={`${effect.name} effect`}>
+ const settings = clip[effect.id] as { enabled?: boolean | null } | null | undefined;
+ const on = isEffectOn(settings);
+ /* Reset puts the values back, not the bypass: a switched-off effect stays off. */
+ const reset = () => {
+ const patch = effect.reset?.(clip) ?? effect.defaults;
+ const values = patch[effect.id] as object | undefined;
+ update(on || !values ? patch : { [effect.id]: { ...values, enabled: false } });
+ };
+ const bypass = (next: boolean) => update({ [effect.id]: { ...settings, enabled: next ? undefined : false } });
+ return <section className={`clip-effect${open ? " clip-effect--open" : ""}${on ? "" : " clip-effect--bypassed"}`} aria-label={`${effect.name} effect`}>
<header className="clip-effect__header">
+ <Checkbox className="clip-effect__bypass" checked={on} disabled={disabled} aria-label={`${effect.name} on`}
+ {...tooltipProps(on ? "Turn off (bypass)" : "Turn on")} onChange={bypass} />
<button type="button" className="clip-effect__toggle" aria-expanded={open} onClick={() => setOpen((value) => !value)}>
<ChevronRight size={12} aria-hidden="true" className="clip-effect__chevron" />
<h3 className="clip-effect__name">{effect.name}</h3>
diff --git a/src/components/workspace/ProgramLayer.tsx b/src/components/workspace/ProgramLayer.tsx
index 2bcd5bb..5cb968a 100644
--- a/src/components/workspace/ProgramLayer.tsx
+++ b/src/components/workspace/ProgramLayer.tsx
@@ -1,10 +1,11 @@
-import { useCallback, useEffect, useLayoutEffect, useRef, useState, type CSSProperties } from "react";
+import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties } from "react";
import { clipFrameStyle, clipVisualSettings, type ClipFrameStyle } from "../../lib/export";
import { PreviewSources } from "../../lib/exportPipeline";
-import type { ProjectAsset, TimelineClip } from "../../lib/project";
+import { clipChromaKey, clipLook, type ProjectAsset, type TimelineClip } from "../../lib/project";
import { ChromaKeyPreview } from "./ChromaKeyPreview";
import { VideoEffectsPreview } from "./VideoEffectsPreview";
-import { hasVideoEffects } from "../../lib/effectSettings";
+import { activeVideoEffects, hasVideoEffects } from "../../lib/effectSettings";
+import type { GpuEffects } from "../../lib/videoEffectsGpu";
import { isTauri } from "../../lib/persistence";
import type { PreviewMedia } from "../../lib/previewPresentation";
@@ -93,8 +94,12 @@ export function ProgramLayer({ clip, asset, sources, playheadMs, playing, rate =
if (video.current) setReady(video.current.readyState >= 2 && !video.current.seeking);
};
const style = previewMediaStyle(clipFrameStyle(clipVisualSettings(clip), playheadMs - clip.startMs));
- const effects = hasVideoEffects(clip);
- const sourceStyle: CSSProperties = composited || clip.chromaKey || effects ? { ...style, visibility: "hidden", position: "absolute" } : style;
+ /* Bypassed effects are dropped here, the way the export drops them. Kept
+ per clip object so the effect canvases only redraw when the clip does. */
+ const gpuEffects = useMemo<GpuEffects>(() => ({ ...activeVideoEffects(clip), chromaKey: clipChromaKey(clip), look: clipLook(clip) }), [clip]);
+ const chromaKey = gpuEffects.chromaKey;
+ const effects = hasVideoEffects(gpuEffects);
+ const sourceStyle: CSSProperties = composited || chromaKey || effects ? { ...style, visibility: "hidden", position: "absolute" } : style;
const showStatus = active && foreground && isTauri() && Boolean(asset?.relativePath || asset?.sourcePath);
return <div className="program-layer" data-clip-id={clip.id} data-active={active} aria-hidden={!active}
aria-label={`${foreground ? "Foreground" : "Background"} clip: ${clip.label}`}
@@ -104,8 +109,8 @@ export function ProgramLayer({ clip, asset, sources, playheadMs, playing, rate =
: <video key={url} ref={registerVideo} src={url} style={sourceStyle} muted={!active || muted} playsInline preload="auto"
onLoadedMetadata={loaded} onLoadedData={loaded} onCanPlay={loaded} onSeeked={loaded}
onError={() => setError(`Could not decode ${clip.label}.`)} />)}
- {!composited && url && effects && <VideoEffectsPreview source={isImage ? image : video} sourceUrl={url} effects={clip} playing={playing && active && !isImage} style={style} onError={setError} />}
- {!composited && url && !effects && clip.chromaKey && <ChromaKeyPreview source={isImage ? image : video} sourceUrl={url} effect={clip.chromaKey} playing={playing && active && !isImage} style={style} onError={setError} />}
+ {!composited && url && effects && <VideoEffectsPreview source={isImage ? image : video} sourceUrl={url} effects={gpuEffects} playing={playing && active && !isImage} style={style} onError={setError} />}
+ {!composited && url && !effects && chromaKey && <ChromaKeyPreview source={isImage ? image : video} sourceUrl={url} effect={chromaKey} playing={playing && active && !isImage} style={style} onError={setError} />}
{showStatus && (error
? <div className="program-note program-note--error" role="alert">{error}</div>
: (!url || (!ready && !isImage)) && <div className="program-note"><span>Loading {clip.label}…</span></div>)}
diff --git a/src/lib/effectSettings.test.ts b/src/lib/effectSettings.test.ts
index 9862e62..930b1a0 100644
--- a/src/lib/effectSettings.test.ts
+++ b/src/lib/effectSettings.test.ts
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
-import { parseCube } from "./effectSettings";
+import { activeVideoEffects, hasVideoEffects, isEffectOn, parseCube } from "./effectSettings";
import { timelineClipSchema } from "./project";
import { clipFrameStyle, clipVisualSettings } from "./export";
@@ -54,3 +54,53 @@ it("retains effects through project parsing and export frame planning", () => {
expect(timelineClipSchema.safeParse({ ...clip, blur: { radius: 25 } }).success).toBe(false);
expect(timelineClipSchema.safeParse({ ...clip, lut: { ...clip.lut, table: { ...clip.lut!.table, values: [] } } }).success).toBe(false);
});
+
+describe("effect bypass", () => {
+ const base = { id: "clip", assetId: "asset", trackId: "video", label: "Clip", startMs: 0, durationMs: 2000 };
+
+ it("loads projects written before bypass unchanged and keeps an explicit flag", () => {
+ const legacy = timelineClipSchema.parse({ ...base, sharpen: { amount: 40 }, look: { opacity: 70, temperature: 5 } });
+ expect(JSON.parse(JSON.stringify(legacy)).sharpen).toEqual({ amount: 40 });
+ expect(JSON.parse(JSON.stringify(legacy)).look).toEqual({ opacity: 70, temperature: 5 });
+ const off = timelineClipSchema.parse({ ...base, sharpen: { amount: 40, enabled: false }, chromaKey: { color: "#00ff00", tolerance: 20, enabled: false } });
+ expect(off.sharpen?.enabled).toBe(false);
+ expect(off.chromaKey?.enabled).toBe(false);
+ expect(timelineClipSchema.safeParse({ ...base, blur: { radius: 2, enabled: "no" } }).success).toBe(false);
+ });
+
+ it("treats absent, null and true as on and only false as off", () => {
+ type Amount = { amount: number; enabled?: boolean | null };
+ const isEffectOnAmount = (effect: Amount | null | undefined) => isEffectOn(effect);
+ expect(isEffectOnAmount({ amount: 1 })).toBe(true);
+ expect(isEffectOnAmount({ amount: 1, enabled: null })).toBe(true);
+ expect(isEffectOnAmount({ amount: 1, enabled: true })).toBe(true);
+ expect(isEffectOnAmount({ amount: 1, enabled: false })).toBe(false);
+ expect(isEffectOnAmount(null)).toBe(false);
+ expect(isEffectOnAmount(undefined)).toBe(false);
+ });
+
+ it("drops bypassed effects from what renders", () => {
+ const effects = { sharpen: { amount: 40, enabled: false }, blur: { radius: 3 }, lut: { intensity: 50, enabled: false } };
+ expect(activeVideoEffects(effects)).toEqual({ sharpen: null, blur: { radius: 3 }, colorCorrection: null, vignette: null, lut: null });
+ expect(hasVideoEffects(effects)).toBe(true);
+ expect(hasVideoEffects({ sharpen: { amount: 40, enabled: false } })).toBe(false);
+ });
+
+ it("renders a clip with every effect bypassed like a clip without effects, in preview and export alike", () => {
+ const plain = timelineClipSchema.parse(base);
+ const bypassed = timelineClipSchema.parse({
+ ...base,
+ look: { opacity: 40, temperature: 50, enabled: false },
+ chromaKey: { color: "#00ff00", tolerance: 20, enabled: false },
+ transition: { type: "fade", durationMs: 500, enabled: false },
+ sharpen: { amount: 40, enabled: false },
+ blur: { radius: 3, enabled: false },
+ colorCorrection: { exposure: 1, contrast: 0, saturation: 100, enabled: false },
+ vignette: { amount: 30, enabled: false },
+ lut: { intensity: 50, enabled: false },
+ });
+ expect(clipVisualSettings(bypassed)).toEqual(clipVisualSettings(plain));
+ expect(clipFrameStyle(clipVisualSettings(bypassed), 0).opacity).toBe(1);
+ expect(hasVideoEffects(clipVisualSettings(bypassed))).toBe(false);
+ });
+});
diff --git a/src/lib/effectSettings.ts b/src/lib/effectSettings.ts
index dbfb508..9aedb90 100644
--- a/src/lib/effectSettings.ts
+++ b/src/lib/effectSettings.ts
@@ -13,22 +13,44 @@ export const lutTableSchema = z.object({
if (table.domainMin.some((min, i) => Math.fround(min) >= Math.fround(table.domainMax[i]))) context.addIssue({ code: "custom", message: "LUT domain maximum must exceed minimum at GPU precision." });
});
+/* Bypass. `enabled: false` switches an effect off without losing its
+ settings (the checkbox in the effect's header). Absent — every project
+ written before bypass existed — or true means on, so old files load and
+ save byte for byte. Nullish rather than optional for the reason given on
+ projectAssetSchema.durationMs; Rust skips it when None. */
+export const effectEnabledSchema = z.boolean().nullish();
+
+/** True when the effect is present and not bypassed. */
+export const isEffectOn = <T extends { enabled?: boolean | null }>(effect: T | null | undefined): effect is T =>
+ effect !== null && effect !== undefined && effect.enabled !== false;
+
export const effectSchemas = {
- sharpen: z.object({ amount: z.number().finite().min(0).max(200) }).nullish(),
- blur: z.object({ radius: z.number().finite().min(0).max(24) }).nullish(),
+ sharpen: z.object({ amount: z.number().finite().min(0).max(200), enabled: effectEnabledSchema }).nullish(),
+ blur: z.object({ radius: z.number().finite().min(0).max(24), enabled: effectEnabledSchema }).nullish(),
colorCorrection: z.object({
exposure: z.number().finite().min(-4).max(4),
contrast: z.number().finite().min(-100).max(100),
saturation: z.number().finite().min(0).max(200),
+ enabled: effectEnabledSchema,
}).nullish(),
- vignette: z.object({ amount: z.number().finite().min(0).max(100) }).nullish(),
- lut: z.object({ intensity: z.number().finite().min(0).max(100), table: lutTableSchema.nullish() }).nullish(),
+ vignette: z.object({ amount: z.number().finite().min(0).max(100), enabled: effectEnabledSchema }).nullish(),
+ lut: z.object({ intensity: z.number().finite().min(0).max(100), table: lutTableSchema.nullish(), enabled: effectEnabledSchema }).nullish(),
};
export type VideoEffects = z.infer<z.ZodObject<typeof effectSchemas>>;
export type LutTable = z.infer<typeof lutTableSchema>;
-export const hasVideoEffects = (effects: VideoEffects): boolean => Boolean(
- effects.sharpen || effects.blur || effects.colorCorrection || effects.vignette || effects.lut,
-);
+
+/** The effects that render: bypassed ones are dropped, as if absent. Every
+ * render path (program monitor, export) reads effects through this. */
+export const activeVideoEffects = (effects: VideoEffects): VideoEffects => ({
+ sharpen: isEffectOn(effects.sharpen) ? effects.sharpen : null,
+ blur: isEffectOn(effects.blur) ? effects.blur : null,
+ colorCorrection: isEffectOn(effects.colorCorrection) ? effects.colorCorrection : null,
+ vignette: isEffectOn(effects.vignette) ? effects.vignette : null,
+ lut: isEffectOn(effects.lut) ? effects.lut : null,
+});
+
+export const hasVideoEffects = (effects: VideoEffects): boolean =>
+ isEffectOn(effects.sharpen) || isEffectOn(effects.blur) || isEffectOn(effects.colorCorrection) || isEffectOn(effects.vignette) || isEffectOn(effects.lut);
export const MAX_LUT_FILE_BYTES = 16 * 1024 * 1024;
diff --git a/src/lib/export.ts b/src/lib/export.ts
index 4e903a9..de897f4 100644
--- a/src/lib/export.ts
+++ b/src/lib/export.ts
@@ -12,6 +12,7 @@
========================================================================== */
import {
+ clipChromaKey,
clipLook,
clipTransform,
clipTransition,
@@ -38,7 +39,7 @@ export interface ExportSettings {
quality: QualityId;
}
-import type { VideoEffects } from "./effectSettings";
+import { activeVideoEffects, type VideoEffects } from "./effectSettings";
export interface ClipVisualSettings extends VideoEffects {
transform: ClipTransform;
@@ -55,15 +56,13 @@ export interface ClipFrameStyle extends ClipVisualSettings {
revealEnd: number;
}
+/** What a clip looks like on screen. Bypassed effects are left out here, so
+ * the monitor and the export both render without them. */
export const clipVisualSettings = (clip: TimelineClip): ClipVisualSettings => ({
transform: clipTransform(clip),
look: clipLook(clip),
- chromaKey: clip.chromaKey,
- sharpen: clip.sharpen,
- blur: clip.blur,
- colorCorrection: clip.colorCorrection,
- vignette: clip.vignette,
- lut: clip.lut,
+ chromaKey: clipChromaKey(clip),
+ ...activeVideoEffects(clip),
transition: clipTransition(clip),
});
@@ -429,8 +428,9 @@ export function visibleClipsAt(
}
if (best) {
visible.push(best);
- const revealing = best.chromaKey || (best.look?.opacity ?? 100) < 100 ||
- (best.transition && best.transition.type !== "cut" && timeMs - best.startMs < best.transition.durationMs);
+ const transition = clipTransition(best);
+ const revealing = Boolean(clipChromaKey(best)) || clipLook(best).opacity < 100 ||
+ (transition.type !== "cut" && timeMs - best.startMs < transition.durationMs);
if (!revealing) break;
}
}
diff --git a/src/lib/project.ts b/src/lib/project.ts
index caf161f..2c65947 100644
--- a/src/lib/project.ts
+++ b/src/lib/project.ts
@@ -1,6 +1,6 @@
import { z } from "zod";
import { createImageScene, imageSceneSchema } from "./imageScene";
-import { effectSchemas } from "./effectSettings";
+import { effectEnabledSchema, effectSchemas, isEffectOn } from "./effectSettings";
import { normalizeShotTagSelection, shotTagClauses, SHOT_TAG_ID_PATTERN, type ShotTagClauses, type ShotTagSelection } from "./shot-tags";
export const PROJECT_FILE_NAME = "slopus.json";
@@ -209,20 +209,25 @@ export const clipTransformSchema = z.object({
positionY: z.number().min(-100).max(100),
});
+/* Look, transition and chroma key are effects in the inspector too, so they
+ take the same bypass flag as the GPU effects (see effectSettings.ts). */
export const clipChromaKeySchema = z.object({
color: z.string().regex(/^#[0-9a-fA-F]{6}$/),
tolerance: z.number().min(0).max(100),
+ enabled: effectEnabledSchema,
});
export const clipLookSchema = z.object({
opacity: z.number().min(0).max(100),
/** Cool at -100, neutral at 0, warm at +100. */
temperature: z.number().min(-100).max(100),
+ enabled: effectEnabledSchema,
});
export const clipTransitionSchema = z.object({
type: z.enum(["cut", "fade", "wipe-left", "wipe-right"]),
durationMs: z.number().int().min(100).max(3000),
+ enabled: effectEnabledSchema,
});
export const timelineClipSchema = z.object({
@@ -611,8 +616,10 @@ export const roundClipTransform = (transform: ClipTransform): ClipTransform => (
positionY: roundTransformValue(transform.positionY),
});
export const clipTransform = (clip: TimelineClip): ClipTransform => roundClipTransform(clip.transform ?? DEFAULT_CLIP_TRANSFORM);
-export const clipLook = (clip: TimelineClip): ClipLook => clip.look ?? DEFAULT_CLIP_LOOK;
-export const clipTransition = (clip: TimelineClip): ClipTransition => clip.transition ?? DEFAULT_CLIP_TRANSITION;
+/* A bypassed Look or transition renders as if it were not there. */
+export const clipLook = (clip: TimelineClip): ClipLook => isEffectOn(clip.look) ? clip.look : DEFAULT_CLIP_LOOK;
+export const clipTransition = (clip: TimelineClip): ClipTransition => isEffectOn(clip.transition) ? clip.transition : DEFAULT_CLIP_TRANSITION;
+export const clipChromaKey = (clip: TimelineClip): ClipChromaKey | null => isEffectOn(clip.chromaKey) ? clip.chromaKey : null;
export type GenerationBrief = z.infer<typeof generationBriefSchema>;
export type ProjectReferenceImage = z.infer<typeof projectReferenceImageSchema>;
export type ProjectReferenceRefmod = z.infer<typeof projectReferenceRefmodSchema>;
diff --git a/src/lib/timelinePreview.ts b/src/lib/timelinePreview.ts
index ca8ec5c..bdc5ce1 100644
--- a/src/lib/timelinePreview.ts
+++ b/src/lib/timelinePreview.ts
@@ -1,5 +1,5 @@
import { visibleClipsAt } from "./export";
-import type { ProjectAsset, TimelineClip, TimelineTrack } from "./project";
+import { clipTransition, type ProjectAsset, type TimelineClip, type TimelineTrack } from "./project";
export type PreviewSegment = { startMs: number; clips: TimelineClip[] };
@@ -12,8 +12,9 @@ export function previewSegments(tracks: TimelineTrack[], assets: ReadonlyMap<str
for (const clip of track.clips) {
boundaries.add(clip.startMs);
boundaries.add(clip.startMs + clip.durationMs);
- if (clip.transition && clip.transition.type !== "cut") {
- boundaries.add(clip.startMs + Math.min(clip.durationMs, clip.transition.durationMs));
+ const transition = clipTransition(clip);
+ if (transition.type !== "cut") {
+ boundaries.add(clip.startMs + Math.min(clip.durationMs, transition.durationMs));
}
}
}
diff --git a/src/styles/ui.css b/src/styles/ui.css
index ee9e93d..3372dfa 100644
--- a/src/styles/ui.css
+++ b/src/styles/ui.css
@@ -1695,3 +1695,21 @@
.ui-statusbar__items--end {
margin-left: auto;
}
+
+/* ============================================================================
+ Effect bypass (ClipEffects). Parked here by the integration pass because
+ timeline.css belonged to another agent at the time; it can move there.
+ The checkbox sits in the effect's 32px header ahead of the chevron, and a
+ bypassed effect's name reads secondary, the way Premiere dims an fx that
+ is switched off.
+ ========================================================================== */
+
+.clip-effect__bypass {
+ flex: none;
+ margin-left: var(--space-2);
+ padding-block: 0;
+}
+
+.clip-effect--bypassed .clip-effect__name {
+ color: var(--text-secondary);
+}