Date: Fri, 24 Apr 2020 00:53:28 -0600 From: "@lbutlr" <kremels@kreme.com> To: FreeBSD <freebsd-questions@freebsd.org> Subject: Re: Audio recording on demand (level + duration) Message-ID: <AD40E5FB-7324-4740-9D51-72E56B33EDB0@kreme.com> In-Reply-To: <20200423175126.e9eea9fb.freebsd@edvax.de> References: <20200423175126.e9eea9fb.freebsd@edvax.de>
next in thread | previous in thread | raw e-mail | index | archive | help
On 23 Apr 2020, at 09:51, Polytropon <freebsd@edvax.de> wrote: > continuously monitor audio input > if volume > 0: > create UTC timestamp (YYYY-MM-DD_HH:MM:SS) > start recording (in background) > if volume still =3D 0 again > send TERM signal do recorder > recorder closes file (valid file!) > if duration of file > 10 seconds: > convert file to MP3 (in background) > rename file using timestamp > else: > remove file My guess is that you need to do something like this: cat /dev/dsp > tmpfile Periodically copy and scan tmpfile for portions that have sound = levels above x% Clip those parts into new file Repeat scan until reaching ends fo file When entire file is scanned, delete copy and cat > /dev/null tmpfile The exact methods probably depend on the output of cat /dev/sndstat > I'd like to create the "wrapper" as a simple shell script. >=20 > So when this system runs for a while, I will have certain > files, let's say >=20 > 2020-04-23_17:00:01.mp3 > 2020-04-23_17:35:28.mp3 > 2020-04-23_21:19:57.mp3 > ... and so on ... If you process the file once per day, this is trivial, simply get the = start of the sound duration from the copy and add this to the dat = eyesteray. Even if you want to process the sound more frequently, it is = not difficult, just more tedious. > An option would be to add the duration > to the filename (2020-04-23_21:19:57_00:24:13.mp3 - a file > that contains 24 min 13 sec audio). Very easy to get the duration of your sound file from, for example, = ffmpeg. Keep in mind, I=E2=80=99m guessing here, but hopefully this will help at = least look at another direction and maybe figure out or find the answer = you need. --=20 I intend to live forever. So far, so good.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AD40E5FB-7324-4740-9D51-72E56B33EDB0>