You are not logged in.

#1 2008-12-10 23:32:10

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,224
Website

Seamless but Split Recording

I'm the Communications Officer for my local group of fire brigades - we have a problem at the moment that only our main despatch channel is recorded and archived (in case something goes bad). We also have "fireground" channels that are used locally for operations at a fire, but they're arguably more important to record than the despatch channel.

What I want to do is get a little PC stashed in a corner somewhere, with a line in and big hard drive. Plug in a radio / scanner and record the line input constantly.

1) The files will need to be split for obvious reasons, as well as point 2. I'm not sure how to split the files seamlessly. Ie, stop recording and start a recording to a new file instantly. The gap between the 2 files has to be 0 otherwise knowing my luck, it will be that half a second that didn't get recorded that the whole investigation revolves around. (The "do not" in "do not enter that area" could be lost in half a second on the radio)
2) Given that disk space is a finite resource, and I don't want to have to manually dump files every X period, I want a rolling 24 - 48 hours of audio. Possibly more depending on the available disk space, but minimum 24 - 48 hours. If something 'bad' does happen, then we have 24 - 48 hours to scrape the needed recordings off the box. If the recording are split in to different files every hour (or 30 minutes) then this will be easy to do.

Ideally a command line based solution would be good. Add the command to rc.local so it starts at boot. Have an hourly cronjob that deletes the oldest recordings. Easy!

Any input or ideas would be great. Ultimately I'd investigate putting it all together in to a Carputer (Truckputer?) and mounting in the actual fire trucks as well as at the station.

Offline

#2 2008-12-11 02:19:29

Daenyth
Forum Fellow
From: Boston, MA
Registered: 2008-02-24
Posts: 1,244

Re: Seamless but Split Recording

Sounds like a solid plan... I have no clue about the instant split. I agree that any gap is unacceptable, but I don't know of any solutions off the top of my head. Tried googling?

Offline

#3 2008-12-11 02:46:48

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,224
Website

Re: Seamless but Split Recording

Nothing specific that I can find...

Best I've got so far is:

while true ; do
   FNAME=`date +%Y%m%d-%a-%H00_%s`
   arecord --format cd --duration 3600 --file-type raw | oggenc - -r -o $FNAME.ogg &
   sleep 3600
done

This quite possibly wouldn't be seamless though, especially if there's disk delays when the loop loops

The other problem is it rolls the current file an hour after it started (ie, if the script started at 9.32am, then it will roll at 10.32am). This means each full hour will be spread across multiple files (ie, 10.00am to 10.59am will be in 2 files)

Last edited by fukawi2 (2008-12-11 02:50:24)

Offline

#4 2008-12-11 03:08:17

dav7
Member
From: Australia
Registered: 2008-02-08
Posts: 674

Re: Seamless but Split Recording

The only solution I can think of is theoretical: a few seconds before the last recorder process is scheduled to stop, a new recorder process is initialized. Only after a watchdog of some kind has verified that the new recorder is ready to record is the old one told to start cleaning up and shutting down. This will mean that if the system is low on RAM or being slow for whatever reason, a slowly-starting recorder won't mean loss of audio.

This may well mean there's a bit of "repeat" at the end and beginning of recordings though, and may not be wanted, but will ensure that you never lose anything.

-dav7


Windows was made for looking at success from a distance through a wall of oversimplicity. Linux removes the wall, so you can just walk up to success and make it your own.
--
Reinventing the wheel is fun. You get to redefine pi.

Offline

#5 2008-12-11 03:17:13

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,224
Website

Re: Seamless but Split Recording

That's my other solution - reduce the sleep time by 5 seconds or so so they overlap a bit. Better to have a bit of a double-up rather than miss something.

EXCEPT, I don't think ALSA will let 2 processes record at the same time (ie, share the input?)

Theory:
Would there be a way to use fifo buffers? ie:

cat /dev/audio/input > /dev/audio_fifo
arecord < /dev/audio_fifo

That way, when record 1 stops, the fifo buffer starts filling, and once recorder 2 is ready, it just pulls out what's backed up in the fifo?

Offline

#6 2008-12-11 03:33:34

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,224
Website

Re: Seamless but Split Recording

Ooooohh, I've been thinking about the fifo thing... Instead of buffering the actualy audio, buffer the output from arecord....?

Would this work?

mkfifo /tmp/audio
arecord --format cd --file-type raw > /tmp/audio
while true ; do
   FNAME=`date +%Y%m%d-%a-%H00_%s`
   oggenc /tmp/audio -r -o $FNAME.ogg
   OGGENC_PID=$!
   sleep 3600
   kill OGG_ENC
done

Offline

Board footer

Powered by FluxBB