1. fix bulk edit and export Now I can only edit one video at the time overwise the timestamp get overwritten. Save timestamps for each file uploaded
2. in export bulk make clear wich files will get elaborated and whick is being elaborated also add multple progress bar one for bulk one for the actual video and one for actual process (use Material You expresssive and make them clear) 3. remove save marker button; autosave then save edit 4. add paste timestamp button on hover other timestamp input 5. make unlink button not global but add a link icon colored by couple to let understand which timestamps are linked and make the single link removed (link should work that if I edit a timestamp the next/previuos based on which are linked get automatically setted to the next/previous frame timestamp) 6. I'm unable to pit whichever timestamp I want in the timestamp table for example 00:07:23.109 (the one in the frame visualizer) get automatically changed to 00:07:23.110 making the colored border not working correctly sometimes fix both
This commit is contained in:
@@ -320,6 +320,18 @@ def replace_markers(video_id: str, markers: list[float], source: str) -> list[fl
|
||||
return sorted(markers)
|
||||
|
||||
|
||||
def list_segment_edits(video_id: str) -> list[dict]:
|
||||
with _DB_LOCK:
|
||||
conn = get_conn()
|
||||
cur = conn.cursor()
|
||||
cur.execute(
|
||||
"SELECT * FROM segment_edits WHERE video_id = ? ORDER BY segment_key",
|
||||
(video_id,),
|
||||
)
|
||||
rows = cur.fetchall()
|
||||
conn.close()
|
||||
return [_row_to_dict(row) for row in rows]
|
||||
|
||||
def replace_segment_edits(video_id: str, segments: list[dict]) -> list[dict]:
|
||||
now = _now()
|
||||
with _DB_LOCK:
|
||||
|
||||
+20
-4
@@ -236,6 +236,11 @@ def replace_markers(video_id: str, payload: schemas.MarkersUpdate) -> dict:
|
||||
return {"markers": db.replace_markers(video_id, markers, source="manual")}
|
||||
|
||||
|
||||
@app.get("/api/videos/{video_id}/segment-edits", response_model=dict[str, list[schemas.SegmentEditOut]])
|
||||
def list_segment_edits(video_id: str) -> dict:
|
||||
_get_video_or_404(video_id)
|
||||
return {"segments": db.list_segment_edits(video_id)}
|
||||
|
||||
@app.put("/api/videos/{video_id}/segment-edits", response_model=dict[str, list[schemas.SegmentEditOut]])
|
||||
def replace_segment_edits(video_id: str, payload: schemas.SegmentEditsUpdate) -> dict:
|
||||
_get_video_or_404(video_id)
|
||||
@@ -306,6 +311,11 @@ def split_video(
|
||||
job = job_manager.create_job("split")
|
||||
job_id = job["id"]
|
||||
|
||||
segment_edits = db.list_segment_edits(video_id)
|
||||
custom_segments = None
|
||||
if segment_edits:
|
||||
custom_segments = [(se["start_seconds"], se["end_seconds"]) for se in segment_edits if se["segment_key"].startswith("segment_")]
|
||||
|
||||
def run_job() -> dict:
|
||||
project_dir = _project_dir(project["id"])
|
||||
output_dir = project_dir / "outputs" / video_id
|
||||
@@ -328,6 +338,7 @@ def split_video(
|
||||
ffmpeg_pass2_template=project["ffmpeg_pass2_template"],
|
||||
progress_cb=progress,
|
||||
log_cb=lambda message: job_manager.log(job_id, message),
|
||||
custom_segments=custom_segments,
|
||||
)
|
||||
return {"outputs": outputs, "output_dir": str(output_dir)}
|
||||
|
||||
@@ -346,7 +357,7 @@ def split_all_videos(payload: schemas.SplitAllRequest | None = Body(default=None
|
||||
if not videos:
|
||||
raise HTTPException(status_code=400, detail="No videos available to export")
|
||||
|
||||
ready: list[tuple[dict, list[float]]] = []
|
||||
ready: list[tuple[dict, list[float], list[tuple[float, float]] | None]] = []
|
||||
skipped: list[dict] = []
|
||||
for video in videos:
|
||||
try:
|
||||
@@ -355,10 +366,15 @@ def split_all_videos(payload: schemas.SplitAllRequest | None = Body(default=None
|
||||
skipped.append({"video_id": video["id"], "filename": video["filename"], "reason": exc.detail})
|
||||
continue
|
||||
markers = sorted(db.list_markers(video["id"]))
|
||||
if not markers:
|
||||
skipped.append({"video_id": video["id"], "filename": video["filename"], "reason": "No saved markers"})
|
||||
segment_edits = db.list_segment_edits(video["id"])
|
||||
custom_segments = None
|
||||
if segment_edits:
|
||||
custom_segments = [(se["start_seconds"], se["end_seconds"]) for se in segment_edits if se["segment_key"].startswith("segment_")]
|
||||
|
||||
if not markers and not custom_segments:
|
||||
skipped.append({"video_id": video["id"], "filename": video["filename"], "reason": "No saved markers or segments"})
|
||||
continue
|
||||
ready.append((video, markers))
|
||||
ready.append((video, markers, custom_segments))
|
||||
|
||||
if not ready:
|
||||
raise HTTPException(status_code=400, detail="No videos have saved markers ready to export")
|
||||
|
||||
+29
-21
@@ -348,35 +348,43 @@ def build_episodes(
|
||||
ffmpeg_pass2_template: str | None = None,
|
||||
progress_cb: ProgressCallback | None = None,
|
||||
log_cb: LogCallback | None = None,
|
||||
custom_segments: list[tuple[float, float]] | None = None,
|
||||
) -> list[str]:
|
||||
output_dir.mkdir(parents=True, exist_ok=True)
|
||||
temp_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
min_segment = 0.001
|
||||
|
||||
core_end = max(intro_seconds, total_duration - outro_seconds)
|
||||
boundaries = [p for p in sorted(cut_points) if intro_seconds < p < core_end]
|
||||
boundaries.append(core_end)
|
||||
|
||||
outputs: list[str] = []
|
||||
prev = intro_seconds
|
||||
safe_boundaries: list[float] = []
|
||||
|
||||
for end in boundaries:
|
||||
if end - prev <= min_segment:
|
||||
continue
|
||||
safe_boundaries.append(end)
|
||||
prev = end
|
||||
|
||||
if not safe_boundaries:
|
||||
raise RuntimeError("No valid segments after filtering short ranges")
|
||||
|
||||
prev = intro_seconds
|
||||
total_segments = len(safe_boundaries)
|
||||
core_ranges: list[tuple[int, float, float]] = []
|
||||
for index, end in enumerate(safe_boundaries, start=1):
|
||||
core_ranges.append((index, prev, end))
|
||||
prev = end
|
||||
min_segment = 0.001
|
||||
|
||||
if custom_segments and len(custom_segments) > 0:
|
||||
total_segments = len(custom_segments)
|
||||
for index, (start, end) in enumerate(custom_segments, start=1):
|
||||
core_ranges.append((index, start, end))
|
||||
else:
|
||||
core_end = max(intro_seconds, total_duration - outro_seconds)
|
||||
boundaries = [p for p in sorted(cut_points) if intro_seconds < p < core_end]
|
||||
boundaries.append(core_end)
|
||||
|
||||
prev = intro_seconds
|
||||
safe_boundaries: list[float] = []
|
||||
|
||||
for end in boundaries:
|
||||
if end - prev <= min_segment:
|
||||
continue
|
||||
safe_boundaries.append(end)
|
||||
prev = end
|
||||
|
||||
if not safe_boundaries:
|
||||
raise RuntimeError("No valid segments after filtering short ranges")
|
||||
|
||||
prev = intro_seconds
|
||||
total_segments = len(safe_boundaries)
|
||||
for index, end in enumerate(safe_boundaries, start=1):
|
||||
core_ranges.append((index, prev, end))
|
||||
prev = end
|
||||
|
||||
intro_work = intro_seconds if intro_seconds > min_segment else 0.0
|
||||
outro_start = max(0.0, total_duration - outro_seconds)
|
||||
|
||||
Reference in New Issue
Block a user