Update rtps_daily_recorder.py

This commit is contained in:
2025-10-17 18:05:02 +02:00
committed by GitHub
parent a817113777
commit e5c18c8df9
+9 -2
View File
@@ -322,12 +322,17 @@ class CameraService:
f.write(f"file '{jpg.absolute()}'\n")
f.write(f"duration 0.2\n")
# Erstelle Timestamp-Text (z.B. "Oktober 14:25")
start_time = cutoff_time.strftime("%d.%m.%Y %H:%M")
cmd = [
'ffmpeg', '-y',
'-f', 'concat',
'-safe', '0',
'-i', str(temp_list),
'-vsync', 'vfr',
'-vf', f"drawtext=fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf:text='{start_time}':fontcolor=white:fontsize=24:box=1:boxcolor=black@0.7:boxborderw=5:x=10:y=h-th-10",
'-c:v', 'libx264',
'-pix_fmt', 'yuv420p',
'-preset', 'fast',
@@ -335,15 +340,16 @@ class CameraService:
str(output_file)
]
subprocess.run(cmd, check=True, capture_output=True)
if output_file.exists() and output_file.stat().st_size > 0:
logging.info(f" Video erstellt: {output_file}")
logging.info(f" Video erstellt: {output_file}")
# Lösche nur die GUTEN JPGs (graue wurden schon gelöscht)
for jpg in jpg_files:
jpg.unlink()
logging.info(f" {len(jpg_files)} gute Screenshots gelöscht nach Videoerstellung")
logging.info(f" {len(jpg_files)} gute Screenshots gelöscht nach Videoerstellung")
return True
except Exception as e:
@@ -353,6 +359,7 @@ class CameraService:
if temp_list.exists():
temp_list.unlink()
def cleanup_old_files(self):
"""Lösche alte Video- und Bilddateien (nur älter als 7 Tage)"""
cutoff_time = datetime.now() - timedelta(days=CONFIG["VIDEO_RETENTION_DAYS"])