raspberry pi jam july

19
RASPBERRY PI JAM Setup Raspberry Pi as CCTV client

Upload: jon-ho

Post on 16-Apr-2017

184 views

Category:

Education


2 download

TRANSCRIPT

Page 1: Raspberry pi jam july

RASPBERRY PI JAM

Setup Raspberry Pi as CCTV client

Page 2: Raspberry pi jam july

Who am I?

• Name : Jon Ho• Occupation : Simcard OneXOX seller– Buy my prepaid card and top up RM 50, and you

get 2 years validity, FOR FREEEEEEE!• Part Time : Freelancer/Maker• Some Time : Busker/Farmer/Fisherman

Page 3: Raspberry pi jam july

CCTVRM1,020 vs RM1,980

Page 4: Raspberry pi jam july

RECIPE

• Hardware– 1 Command & Control Windows PC– Nth number of client Pi Camera

• Software– Raspbian Jessie on Raspberry Pi– Raspivid

www.raspberrypi.org/documentation/raspbian/applications/camera.md

– Zenmap, Mplayer on Windows PC

Page 5: Raspberry pi jam july

Linux Streaming• VLC

– Slowest– Easiest to set up

• Gstreamer– So-so speed– Complex to set up

• Netcat– Fastest!– No setup needed! Runs out of the box!

Page 6: Raspberry pi jam july

gator

Page 7: Raspberry pi jam july

What you need

• 1: Raspberry Pi 3

Page 8: Raspberry pi jam july

What you need (cont)

• 2: Pi Camera Module (Noir)

Page 9: Raspberry pi jam july

What you need (cont)

• 3: PC/Laptop Windows with zenmap/ncat (for network streaming stuff) and mplayer (for video stuff) installed– Both are opensource and freeeeee

Page 10: Raspberry pi jam july

Step 1: setup the C&C

• First, find out your C&C PC’s ip– Open a terminal in windows and run ipconfig

– Remember the ip, this is what your raspi will connect to

Page 11: Raspberry pi jam july

Step 1: setup the C&C (Cont)

• Second, in the same terminal, run ncat to pipe the stream to mplayer– C:\Users\jon>ncat -l -p 2222 | "C:\Program Files (x86)\MPlayer for

Windows\mplayer.exe" -fps 200 -demuxer h264es –– The -demuxer h264es arguments decode the stream into mpeg 4

Page 12: Raspberry pi jam july

Step 2: setup the pi camera• Setup Camera

– There are tons of tutorials of how to setup pi camera, so I will not cover that. Just make sure it looks something like below.

– Also if possible, try to get an enclosure for the raspi camera. You don’t want it to die every time somebody sneezes at it

Page 13: Raspberry pi jam july

Step 2: setup the pi camera (cont)

• Test Camera by running this command in the terminal– raspivid -o heuheuheu.h264 -t 10000– omxplayer heuheuheu.h264

Page 14: Raspberry pi jam july

Step 3: profit!

• Now put it all together by running this command on the raspi camera– raspivid -t 0 -w 1280 -h 720 -hf -ih -fps 20 -o - | nc 192.168.1.4 -k -l -p 2222

The –t 0 argument means raspivid will basically run forever streamed on port 2222

Page 15: Raspberry pi jam july

It’s alive!• It’s working!

Page 16: Raspberry pi jam july

Bonus Points

• SOUND– The demo had no sound, due to lack of usb mic. It

can stream sound. Try it out as homework.

• NETWORK SPEED– For best live action speed, use a wireless router

that can transmit on the 5GHz band. 2000++ Mbps means no lag whatsoever!

Page 17: Raspberry pi jam july

Bonus Points (cont)• MULTIPLEXING CAMERA– It is possible to multiplex the camera, although

stability issue may arise.

Page 18: Raspberry pi jam july

To learn more

• Raspivid– www.raspberrypi.org/documentation/raspbian/

applications/camera.md

• Netcat– www.binarytides.com/netcat-tutorial-for-

beginners/

Page 19: Raspberry pi jam july

DONATE• If you think this is cool beans and would like to send free money

so I don’t starve to death and keep making stuff like this, send it here:

BITCOIN1GhVoWnYq21mDEC6nSn2WZkuoPMAAarJrk

LITECOINLS1N3L34feg7GwwLWmcTqsmzfoUtzSMME6