MOVE clip creation logic out of CLI entry point
This commit is contained in:
@@ -1,14 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
from datetime import datetime
|
||||
from rewind.video import combine_last_x_ts_files
|
||||
from rewind.video import clip
|
||||
import obsws_python as obs
|
||||
import sys, argparse
|
||||
|
||||
def create_recording(seconds: int) -> None:
|
||||
output_file_name = f"{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}.mp4"
|
||||
combine_last_x_ts_files(seconds, output_file_name)
|
||||
print(f"Created clip: {output_file_name}")
|
||||
|
||||
def build_parser() -> argparse.ArgumentParser:
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="rewind",
|
||||
@@ -32,7 +27,7 @@ def main(argv=None) -> int:
|
||||
args = parser.parse_args(argv)
|
||||
|
||||
if args.command == "save":
|
||||
create_recording(args.seconds)
|
||||
clip(args.seconds)
|
||||
else:
|
||||
parser.error("Unknown command")
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import os, subprocess
|
||||
import os, subprocess, datetime
|
||||
|
||||
from rewind.paths import load_state
|
||||
|
||||
@@ -28,6 +28,11 @@ def combine_last_x_ts_files(seconds: float, output_file: str) -> None:
|
||||
|
||||
os.remove("file_list.txt")
|
||||
|
||||
def clip(seconds_from_end: float, output_file: str) -> None:
|
||||
output_file_name = f"{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}.mp4"
|
||||
combine_last_x_ts_files(seconds_from_end, output_file_name)
|
||||
print(f"Created clip: {output_file_name}")
|
||||
|
||||
def get_duration(file_path: str) -> float:
|
||||
result = subprocess.run(
|
||||
["ffprobe", "-v", "error", "-show_entries",
|
||||
|
||||
Reference in New Issue
Block a user