39 lines
No EOL
980 B
Python
Executable file
39 lines
No EOL
980 B
Python
Executable file
#!/usr/bin/env python3
|
|
import os
|
|
import subprocess
|
|
import datetime
|
|
import pytz
|
|
|
|
OUTDIR = "chunks"
|
|
CHUNK_SECONDS = 10800 # 3 Stunden
|
|
|
|
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}")
|
|
|
|
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(CHUNK_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() |