From b884131639904e577813d270c0ab45a0fe4ee6b6 Mon Sep 17 00:00:00 2001 From: victorcavero14 Date: Wed, 5 Aug 2026 12:03:15 +0200 Subject: [PATCH] =?UTF-8?q?feat(editor):=20clip=20editor=20frontend=20?= =?UTF-8?q?=E2=80=94=20ClipEditor=20overlay=20wired=20into=20results?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ClipEditor.jsx: per-clip edit overlay driving the /edl + /rerender backend - App.jsx: editingClip state, handleClipRerendered syncs results, reopened project state and per-clip edit state after a recut (burned layers reset) - ResultCard.jsx: "edit clip" entry button (Scissors), layout tweak - recut.py: write absolute paths in the concat list — the demuxer resolves relative entries against the list file's dir, not the process cwd Co-Authored-By: Claude Fable 5 --- dashboard/src/App.jsx | 44 +- dashboard/src/components/ClipEditor.jsx | 753 ++++++++++++++++++++++++ dashboard/src/components/ResultCard.jsx | 16 +- recut.py | 4 +- 4 files changed, 812 insertions(+), 5 deletions(-) create mode 100644 dashboard/src/components/ClipEditor.jsx diff --git a/dashboard/src/App.jsx b/dashboard/src/App.jsx index 33ffdd7..d0e82bd 100644 --- a/dashboard/src/App.jsx +++ b/dashboard/src/App.jsx @@ -9,6 +9,7 @@ import ThumbnailStudio from './components/ThumbnailStudio'; import SaaShortsTab from './components/SaaShortsTab'; import UGCGallery from './components/UGCGallery'; import ScheduleWeekModal from './components/ScheduleWeekModal'; +import ClipEditor from './components/ClipEditor'; import UsageMeter from './components/UsageMeter'; import TopUpModal from './components/TopUpModal'; import StarBanner from './components/StarBanner'; @@ -228,6 +229,8 @@ function App() { const [sessionRecovered, setSessionRecovered] = useState(false); const [showScheduleWeek, setShowScheduleWeek] = useState(false); + // Clip editor overlay: index of the clip being edited, or null. + const [editingClip, setEditingClip] = useState(null); // Silent-success "saved" states for the settings key inputs (design.md: no alert popups) const [elevenLabsSaved, setElevenLabsSaved] = useState(false); @@ -280,6 +283,35 @@ function App() { s.timer = setTimeout(flushClipState, 2000); }; + // A recut replaced the clip's server file with a fresh render (burned layers + // reset), so update the results, the reopened-project state and the synced + // per-clip edit state, and let the ResultCard remount from the new file. + const handleClipRerendered = (index, data) => { + const newFile = (data.new_video_url || '').split('/').pop(); + setResults((prev) => { + if (!prev?.clips?.[index]) return prev; + const clips = prev.clips.slice(); + clips[index] = { + ...clips[index], + video_url: data.new_video_url, + start: data.start, + end: data.end, + recipe: data.recipe, + }; + return { ...prev, clips }; + }); + setProjectState((prev) => { + if (!prev?.clips) return prev; + return { + ...prev, + clips: prev.clips.map((c) => (c.index === index + ? { ...c, server_file: newFile, active_layers: null } + : c)), + }; + }); + handleClipStateChange(index, { activeLayers: null, serverVideoFile: newFile }); + }; + // Reopen an archived project from the History tab: the backend re-downloads // its files from R2 into the server's working dir and returns the full state. const restoreProject = async (projectJobId) => { @@ -1402,10 +1434,11 @@ function App() {
{results.clips.map((clip, i) => ( setEditingClip(index)} initialState={projectState?.clips?.find((c) => c.index === i) || null} onStateChange={handleClipStateChange} durableUrl={durableClips[i]} @@ -1576,6 +1609,15 @@ function App() { )} + {editingClip !== null && results?.clips?.[editingClip] && ( + setEditingClip(null)} + onRerendered={handleClipRerendered} + /> + )} {showLogin && setShowLogin(false)} />} {showPlanChoice && setShowPlanChoice(false)} />} {showTopUp && ( diff --git a/dashboard/src/components/ClipEditor.jsx b/dashboard/src/components/ClipEditor.jsx new file mode 100644 index 0000000..1fa057b --- /dev/null +++ b/dashboard/src/components/ClipEditor.jsx @@ -0,0 +1,753 @@ +import React, { useState, useEffect, useReducer, useRef, useCallback, useMemo } from 'react'; +import { + X, Loader2, Plus, Trash2, ChevronUp, ChevronDown, Scissors, + AlertCircle, Undo2, Redo2, Film, +} from 'lucide-react'; +import { getApiUrl } from '../config'; +import { apiFetch, apiJson, QuotaError } from '../lib/api'; + +// Full-screen clip editor: shows WHICH source segments a clip was cut from, +// lets the user trim/extend/split/reorder them (word-snapped), and re-renders +// through POST /api/clip/rerender. The recipe (EDL) comes from GET .../edl. + +const MIN_SEGMENT_SECONDS = 0.5; +const SNAP_WINDOW_SECONDS = 0.35; +const WORD_CONTEXT_SECONDS = 15; + +const SEGMENT_COLORS = [ + 'oklch(76% .17 50)', // brass + 'oklch(70% .12 200)', + 'oklch(72% .13 140)', + 'oklch(70% .14 300)', + 'oklch(74% .13 90)', + 'oklch(68% .13 250)', +]; + +function fmt(t) { + if (!Number.isFinite(t)) return '–:––'; + const m = Math.floor(t / 60); + const s = t - m * 60; + return `${m}:${s.toFixed(1).padStart(4, '0')}`; +} + +function totalOf(segments) { + return segments.reduce((acc, s) => acc + (s.end - s.start), 0); +} + +function editorReducer(state, action) { + switch (action.type) { + case 'init': + return { segments: action.segments, selected: 0, past: [], future: [], pendingBase: null }; + case 'select': + return { ...state, selected: action.index }; + // Live drag feedback: replaces segments without touching history; the + // pre-drag snapshot is kept so the whole drag undoes as ONE step. + case 'preview': + return { ...state, segments: action.segments, pendingBase: state.pendingBase || state.segments }; + case 'commit': { + const base = state.pendingBase || state.segments; + return { + ...state, + segments: action.segments, + selected: Math.min(action.select ?? state.selected, action.segments.length - 1), + past: [...state.past, base], + future: [], + pendingBase: null, + }; + } + case 'undo': { + if (!state.past.length) return state; + const prev = state.past[state.past.length - 1]; + return { + ...state, + segments: prev, + selected: Math.min(state.selected, prev.length - 1), + past: state.past.slice(0, -1), + future: [state.segments, ...state.future], + pendingBase: null, + }; + } + case 'redo': { + if (!state.future.length) return state; + const next = state.future[0]; + return { + ...state, + segments: next, + selected: Math.min(state.selected, next.length - 1), + past: [...state.past, state.segments], + future: state.future.slice(1), + pendingBase: null, + }; + } + default: + return state; + } +} + +export default function ClipEditor({ jobId, clipIndex, clipTitle, onClose, onRerendered }) { + const [edl, setEdl] = useState(null); + const [loadError, setLoadError] = useState(null); + const [state, dispatch] = useReducer(editorReducer, { segments: [], selected: 0, past: [], future: [], pendingBase: null }); + const { segments, selected } = state; + + const [snapToWords, setSnapToWords] = useState(true); + const [reapplyCaptions, setReapplyCaptions] = useState(true); + // The recipe of the currently RENDERED preview (playhead maps onto it). + const [renderedSegments, setRenderedSegments] = useState(null); + const [previewUrl, setPreviewUrl] = useState(null); + const [rendering, setRendering] = useState(false); + const [renderSeconds, setRenderSeconds] = useState(0); + const [renderError, setRenderError] = useState(null); + const [confirmClose, setConfirmClose] = useState(false); + const [selectedWord, setSelectedWord] = useState(null); + const [playhead, setPlayhead] = useState(0); + const [showSource, setShowSource] = useState(false); + + const videoRef = useRef(null); + const sourceRef = useRef(null); + const clipTrackRef = useRef(null); + const sourceTrackRef = useRef(null); + const dragRef = useRef(null); + const [ghost, setGhost] = useState(null); // in-progress new segment on the source track + + // ---- load the EDL ------------------------------------------------------- + useEffect(() => { + let cancelled = false; + (async () => { + try { + const data = await apiJson(`/api/clip/${jobId}/${clipIndex}/edl`); + if (cancelled) return; + setEdl(data); + dispatch({ type: 'init', segments: data.segments.map((s) => ({ ...s })) }); + setRenderedSegments(data.segments.map((s) => ({ ...s }))); + setReapplyCaptions(true); + setPreviewUrl(getApiUrl(`/videos/${jobId}/${data.current_file}`)); + } catch (e) { + if (!cancelled) setLoadError(e.detail || e.message || 'could not load the clip recipe'); + } + })(); + return () => { cancelled = true; }; + }, [jobId, clipIndex]); + + const words = useMemo(() => (edl?.words || []), [edl]); + const sourceAvailable = !!edl?.source?.available; + const sourceDuration = edl?.source?.duration || 0; + const canonical = edl?.canonical_range || { start: 0, end: 0 }; + const limits = edl?.limits || { max_segments: 12, min_segment_seconds: MIN_SEGMENT_SECONDS, max_total_seconds: 180 }; + const minSeg = limits.min_segment_seconds || MIN_SEGMENT_SECONDS; + + const total = totalOf(segments); + const dirty = useMemo(() => { + if (!renderedSegments) return false; + return JSON.stringify(segments) !== JSON.stringify(renderedSegments); + }, [segments, renderedSegments]); + + // Trim bounds: with the source gone, cuts must stay inside the range the + // canonical file was rendered from. + const bounds = sourceAvailable + ? { lo: 0, hi: sourceDuration || Infinity } + : { lo: canonical.start, hi: canonical.end }; + + const outOfRange = useCallback( + (seg) => !sourceAvailable && (seg.start < canonical.start - 0.05 || seg.end > canonical.end + 0.05), + [sourceAvailable, canonical], + ); + const needsSourcePath = segments.some((s) => s.start < canonical.start - 0.05 || s.end > canonical.end + 0.05); + const invalidSegments = segments.some(outOfRange); + const overCaps = segments.length > limits.max_segments || total > limits.max_total_seconds; + const canRender = !rendering && segments.length > 0 && !invalidSegments && !overCaps + && segments.every((s) => s.end - s.start >= minSeg); + + // ---- helpers ------------------------------------------------------------ + const snapEdge = useCallback((t, kind) => { + if (!snapToWords || !words.length) return t; + let best = null; + for (const w of words) { + const c = kind === 'start' ? w.s : w.e; + if (Math.abs(c - t) <= SNAP_WINDOW_SECONDS && (best === null || Math.abs(c - t) < Math.abs(best - t))) best = c; + } + return best ?? t; + }, [snapToWords, words]); + + const clampSeg = useCallback((seg) => ({ + start: Math.max(bounds.lo, Math.min(seg.start, seg.end - minSeg)), + end: Math.min(bounds.hi, Math.max(seg.end, seg.start + minSeg)), + }), [bounds.lo, bounds.hi, minSeg]); + + const setSegment = (index, next, { snap = true } = {}) => { + const updated = segments.map((s, i) => { + if (i !== index) return s; + const seg = { ...s, ...next }; + if (snap) { + if (next.start !== undefined) seg.start = snapEdge(seg.start, 'start'); + if (next.end !== undefined) seg.end = snapEdge(seg.end, 'end'); + } + return clampSeg(seg); + }); + dispatch({ type: 'commit', segments: updated, select: index }); + }; + + const addSegment = () => { + if (segments.length >= limits.max_segments) return; + const last = segments[segments.length - 1]; + let start = last ? last.end : bounds.lo; + let end = start + 10; + if (end > bounds.hi) { end = bounds.hi; start = Math.max(bounds.lo, end - 10); } + if (end - start < minSeg) return; + dispatch({ type: 'commit', segments: [...segments, { start: Math.round(start * 1000) / 1000, end: Math.round(end * 1000) / 1000 }], select: segments.length }); + }; + + const deleteSegment = (index) => { + if (segments.length <= 1) return; + dispatch({ type: 'commit', segments: segments.filter((_, i) => i !== index), select: Math.max(0, index - 1) }); + }; + + const moveSegment = (index, dir) => { + const j = index + dir; + if (j < 0 || j >= segments.length) return; + const next = segments.slice(); + [next[index], next[j]] = [next[j], next[index]]; + dispatch({ type: 'commit', segments: next, select: j }); + }; + + const splitSegment = (index) => { + if (segments.length >= limits.max_segments) return; + const seg = segments[index]; + if (seg.end - seg.start < minSeg * 2) return; + let at = seg.start + (seg.end - seg.start) / 2; + // Prefer the playhead when it currently maps inside this segment. + if (!dirty && renderedSegments) { + let offset = 0; + for (let i = 0; i < renderedSegments.length; i += 1) { + const r = renderedSegments[i]; + const len = r.end - r.start; + if (i === index && playhead > offset + minSeg && playhead < offset + len - minSeg) { + at = r.start + (playhead - offset); + } + offset += len; + } + } + at = snapEdge(at, 'end'); + if (at - seg.start < minSeg || seg.end - at < minSeg) at = seg.start + (seg.end - seg.start) / 2; + const next = segments.flatMap((s, i) => (i === index + ? [{ start: s.start, end: Math.round(at * 1000) / 1000 }, { start: Math.round(at * 1000) / 1000, end: s.end }] + : [s])); + dispatch({ type: 'commit', segments: next, select: index }); + }; + + // ---- drag: trim handles on the clip track ------------------------------- + const onDragMove = useCallback((e) => { + const d = dragRef.current; + if (!d) return; + const dt = (e.clientX - d.startX) / d.pxPerSec; + const seg = { ...d.base[d.idx] }; + if (d.edge === 'start') seg.start = Math.max(d.lo, Math.min(seg.start + dt, seg.end - d.minSeg)); + else seg.end = Math.min(d.hi, Math.max(seg.end + dt, seg.start + d.minSeg)); + const next = d.base.map((s, i) => (i === d.idx ? seg : s)); + d.last = { seg, next }; + dispatch({ type: 'preview', segments: next }); + }, []); + + const onDragUp = useCallback(() => { + const d = dragRef.current; + dragRef.current = null; + window.removeEventListener('pointermove', onDragMove); + window.removeEventListener('pointerup', onDragUp); + if (!d || !d.last) return; + const { seg, next } = d.last; + const snapped = { ...seg }; + if (d.edge === 'start') snapped.start = Math.max(d.lo, Math.min(d.snap(seg.start, 'start'), seg.end - d.minSeg)); + else snapped.end = Math.min(d.hi, Math.max(d.snap(seg.end, 'end'), seg.start + d.minSeg)); + dispatch({ type: 'commit', segments: next.map((s, i) => (i === d.idx ? snapped : s)), select: d.idx }); + }, [onDragMove]); + + const startTrimDrag = (e, idx, edge, trackEl, secondsOnTrack) => { + e.preventDefault(); + e.stopPropagation(); + const rect = trackEl?.getBoundingClientRect(); + if (!rect || !secondsOnTrack) return; + dragRef.current = { + idx, edge, startX: e.clientX, pxPerSec: rect.width / secondsOnTrack, + base: segments.map((s) => ({ ...s })), last: null, + lo: bounds.lo, hi: bounds.hi, minSeg, snap: snapEdge, + }; + dispatch({ type: 'select', index: idx }); + window.addEventListener('pointermove', onDragMove); + window.addEventListener('pointerup', onDragUp); + }; + + // ---- drag: paint a NEW segment on the source track ---------------------- + const onGhostMove = useCallback((e) => { + const d = dragRef.current; + if (!d || d.kind !== 'ghost') return; + const t = Math.max(0, Math.min(d.duration, d.t0 + (e.clientX - d.startX) / d.pxPerSec)); + d.range = { start: Math.min(d.t0, t), end: Math.max(d.t0, t) }; + setGhost({ ...d.range }); + }, []); + + const onGhostUp = useCallback(() => { + const d = dragRef.current; + dragRef.current = null; + window.removeEventListener('pointermove', onGhostMove); + window.removeEventListener('pointerup', onGhostUp); + setGhost(null); + if (!d || !d.range) return; + const seg = { + start: Math.round(d.snap(d.range.start, 'start') * 1000) / 1000, + end: Math.round(d.snap(d.range.end, 'end') * 1000) / 1000, + }; + if (seg.end - seg.start < d.minSeg || d.count >= d.maxSegments) return; + d.commit(seg); + }, [onGhostMove]); + + const startGhostDrag = (e) => { + if (!sourceAvailable || !sourceDuration || segments.length >= limits.max_segments) return; + const rect = sourceTrackRef.current?.getBoundingClientRect(); + if (!rect) return; + const t0 = ((e.clientX - rect.left) / rect.width) * sourceDuration; + dragRef.current = { + kind: 'ghost', startX: e.clientX, pxPerSec: rect.width / sourceDuration, + t0, duration: sourceDuration, range: null, snap: snapEdge, minSeg, + count: segments.length, maxSegments: limits.max_segments, + commit: (seg) => dispatch({ type: 'commit', segments: [...segments, seg], select: segments.length }), + }; + window.addEventListener('pointermove', onGhostMove); + window.addEventListener('pointerup', onGhostUp); + }; + + // ---- keyboard ----------------------------------------------------------- + useEffect(() => { + const onKey = (e) => { + const tag = (e.target?.tagName || '').toLowerCase(); + const typing = tag === 'input' || tag === 'textarea' || tag === 'select'; + if (e.key === 'Escape') { + e.preventDefault(); + if (dirty) setConfirmClose(true); else onClose(); + return; + } + if (typing) return; + if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === 'z') { + e.preventDefault(); + dispatch({ type: e.shiftKey ? 'redo' : 'undo' }); + } else if (e.key === ' ') { + e.preventDefault(); + const v = videoRef.current; + if (v) { if (v.paused) v.play().catch(() => {}); else v.pause(); } + } else if (e.key === 'Backspace' || e.key === 'Delete') { + e.preventDefault(); + deleteSegment(selected); + } else if (e.key.toLowerCase() === 's') { + e.preventDefault(); + splitSegment(selected); + } + }; + window.addEventListener('keydown', onKey); + return () => window.removeEventListener('keydown', onKey); + }); + + // ---- re-render ---------------------------------------------------------- + useEffect(() => { + if (!rendering) return undefined; + setRenderSeconds(0); + const t = setInterval(() => setRenderSeconds((s) => s + 1), 1000); + return () => clearInterval(t); + }, [rendering]); + + const doRender = async () => { + if (!canRender) return; + setRendering(true); + setRenderError(null); + try { + const res = await apiFetch('/api/clip/rerender', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + job_id: jobId, + clip_index: clipIndex, + segments: segments.map((s) => ({ start: s.start, end: s.end })), + snap_to_words: false, // boundaries are already word-snapped client-side + reapply_captions: reapplyCaptions, + }), + }); + if (!res.ok) { + let detail = `re-render failed (HTTP ${res.status})`; + try { detail = (await res.json()).detail || detail; } catch { /* keep fallback */ } + throw new Error(detail); + } + const data = await res.json(); + setRenderedSegments(data.recipe.segments.map((s) => ({ ...s }))); + dispatch({ type: 'init', segments: data.recipe.segments.map((s) => ({ ...s })) }); + setPreviewUrl(`${getApiUrl(data.new_video_url)}?t=${Date.now()}`); + onRerendered?.(clipIndex, data); + } catch (e) { + if (e instanceof QuotaError) { + setRenderError(`not enough minutes left (needs ${e.minutesRequired ?? '?'}, ${e.minutesRemaining ?? 0} remaining)`); + } else { + setRenderError(e.message || 're-render failed'); + } + } finally { + setRendering(false); + } + }; + + // ---- transcript panel data --------------------------------------------- + const selectedSeg = segments[selected] || null; + const panelWords = useMemo(() => { + if (!selectedSeg) return []; + const lo = selectedSeg.start - WORD_CONTEXT_SECONDS; + const hi = selectedSeg.end + WORD_CONTEXT_SECONDS; + return words.filter((w) => w.e >= lo && w.s <= hi); + }, [words, selectedSeg]); + + // ---- render ------------------------------------------------------------- + if (loadError) { + return ( +
+
e.stopPropagation()}> +

EDITOR · CLIP {clipIndex + 1}

+
{loadError}
+ +
+
+ ); + } + + if (!edl) { + return ( +
+
+ loading clip recipe… +
+
+ ); + } + + const clipTrackSeconds = Math.max(total, 0.001); + let runningOffset = 0; + const blocks = segments.map((s, i) => { + const left = (runningOffset / clipTrackSeconds) * 100; + const width = ((s.end - s.start) / clipTrackSeconds) * 100; + runningOffset += s.end - s.start; + return { seg: s, i, left, width }; + }); + const renderedTotal = renderedSegments ? totalOf(renderedSegments) : 0; + + return ( +
+ {/* header */} +
+
+

EDITOR · CLIP {clipIndex + 1}

+

edit clip

+ {clipTitle &&

{clipTitle}

} +
+
+
+

DURATION · {fmt(total)}

+

+ {needsSourcePath ? 'PATH · FULL RE-FRAME' : 'PATH · FAST RECUT'} + {edl.rerender_minutes > 0 && ` · ≈${Math.max(1, Math.ceil(total / 60))} MIN`} +

+
+ {confirmClose ? ( +
+ discard changes? + + +
+ ) : ( + + )} +
+
+ + {/* main */} +
+ {/* preview */} +
+
+
+
+ + {/* rail */} +
+
+ {/* segments */} +
+
+

Segments · {segments.length}/{limits.max_segments}

+
+ + +
+
+
+ {segments.map((seg, i) => ( +
dispatch({ type: 'select', index: i })} + className={`rounded-input border p-2.5 cursor-pointer transition-colors ${i === selected ? 'border-[color:var(--color-accent)] bg-paper3' : 'border-rule hover:bg-paper3'} ${outOfRange(seg) ? 'border-[color:var(--color-danger)]' : ''}`} + > +
+ + #{i + 1} + e.stopPropagation()} + onChange={(e) => setSegment(i, { start: parseFloat(e.target.value) || 0 }, { snap: false })} + className="input-field w-20 py-1 px-1.5 text-xs text-center" + aria-label={`segment ${i + 1} start`} + /> + → + e.stopPropagation()} + onChange={(e) => setSegment(i, { end: parseFloat(e.target.value) || 0 }, { snap: false })} + className="input-field w-20 py-1 px-1.5 text-xs text-center" + aria-label={`segment ${i + 1} end`} + /> + {fmt(seg.end - seg.start)} +
+
+ + + + +
+ {outOfRange(seg) && ( +

outside the original range — the source video is gone

+ )} +
+ ))} +
+ +
+ + {/* toggles */} +
+ + +
+ + {/* source monitor */} + {sourceAvailable && ( +
+ + {showSource && ( +
+
+ )} +
+ )} + + {/* transcript */} +
+

Transcript · segment #{selected + 1}

+ {panelWords.length === 0 ? ( +

no words near this segment

+ ) : ( +
+ {panelWords.map((w, i) => { + const inside = selectedSeg && w.e > selectedSeg.start && w.s < selectedSeg.end; + const isSel = selectedWord && selectedWord.s === w.s && selectedWord.e === w.e; + return ( + + ); + })} +
+ )} + {selectedWord && selectedSeg && ( +
+ “{selectedWord.w}” · {fmt(selectedWord.s)} + + +
+ )} +
+
+ + {/* footer actions */} +
+ {renderError && ( +
+ {renderError} +
+ )} + {overCaps && ( +

+ {total > limits.max_total_seconds ? `clip is over ${Math.round(limits.max_total_seconds)}s` : `more than ${limits.max_segments} segments`} +

+ )} +
+ + +
+
+
+
+ + {/* timeline */} +
+ {/* clip track */} +
+
+

CLIP · {fmt(total)}

+

SPACE PLAY · S SPLIT · ⌫ DELETE · ⌘Z UNDO

+
+
+ {blocks.map(({ seg, i, left, width }) => ( +
dispatch({ type: 'select', index: i })} + className={`absolute top-1 bottom-1 rounded-[6px] border ${i === selected ? 'border-[color:var(--color-accent)]' : 'border-transparent'} ${outOfRange(seg) ? 'border-[color:var(--color-danger)]' : ''}`} + style={{ left: `${left}%`, width: `${width}%`, background: `color-mix(in oklab, ${SEGMENT_COLORS[i % SEGMENT_COLORS.length]} 28%, transparent)` }} + > + + #{i + 1} · {fmt(seg.end - seg.start)} + + {/* trim handles */} +
startTrimDrag(e, i, 'start', clipTrackRef.current, clipTrackSeconds)} + className="absolute left-0 top-0 bottom-0 w-2 cursor-ew-resize rounded-l-[6px]" + style={{ background: SEGMENT_COLORS[i % SEGMENT_COLORS.length] }} + /> +
startTrimDrag(e, i, 'end', clipTrackRef.current, clipTrackSeconds)} + className="absolute right-0 top-0 bottom-0 w-2 cursor-ew-resize rounded-r-[6px]" + style={{ background: SEGMENT_COLORS[i % SEGMENT_COLORS.length] }} + /> +
+ ))} + {/* playhead over the last rendered recipe */} + {!dirty && renderedTotal > 0 && playhead <= renderedTotal && ( +
+ )} +
+
+ + {/* source track */} +
+
+

+ SOURCE · {fmt(sourceDuration)}{edl.source.duration_estimated ? ' (EST.)' : ''} + {!sourceAvailable && ' · EXPIRED — TRIMS LIMITED TO THE ORIGINAL RANGE'} +

+ {sourceAvailable && segments.length < limits.max_segments && ( +

DRAG ON EMPTY SPACE TO ADD A SEGMENT

+ )} +
+
+ {/* canonical range marker */} + {sourceDuration > 0 && ( +
+ )} + {sourceDuration > 0 && segments.map((seg, i) => ( +
{ e.stopPropagation(); dispatch({ type: 'select', index: i }); }} + className={`absolute top-1 bottom-1 rounded-[4px] cursor-pointer ${i === selected ? 'ring-1 ring-[color:var(--color-accent)]' : ''}`} + style={{ + left: `${(seg.start / sourceDuration) * 100}%`, + width: `${Math.max(((seg.end - seg.start) / sourceDuration) * 100, 0.4)}%`, + background: SEGMENT_COLORS[i % SEGMENT_COLORS.length], + }} + title={`#${i + 1} · ${fmt(seg.start)} → ${fmt(seg.end)}`} + /> + ))} + {ghost && sourceDuration > 0 && ( +
+ )} +
+
+ 0:00 + {fmt(sourceDuration / 2)} + {fmt(sourceDuration)} +
+
+
+
+ ); +} diff --git a/dashboard/src/components/ResultCard.jsx b/dashboard/src/components/ResultCard.jsx index 4551c53..0f55816 100644 --- a/dashboard/src/components/ResultCard.jsx +++ b/dashboard/src/components/ResultCard.jsx @@ -1,5 +1,5 @@ import React, { useState, useEffect } from 'react'; -import { Download, Share2, Instagram, Youtube, Video, AlertCircle, Loader2, Copy, Check, Wand2, Type, Calendar, Languages, FileText, Link2 } from 'lucide-react'; +import { Download, Share2, Instagram, Youtube, Video, AlertCircle, Loader2, Copy, Check, Wand2, Type, Calendar, Languages, FileText, Link2, Scissors } from 'lucide-react'; import { getApiUrl } from '../config'; import { apiFetch } from '../lib/api'; import SubtitleModal from './SubtitleModal'; @@ -25,7 +25,7 @@ function formatDuration(clip) { return `${String(Math.floor(secs / 60)).padStart(2, '0')}:${String(secs % 60).padStart(2, '0')}`; } -export default function ResultCard({ clip, index, jobId, durableUrl, uploadPostKey, uploadUserId, geminiApiKey, elevenLabsKey, isManaged, onPlay, onPause, onBulkSubtitle, clipCount = 1, bulkProgress, initialState = null, onStateChange, connectedPlatforms = null, onConnectSocials }) { +export default function ResultCard({ clip, index, jobId, durableUrl, uploadPostKey, uploadUserId, geminiApiKey, elevenLabsKey, isManaged, onPlay, onPause, onBulkSubtitle, clipCount = 1, bulkProgress, initialState = null, onStateChange, connectedPlatforms = null, onConnectSocials, onEditClip = null }) { const [showModal, setShowModal] = useState(false); const [showDescModal, setShowDescModal] = useState(false); const [showSubtitleModal, setShowSubtitleModal] = useState(false); @@ -709,6 +709,16 @@ export default function ResultCard({ clip, index, jobId, durableUrl, uploadPostK {/* Actions Footer */}
+ {onEditClip && ( + + )} + diff --git a/recut.py b/recut.py index e10dbe4..8c7d7c3 100644 --- a/recut.py +++ b/recut.py @@ -217,7 +217,9 @@ def run_cut_concat(input_path, segments, out_path, workdir, runner=None): run(command) with open(list_path, "w") as f: for part in part_paths: - f.write(f"file '{part}'\n") + # Absolute paths: the concat demuxer resolves relative entries + # against the LIST FILE's directory, not the process cwd. + f.write(f"file '{os.path.abspath(part)}'\n") run(concat_command(list_path, out_path)) finally: for path in part_paths + [list_path]: