python - Recording video from raspberry pi and saving it to a external hard drive -


i have raspberry pi model b, , raspberry pi camera module

i have either 3tb external hard drive or apple time capsule

what want able record video remotely (via ssh issue commands) , want record unlimited time until issue command stop recording. want video streamed , saved directly time capsule if possible.

so easy way of explaining want

  1. i plug in raspberry pi , connect via ssh
  2. tell raspberry pi start recording video @ 1080p @ 30fps
  3. while video being recorded getting saved directly onto time capsual
  4. have live preview mac video getting recorded can see if need adjust anything
  5. issue stop command end recording.

storage space not issue me.

this have work with

  1. raspberry pi model b
  2. 8gb sd card
  3. something similar ( don't know if same 1 ) http://www.amazon.co.uk/time-capsule-500gb-hard-drive/dp/b00132b0mg
  4. a network card : edimax ew-7811un 150mbps wireless nano usb adapter
  5. mac or pc

this first real question , i've been searching answer please excuse me if have done wrong or haven't put enough detail

raspberry pi forums has info on how done (note, examples here ran on pi, assuming correct software installed, etc.)

you stream video following command live stream , use script on mac pull in , save data

raspivid -t -0 -w 1280 -h 720 -fps 25 -b 2000000 -o - | ffmpeg -i - -vcodec copy -an -f flv -metadata streamname=mystream tcp://0.0.0.0:6666 

some investigation "tee" command camera piping file stream. this question has answer explains tee thusly:

echo "foo bar" | sudo tee -a /path/to/some/file 

so, combining two, may work you:

raspivid -t -0 -w 1280 -h 720 -fps 25 -b 2000000 -o - |tee -a /home/pi/my_big_hard_drive/my_video.h264 | ffmpeg -i - -vcodec copy -an -f flv -metadata streamname=mystream tcp://0.0.0.0:6666 

now, wrap line in script, can start remotely, (easier if transfer ssh keys on first, don't have enter passwords):

ssh -f pi@my_pi:/home/pi/bin/my_awesome_streamer.sh 

another script can used kill raspivid & when necessary, simple such

sudo killall -quit raspivid 

should kill program.

if want play stream directly on mac, can poke around ssh man page , find out cryptic flag combination allow stream data directly through ssh connection mac also.


Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -