|
@@ -48,7 +48,9 @@ class RecordingMaintainer(threading.Thread):
|
|
recordings = [
|
|
recordings = [
|
|
d
|
|
d
|
|
for d in os.listdir(CACHE_DIR)
|
|
for d in os.listdir(CACHE_DIR)
|
|
- if os.path.isfile(os.path.join(CACHE_DIR, d)) and d.endswith(".ts")
|
|
|
|
|
|
+ if os.path.isfile(os.path.join(CACHE_DIR, d))
|
|
|
|
+ and d.endswith(".mp4")
|
|
|
|
+ and not d.startswith("clip_")
|
|
]
|
|
]
|
|
|
|
|
|
files_in_use = []
|
|
files_in_use = []
|
|
@@ -111,38 +113,9 @@ class RecordingMaintainer(threading.Thread):
|
|
file_name = f"{start_time.strftime('%M.%S.mp4')}"
|
|
file_name = f"{start_time.strftime('%M.%S.mp4')}"
|
|
file_path = os.path.join(directory, file_name)
|
|
file_path = os.path.join(directory, file_name)
|
|
|
|
|
|
- cache_path_mp4 = f"{cache_path[:-2]}mp4"
|
|
|
|
-
|
|
|
|
- ffmpeg_cmd = [
|
|
|
|
- "ffmpeg",
|
|
|
|
- "-hide_banner",
|
|
|
|
- "-y",
|
|
|
|
- "-i",
|
|
|
|
- cache_path,
|
|
|
|
- "-c",
|
|
|
|
- "copy",
|
|
|
|
- "-movflags",
|
|
|
|
- "+faststart",
|
|
|
|
- cache_path_mp4,
|
|
|
|
- ]
|
|
|
|
-
|
|
|
|
- p = sp.run(
|
|
|
|
- ffmpeg_cmd,
|
|
|
|
- encoding="ascii",
|
|
|
|
- capture_output=True,
|
|
|
|
- )
|
|
|
|
-
|
|
|
|
- Path(cache_path).unlink(missing_ok=True)
|
|
|
|
-
|
|
|
|
- if p.returncode != 0:
|
|
|
|
- logger.error(f"Unable to convert {cache_path} to {file_path}")
|
|
|
|
- logger.error(p.stderr)
|
|
|
|
- Path(cache_path_mp4).unlink(missing_ok=True)
|
|
|
|
- continue
|
|
|
|
-
|
|
|
|
# copy then delete is required when recordings are stored on some network drives
|
|
# copy then delete is required when recordings are stored on some network drives
|
|
- shutil.copyfile(cache_path_mp4, file_path)
|
|
|
|
- Path(cache_path_mp4).unlink(missing_ok=True)
|
|
|
|
|
|
+ shutil.copyfile(cache_path, file_path)
|
|
|
|
+ os.remove(cache_path)
|
|
|
|
|
|
rand_id = "".join(
|
|
rand_id = "".join(
|
|
random.choices(string.ascii_lowercase + string.digits, k=6)
|
|
random.choices(string.ascii_lowercase + string.digits, k=6)
|