You are not logged in.
Pages: 1
Following on from my other thread about seamless audio recording, I think I have the seamless part figured out (thanks to a fifo buffer ), but my issue now is that I need the output filename to change every hour on the hour, not just an hour from when the script started.
For example:
Script starts at 9:20am. I need it to change filename at 10:00am, not at 10:20am. So the first recording will be 40 minutes, and everything after will be the full hour.
This is the script at the moment, sleeping for the full hour though. Ideally I'd like to be able to catch SIGUSR1 in the script and then change filenames at that time (ie, do the kill line and reloop). That way I could just start the script, then crontab a `kill -SIGUSR1 <pid>` every hour...
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 $OGGENC_PID
done
Any ideas, thoughts, suggestions or solutions welcomed
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
Why not just look at the start time minutes and subtract the difference between that and 60 in seconds from 3600 only for the first loop? Then, each loop would be the full 3600 seconds.
Offline
Use "trap".
archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson
Offline
Thanks guys - I've managed to get this going in perl using it's trap handling and all is good
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
When you have everything completed, would you please post your final result? This problem ran through my head for over an hour last night after reading the originating thread. I'd love to see the final.
Offline
And if you can generalize it, post it to the script wiki.
archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson
Offline
BTW, with epoch time you can do some neat things using modulo math to get what you want:
sleep $(expr 3600 - $(date +%s) % 3600)
Using that line will always sleep until the next hour, on the hour.
Offline
I'm getting there... I'll definitely post the outcome if there's interest
The cycle filename on the hour problem has been dealt with by using perl and SIGUSR1... Here's where I'm up to atm:
http://pastebin.com/m73d83a50
I've got a completely new problem now:
http://bbs.archlinux.org/viewtopic.php?pid=462663
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
Pages: 1