Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Fri 19 Dec 2014, 23:20
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Security/Privacy
"mp3looprecord" security recorder
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [11 Posts]  
Author Message
greengeek

Joined: 20 Jul 2010
Posts: 2746
Location: New Zealand

PostPosted: Wed 19 Nov 2014, 14:28    Post subject:  "mp3looprecord" security recorder  

(NOTE: I have put this in security as that is my intended use but Flash may move it somewhere else as it can be used for recording of other things too...)


"mp3looprecord" started out as a method for recording security audio from a microphone in a perpetual loop so that I could capture voices 24 hours a day and play them back after a burglary or vandalism. The script itself does not know where it is recording from - the user has to set the audio source in the mixer settings first.

It can can be left running all day or all week collecting audio from whatever audio source is set up in your mixer - allowing you to review the audio later. It will record on-the-fly to mp3 files, and will then start to overwrite the oldest file when it detects that it has reached the end of the storage location free space set by the user.

The .pet installs the main mp3looprecord script in /usr/bin, and also adds a "looprecord_start" and "looprecord_stop" script in /root. (Also adds a HowTo document in /root).

The user defines how much data they want to retain (and therefore how many hours recording is in the loop) by specifying the length of each individual recording, the total number of files they want to keep in the loop, and the mp3 bitrate quality (which affects the total size and quality of the file). See the HowTo for guidance and time calculation.

When the script is first installed it defaults to a short record time and low number of files to allow the user to get familiar and do basic testing.

When you click /root/looprecord_start it brings up a terminal which asks the user where they want to have the record directory stored. I use either /root (on livebooted systems which have plenty of ram) or an external usb stick or usb HDD eg: /mnt/sdb1
(If you have a frugal installation take care not to overfill your savefile if you have chosen not to record to an external location).

When the user is ready to extend the record time for normal use they should set the following parameters in the script:

RECORDINGLENGTH
- This defines the length of each individual recorded segment in seconds. If set to 180 this makes each recorded file 3 minutes long.

MAXFILES
- This defines the maximum number of files that is necessary to capture the required timeframe
yet not exceed available storage area.
- For example: If we wanted to capture a loop of 3 minute files that covered a full day we
would need to set maxfiles to 480 (ie: if using 3 minute files we will generate 20 per hour.
There are 24 hours in the day so we need 20 x 24 files = 480).

#I recommend starting with a low maxfiles number for testing purposes.
#NOTE: I do not recommend using a value of MAXFILES=1. Best to use 2 or
#above to avoid overwriting previous audio too soon.

MP3BITRATE
- This defines the bitrate of the final mp3 encoding.
#"32" gives small file size yet generally acceptable quality.
#"64" can give better audio if you have a good microphone.
#"128" or higher just seems a bit too fancy for my needs...
#Higher settings create large file sizes.

Example: if using a record length of 180 (3 minutes), maxfiles of 480 (24 hours) and
a mp3bitrate of 32 you will require approximately 340MB of free space.

This sounds a lot, but if you are recording to a 4GB or larger usb stick you can cover
quite a long time period

#If bitrate=32 + recordinglength=180 this gives an audio segment size of 704kB
#which covers 3 minutes. Multiply that by 20 to get 1 hour = 14080kB. (= 14MB)
#3mins @ bitrate=32 = 704kB
#1 hour @ bitrate=32 = 14080kB = 14MB
#1 day @ bitrate=32 = 337920kB = 340MB (these figures approximate only)


Thanks to the puppians in this thread who helped me assemble this. More development to come later I hope.
.
mp3looprecord-0.2.pet
Description 
pet

 Download 
Filename  mp3looprecord-0.2.pet 
Filesize  4.52 KB 
Downloaded  19 Time(s) 
Back to top
View user's profile Send private message 
stemsee

Joined: 27 Jun 2013
Posts: 672
Location: London

PostPosted: Thu 20 Nov 2014, 17:09    Post subject:  

hi GreenGreek

This looks really useful. Does it have a stealth mode? Screen off - in background?

cheers
stemsee
Back to top
View user's profile Send private message MSN Messenger 
watchdog

Joined: 28 Sep 2012
Posts: 673

PostPosted: Fri 21 Nov 2014, 01:17    Post subject:  

Is it possible to record only when a new sound is heard? I think to a behaviour like motion detector for webcams: a sound detector. The recording should stop with white noise or fixed sound. It would be easier to review the recording.
Back to top
View user's profile Send private message 
greengeek

Joined: 20 Jul 2010
Posts: 2746
Location: New Zealand

PostPosted: Fri 21 Nov 2014, 04:36    Post subject:  

watchdog wrote:
Is it possible to record only when a new sound is heard? I think to a behaviour like motion detector for webcams: a sound detector. The recording should stop with white noise or fixed sound. It would be easier to review the recording.
Yes, this is physically possible but not with this script. While i was developing this I trialled "sox" which allows recording to be triggered by a preset audio threshold. I hope to incorporate that in another script after more testing.

I made some comments and links about sox here
.

Last edited by greengeek on Fri 21 Nov 2014, 04:52; edited 1 time in total
Back to top
View user's profile Send private message 
greengeek

Joined: 20 Jul 2010
Posts: 2746
Location: New Zealand

PostPosted: Fri 21 Nov 2014, 04:47    Post subject:  

stemsee wrote:
This looks really useful. Does it have a stealth mode? Screen off - in background?
Turning the screen off can be a complicated process depending on the type of PC and acpi / dpms settings etc so is beyond the scope of this script. However, I do have a version which runs "quietly" and does not interact with the user onscreen (except in some error conditions). It just ticks along in the background with nothing showing.

The downside of this is that it does not ask the user where they want to store the recording directory (defaults to /root) but it is easy for the user to open the script and manually specify the STORAGELOCATION at the same time as setting the recordinglength, maxfiles and mp3bitrate.

This .pet installs the start and stop files (plus HowTo.txt) in /root (and does not use the script that was in /usr/bin previously). These two files can be placed anywhere (including on a usb stick).

On my PC I find that the screen does go blank when the screensaver timeout occurs, and the recording carries on in the background, so that will be as close to stealth mode as I can get.
mp3stealthrecord-0.1.pet
Description 
pet

 Download 
Filename  mp3stealthrecord-0.1.pet 
Filesize  4.3 KB 
Downloaded  15 Time(s) 
Back to top
View user's profile Send private message 
stemsee

Joined: 27 Jun 2013
Posts: 672
Location: London

PostPosted: Fri 21 Nov 2014, 05:06    Post subject:  

@GreenGeek

Thank you very much. I look forward to testing it out.

stemsee
Back to top
View user's profile Send private message MSN Messenger 
watchdog

Joined: 28 Sep 2012
Posts: 673

PostPosted: Mon 24 Nov 2014, 12:29    Post subject:  

I have tested this code which works for me:

Code:
arecord -d $RECORDINGLENGTH -D plughw:0,0 -f cd | lame -b $MP3BITRATE - $path/$NAME.mp3
sox  $path/$NAME.mp3 $path/$NAME.out.mp3 silence 1 0.1 2.5% -1 0.1 2.5%
rm $path/$NAME.mp3


I have left:

RECORDINGLENGTH=60

MAXFILES=1440

A new file every minute max 24 hours. Other arrangements can be tested. I have used in tahr sox from the link above.
Back to top
View user's profile Send private message 
greengeek

Joined: 20 Jul 2010
Posts: 2746
Location: New Zealand

PostPosted: Mon 24 Nov 2014, 14:17    Post subject:  

watchdog wrote:
I have tested this code which works for me:
Code:
arecord -d $RECORDINGLENGTH -D plughw:0,0 -f cd | lame -b $MP3BITRATE - $path/$NAME.mp3
sox  $path/$NAME.mp3 $path/$NAME.out.mp3 silence 1 0.1 2.5% -1 0.1 2.5%
rm $path/$NAME.mp3

.

Hi watchdog - thanks for the info. Some questions:
1) It looks as if you are using arecord and sox code together in the same script - So it seems that you are recording with arecord, piping to lame for the mp3 conversion, then using sox to analyse the output file and strip silences - have I understood that correctly?
2) Could you confirm which of the sox pets you used please? (could you link to the post you found worked on Tahr?)
3) How did you choose the "silence" values? Were you using a talking voice to set the trigger level or trapping some other sound (door closing, dog barking etc) as a trigger point?
cheers!
Back to top
View user's profile Send private message 
watchdog

Joined: 28 Sep 2012
Posts: 673

PostPosted: Mon 24 Nov 2014, 15:16    Post subject:  

greengeek wrote:
watchdog wrote:
I have tested this code which works for me:
Code:
arecord -d $RECORDINGLENGTH -D plughw:0,0 -f cd | lame -b $MP3BITRATE - $path/$NAME.mp3
sox  $path/$NAME.mp3 $path/$NAME.out.mp3 silence 1 0.1 2.5% -1 0.1 2.5%
rm $path/$NAME.mp3

.

Hi watchdog - thanks for the info. Some questions:
1) It looks as if you are using arecord and sox code together in the same script - So it seems that you are recording with arecord, piping to lame for the mp3 conversion, then using sox to analyse the output file and strip silences - have I understood that correctly?
2) Could you confirm which of the sox pets you used please? (could you link to the post you found worked on Tahr?)
3) How did you choose the "silence" values? Were you using a talking voice to set the trigger level or trapping some other sound (door closing, dog barking etc) as a trigger point?
cheers!


I have edited /usr/bin/mp3looprecord script. At the end you find:

Code:
arecord -d $RECORDINGLENGTH -D plughw:0,0 -f cd | lame -b $MP3BITRATE - $path/$NAME.mp3


Add my sox lines following that line. Install sox from:

http://www.murga-linux.com/puppy/viewtopic.php?p=483166#483166

Adjust in /usr/bin/mp3looprecord at the beginning RECORDINGLENGTH and MAXFILES as you want (for example 1800 (secs) and 48 respectively for one day recoding).


Man of sox:

http://linux.die.net/man/1/sox

Useful link:

http://digitalcardboard.com/blog/2009/08/25/the-sox-of-silence/

Thanks greengeek!

EDIT: you can adjust sox's threshold of silence varying the percentage: I used to cut noise <= 2.5%
Back to top
View user's profile Send private message 
greengeek

Joined: 20 Jul 2010
Posts: 2746
Location: New Zealand

PostPosted: Thu 27 Nov 2014, 15:09    Post subject:  

Quote:
sox $path/$NAME.mp3 $path/$NAME.out.mp3 silence 1 0.1 2.5% -1 0.1 2.5%
I have been tinkering with sox but so far i can't come up with values that are sensitive enough to trigger on burglars voices, without triggering on general background hiss/whitenoise from the mic and soundcard, so I will probably stick to the continuous recording method for now. I did have a play with the sound activated recording function in Audacity too - it works quite well. The activation level seems reasonably sensitive.

I'm currently using Slacko 5.6 so i trialled an Audaccity sfs that rufwoof made available here. Method as follows:
- start Audacity
- click Transport, Sound Activated Recording, (toggle on)
- click Transport, Sound Activation Level... and set to -10dB. This was the level that worked best for me, but I guess that depends on how the mixer levels are set.
- click red 'record' icon.

I will do some further sound activated trials on different soundcards and mics.
Back to top
View user's profile Send private message 
watchdog

Joined: 28 Sep 2012
Posts: 673

PostPosted: Thu 27 Nov 2014, 16:14    Post subject:  

I also tried adding the following line after arecord line:

Code:
sox  $path/$NAME.mp3 $path/$NAME.out.mp3 silence 1 0.1 -35d -1 0.1 -35d


The silence threshold in decibel expressed better works: the right decibel value depends on your mixer levels and mic quality.
I think the best is the original script with the only sox line added for a fast review without removing the original piece of recording for further evaluation.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [11 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Security/Privacy
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0901s ][ Queries: 12 (0.0045s) ][ GZIP on ]