From 12aaef06730df8b9eb8d83e0b54a268de679d504 Mon Sep 17 00:00:00 2001 From: Dylan De Faoite Date: Sun, 1 Feb 2026 02:57:13 +0000 Subject: [PATCH] feat: default video dir in config --- rewind/core.py | 20 ++++++++++++++++---- rewind/example.config.toml | 4 +++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/rewind/core.py b/rewind/core.py index 927f6ed..fc36f20 100644 --- a/rewind/core.py +++ b/rewind/core.py @@ -5,10 +5,15 @@ import subprocess import json from rewind.state import load_state +from rewind.paths import load_config from tqdm import tqdm def clip(seconds_from_end: float) -> None: + clip_output = os.path.expanduser(load_config()["record"]["clip_output"]) + os.makedirs(clip_output, exist_ok=True) + output_file_name = f"{datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}.mp4" + output_path = os.path.join(clip_output, output_file_name) start_timestamp = datetime.datetime.now().timestamp() - seconds_from_end end_timestamp = datetime.datetime.now().timestamp() @@ -19,11 +24,18 @@ def clip(seconds_from_end: float) -> None: end_timestamp ) - _concat_ts_files(files, start_offset, end_offset, length, output_file_name) - print(f"Created clip: {output_file_name}") + _concat_ts_files(files, start_offset, end_offset, length, output_path) + print(f"Created clip: {output_path}") def save(first_marker: str, second_marker: str): + vod_dir = os.path.expanduser(load_config()["record"]["vod_output"]) + os.makedirs(vod_dir, exist_ok=True) + output_file_name = f"{datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}-[{first_marker}-{second_marker}].mp4" + output_path = os.path.join(vod_dir, output_file_name) + + print(output_path) + first_timestamp = get_marker_timestamp(first_marker) second_timestamp = get_marker_timestamp(second_marker) @@ -35,8 +47,8 @@ def save(first_marker: str, second_marker: str): second_timestamp ) - _concat_ts_files(files, start_offset, end_offset, second_timestamp - first_timestamp, output_file_name) - print(f"Created video file: {output_file_name}") + _concat_ts_files(files, start_offset, end_offset, second_timestamp - first_timestamp, output_path) + print(f"Created video file: {output_path}") def mark(name: str) -> None: if not name: diff --git a/rewind/example.config.toml b/rewind/example.config.toml index dd5eda4..721667d 100644 --- a/rewind/example.config.toml +++ b/rewind/example.config.toml @@ -4,4 +4,6 @@ port = 4455 password = "6BQWrpHLbyJxNLPJ" [record] -max_record_time = 28800 \ No newline at end of file +max_record_time = 28800 +vod_output = "~/Videos/VoDs" +clip_output = "~/Videos/Clips" \ No newline at end of file