4a7d1e6663
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
103 lines
3.2 KiB
Python
103 lines
3.2 KiB
Python
with open("backend/app/mkv.py", "r", encoding="utf-8") as f:
|
|
content = f.read()
|
|
|
|
import re
|
|
|
|
old_sig = """def build_episodes(
|
|
video_path: str,
|
|
total_duration: float,
|
|
intro_seconds: float,
|
|
outro_seconds: float,
|
|
cut_points: list[float],
|
|
output_dir: Path,
|
|
temp_dir: Path,
|
|
project_dir: Path,
|
|
output_prefix: str = "episode",
|
|
reencode: bool = False,
|
|
ffmpeg_pass1_template: str | None = None,
|
|
ffmpeg_pass2_template: str | None = None,
|
|
progress_cb: ProgressCallback | None = None,
|
|
log_cb: LogCallback | None = None,
|
|
) -> list[str]:"""
|
|
|
|
new_sig = """def build_episodes(
|
|
video_path: str,
|
|
total_duration: float,
|
|
intro_seconds: float,
|
|
outro_seconds: float,
|
|
cut_points: list[float],
|
|
output_dir: Path,
|
|
temp_dir: Path,
|
|
project_dir: Path,
|
|
output_prefix: str = "episode",
|
|
reencode: bool = False,
|
|
ffmpeg_pass1_template: str | None = None,
|
|
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]:"""
|
|
|
|
content = content.replace(old_sig, new_sig)
|
|
|
|
old_logic = """ 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"""
|
|
|
|
new_logic = """ outputs: list[str] = []
|
|
core_ranges: list[tuple[int, float, float]] = []
|
|
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"""
|
|
|
|
content = content.replace(old_logic, new_logic)
|
|
|
|
with open("backend/app/mkv.py", "w", encoding="utf-8") as f:
|
|
f.write(content)
|
|
print("mkv.py patched")
|