Start recording at Bang
June 24, 2015 1:04 PM   Subscribe

I want to start a few seconds video recording prompted by a gun blast. Plan is to attach a USB camera to a spotting scope and have my Mac start recording a few seconds of video the moment a shot is fired. The start and stop of the Video recording can be done with Automator ad/or Apple script. I am looking for an app or hardware solution to prompt the recording. It could be an application that starts a script once a sound exceeds a certain level. Perhaps even better a motion sensor that will sense the shock in the rifle stock. Thanks for your help. Rogier
posted by Mac-Expert to Technology (8 answers total)
 
One issue, depending on what aspect of this you are trying to record, is the lag time between the sound of a bang, as well as the lag time between the microphone triggering a script to start recording, and the actual time that recording begins. The first lag time will be based on the speed of sound and distance between barrel and microphone, while the second lag time will be a factor of the microphone and the latency of the OS monitoring the signal from the mic. The sound processing latency in OS X is around 100 ms, I think.

If you want to start recording just before the bullet fires, perhaps you could hook up an LED photosensor circuit that would be blocked as the trigger is pulled. You have an LED emitting light on one end, and a sensor on the other end that receives that light signal. As the trigger is pulled, the trigger temporarily blocks the light going between emitter and sensor.

Once the photosensor is blocked, the circuit is triggered. Perhaps that circuit starts playing a sound about 100-500 ms before the trigger is pulled, which starts a script or whatever to initiate video recording, presumably just before the bullet is actually fired or before it leaves the barrel.
posted by a lungful of dragon at 1:15 PM on June 24, 2015


In other words, by the time a microphone hears a bang and fires off a script, there might not be much interesting to record. You might want to think about triggering recording before the trigger is fully pulled.
posted by a lungful of dragon at 1:19 PM on June 24, 2015


Response by poster: Thanks for your quick input :-)

Microphone (sensor) wil be placed near the rifle so there will be no delay other than the software (Quicktime) to start recording.
Meantime I realized that a vibration sensor might be better suited for this task. It could be the build inn motion sensors in the Mac or a Piezo element attached to the bench or the rifle stock.
posted by Mac-Expert at 1:31 PM on June 24, 2015


Can you record a continuous buffer and save the previous 5 to next 5 seconds after a triggering event? That might be the easiest way. OBS can do this for game capture, not sure if a tool for webcam in exists (though OBS works with webcams)
posted by Alterscape at 1:34 PM on June 24, 2015


Response by poster: If lag time is a problem I could also reverse the script along these lines:

1. Start recording (space bar)
2. Pulse from sensor
3. Wait 3 seconds
4. Delete all recording until 5 seconds ago
5. Loop playback

The missing ingredient is the sensor that gives the pulse.

Camera will be plain old USB that is easily recognized in OSX
posted by Mac-Expert at 2:10 PM on June 24, 2015


One of these sensors intended for high-speed photography might be of interest.
posted by Jack Karaoke at 6:49 PM on June 24, 2015


Best answer: Use soundmeter.

If you're on OSX and have brew, install portaudio with
 brew install portaudio
install pyaudio with
 pip install --allow-external pyaudio --allow-unverified pyaudio pyaudio
and then install soundmeter:
 pip install soundmeter
Craft a bash script that will run some applescript, and save it as trigger.sh. Finally, from the command line, run
soundmeter --trigger +1000 --action exec --exec trigger.sh
I just tested this on my computer, and it works like a charm. Of course, you'll have to adjust the '1000' value to something higher to only be triggered on a gunshot, etc.
posted by suedehead at 8:15 PM on June 25, 2015


Response by poster: Thanks!
Anything that will read the motion sensors in a laptop?
posted by Mac-Expert at 8:47 AM on June 26, 2015


« Older My mom is getting new boobs. How can I help her...   |   Please Stop. No, I don't think I will. Newer »
This thread is closed to new comments.