bootshorn_investigation/create_chunks.py
2025-05-30 19:54:06 +02:00

42 lines
No EOL
1.1 KiB
Python
Executable file

#!/usr/bin/env python3
import os
import subprocess
import datetime
import pytz
OUTDIR = "chunks"
DURATION = 10800 # 3 Stunden
SOURCE = "pulse" # funktioniert mit PulseAudio
os.makedirs(OUTDIR, exist_ok=True)
def record_section():
tz = pytz.timezone("Europe/Berlin")
now = datetime.datetime.now(tz)
timestamp = now.strftime("%Y%m%d-%H%M%S")
filename = os.path.join(OUTDIR, f"{timestamp}.flac")
print(f"🎙️ Starte Aufnahme: {filename}")
duration_seconds = DURATION # Feste Dauer von 3 Stunden
cmd = [
"ffmpeg",
"-f", "pulse",
"-i", "alsa_input.usb-HANMUS_USB_AUDIO_24BIT_2I2O_1612310-00.analog-stereo",
"-ac", "1",
"-ar", "96000",
"-sample_fmt", "s32", # gerät kann nur 24bit, aber flac kann nur 32bit container
"-t", str(duration_seconds),
"-c:a", "flac",
"-compression_level", "12",
filename
]
subprocess.run(cmd)
print(f"✅ Aufnahme abgeschlossen: {filename}")
def main():
while True:
record_section()
if __name__ == "__main__":
main()