Date: Fri, 24 Apr 2020 09:06:35 +0100 From: Steve O'Hara-Smith <steve@sohara.org> To: Polytropon <freebsd@edvax.de> Cc: FreeBSD Questions <freebsd-questions@freebsd.org> Subject: Re: Audio recording on demand (level + duration) Message-ID: <20200424090635.1041850d0bc1ebdee783678d@sohara.org> 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 Thu, 23 Apr 2020 17:51:26 +0200 Polytropon <freebsd@edvax.de> wrote: > My question is: > > What file can I monitor (and how) to obtain an information > about _if_ there is some audio input? I'd probably use the > rec command from the sox package for recording, and probably > something like lame for MP3 conversion. Use sox it has no trouble encoding to mp3 in real time (or flac which is my preferred recording format) and can be told to skip leading silence - I use it like this to create timestamped recordings without leading silence. NOW=`date -Iseconds | cut -c12-19` rec $NOW.flac silence 1 0.5 0.1% You could start with that and watch for the file to start growing to see when sound starts. But sox is cleverer than that - viz this extract from man sox: rec -r 44100 -b 16 -e signed-integer -p \ silence 1 0.50 0.1% 1 10:00 0.1% | \ sox -p song.ogg silence 1 0.50 0.1% 1 2.0 0.1% : \ newfile : restart records a stream of audio such as LP/cassette and splits in to multiple audio files at points with 2 seconds of silence. Also, it does not start recording until it detects audio is playing and stops after it sees 10 minutes of silence. I suspect you can torture sox into doing pretty much what you want but you'll have to wrap your head round the silence and newfile options :) -- Steve O'Hara-Smith <steve@sohara.org>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20200424090635.1041850d0bc1ebdee783678d>