Update rtps_daily_recorder.py
This commit is contained in:
@@ -322,12 +322,17 @@ class CameraService:
|
|||||||
f.write(f"file '{jpg.absolute()}'\n")
|
f.write(f"file '{jpg.absolute()}'\n")
|
||||||
f.write(f"duration 0.2\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 = [
|
cmd = [
|
||||||
'ffmpeg', '-y',
|
'ffmpeg', '-y',
|
||||||
'-f', 'concat',
|
'-f', 'concat',
|
||||||
'-safe', '0',
|
'-safe', '0',
|
||||||
'-i', str(temp_list),
|
'-i', str(temp_list),
|
||||||
'-vsync', 'vfr',
|
'-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',
|
'-c:v', 'libx264',
|
||||||
'-pix_fmt', 'yuv420p',
|
'-pix_fmt', 'yuv420p',
|
||||||
'-preset', 'fast',
|
'-preset', 'fast',
|
||||||
@@ -335,15 +340,16 @@ class CameraService:
|
|||||||
str(output_file)
|
str(output_file)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
subprocess.run(cmd, check=True, capture_output=True)
|
subprocess.run(cmd, check=True, capture_output=True)
|
||||||
|
|
||||||
if output_file.exists() and output_file.stat().st_size > 0:
|
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)
|
# Lösche nur die GUTEN JPGs (graue wurden schon gelöscht)
|
||||||
for jpg in jpg_files:
|
for jpg in jpg_files:
|
||||||
jpg.unlink()
|
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
|
return True
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -353,6 +359,7 @@ class CameraService:
|
|||||||
if temp_list.exists():
|
if temp_list.exists():
|
||||||
temp_list.unlink()
|
temp_list.unlink()
|
||||||
|
|
||||||
|
|
||||||
def cleanup_old_files(self):
|
def cleanup_old_files(self):
|
||||||
"""Lösche alte Video- und Bilddateien (nur älter als 7 Tage)"""
|
"""Lösche alte Video- und Bilddateien (nur älter als 7 Tage)"""
|
||||||
cutoff_time = datetime.now() - timedelta(days=CONFIG["VIDEO_RETENTION_DAYS"])
|
cutoff_time = datetime.now() - timedelta(days=CONFIG["VIDEO_RETENTION_DAYS"])
|
||||||
|
|||||||
Reference in New Issue
Block a user