Simple way to view IP Cameras on TV

vc1234 said:
And what software is used ?
 
Thanks.
 
also interested in this.
 
Desert_AIP said:
I finished my RPi project. 
I display the cams via the RPi and port it to the TV on HDMI (port 4).
 
I integrated it with Amazon Echo/Alexa.
 
The RPi is running a WeMo emulation which is native to the Echo. 
When the RPi is commanded by the Echo to turn something on, in this case it sends a CEC command to the TV via the HDMI port to turn on the TV and switch to port 4 as Active Source.
 
Because the WeMo protocol is native I can use the phrase "Alexa, turn on the Driveway Camera". 
Instead of the more clumsy "Alexa, tell Homeseer to turn on the Driveway Camera."
"Alexa, Driveway Camera on."  Also works.
 
drvnbysound said:
 
How many cameras are you displaying? Roughly what resolution and frame rate? 
I have it set up in a 2x2,each at 640x480 and 20 or 30 fps.

I'll post details on the weekend.

The link to the display script I'm using has a 3x2 or 3x3 layout on it.
 
I did this in stages and added a piece at a time.
I combined several tutorials to achieve the desired effect.
 
First was the display cameras script.
Next was WeMo emulation.
Next was CEC command functionality.
Finally I combined the WeMo and CEC commands.
 
As an interim step after I got the WeMo emulation running, I used a GPIO script to drive a relay.
That way you could issue voice commands to do something like close the garage door.
What I learned from that allowed me to substitue the GPIO script for the CEC commands.
I don't think I'll post that here because I don;t wantt o cause confusion.
 
I'll post the commands I used with the RPi for each section.  You should be able to cut and paste these in an SSH session using PuTTY or another client.
 
First the Display Cameras Script.
 
I used this tutorial:
 
https://community.spiceworks.com/how_to/123787-raspberry-pi-powered-surveillance-camera-monitoring-display
 
Start with a clean install of the latest Raspbian Jessie.
Then make sure everything is up to date
 
Software

Code:
sudo apt-get update && sudo apt-get upgrade -y

 
Firmware

Code:
sudo apt-get install rpi-update && echo Y | sudo rpi-update

 
Display cameras uses Omxplayer & Screen
Install Omxplayer & Screen
 

Code:
sudo apt-get install omxplayer 
 
sudo apt-get install screen

 
Then increase the GPU memory
Use raspi-config
Set aside 256-512 MB to GPU
 

Code:
sudo raspi-config

 
Also, while in raspi-config, tell the script to hold until network is available.
Select "Wait for Network at Boot" in raspi-config. 
 
Determine the camera layout math and pixel coordinates, see link above for several examples.
 
 
Edit config.txt to set memory and display limits
You want to set the output up for display on a TV.
 

Code:
sudo nano /boot/config.txt 

 
 
Add or un comment lines
For 16:9 display
 
sdtv_aspect=3
 
Group=1=CEA, mode=16=1080P 60Hz
 
hdmi_group=1
hdmi_mode=16
 
 
Determine your camera stream URLs.  I tried this with both http and RTSP streams and it works with both.
I'm using Vivotek cameras, use the URL for your particular camera.  
I also set up a view only user ID and password on the cameras so I wasn't using the root password.
The script will auto scale the streams, but I found that after it ran for awhile the screen went blank.  Even with the screen saver turned off.  Since I have 4 streams per camera, I ded icated one to this task and formatted it as a 640x480 native resolution and used that size for each display panel.
 
Create "displaycameras" script
Replace the <...camX url...> with the RTSP or RTMP or http URLs for your cameras.
NOTE: The command that calls the first camera feed (line 13) has the added option, "-b", which sets background to black
 

Code:
sudo nano /etc/init.d/displaycameras

 
 
Script contents for 4x4 layout 4:3 with 640x480 sources (or windows) 21 pixel frame above and horizontally between feeds:
-------------------------------------------------------------- 
#!/bin/bash 
### BEGIN INIT INFO 
# Provides: omxplayer 
# Required-Start: 
# Required-Stop: 
# Default-Start: 2 3 4 5 
# Default-Stop: 0 1 6 
# Short-Description: Displays camera feeds for monitoring 
# Description: 
### END INIT INFO
 
# Camera Feeds & Positions 
top_left="screen -dmS top_left sh -c 'omxplayer --win \"0 21 640 501\" rtsp:// <...cam1_url...> -b --live '"; 
top_right="screen -dmS top_right sh -c 'omxplayer --win \"640 21 1280 501\" rtsp:// <...cam2_url...> --live'"; 
bottom_left="screen -dmS bottom_left sh -c 'omxplayer --win \"0 522 640 1002\" rtsp:// <...cam3_url...> --live'"; 
bottom_right="screen -dmS bottom_right sh -c 'omxplayer --win \"640 522 1280 1002\" rtsp:// <...cam4_url...> --live'";
 
# Camera Feed Names 
# (variable names from above, separated by a space) 
camera_feeds=(top_left top_right bottom_left bottom_right)
 
# Sleep for 1 minute on startup to allow network to establish
# This line is optional, but helps with the periodic restarts we'll initiate in crontab
# It will delay startup for one minute when you run the application.  
# This may cause you to think it's not working correctly. 
# I recommend commenting the line below out during testing.
sleep 1m
 
 
#---- There should be no need to edit anything below this line ----
 
# Start displaying camera feeds 
case "$1" in 
start) 
for i in "${camera_feeds[@]}" 
 do 
 eval eval '$'$i 
done 
echo "Camera Display Started" 
;;
 
# Stop displaying camera feeds 
stop) 
 sudo killall omxplayer.bin 
 echo "Camera Display Ended" 
;;
 
# Restart any camera feeds that have died 
repair) 
for i in "${camera_feeds[@]}" 
do 
 if !(screen -list | grep -q $i) 
 then 
eval eval '$'$i 
 echo "$i is now running" 
fi 
done 
;;
 
*) 
echo "Usage: /etc/init.d/displaycameras {start|stop|repair}" 
exit 1
 
;; 
esac 
-------------------------------------------------------------- 
 
 
Next, change permissions for displaycameras script to make it executable
 
 

Code:
sudo chmod 755 /etc/init.d/displaycameras

 
 
 
 
Script Use:
Start the camera feeds: 

Code:
/etc/init.d/displaycameras start

 
Close the camera feeds: 

Code:
/etc/init.d/displaycameras stop

 
Re-open any closed camera feeds: 

Code:
/etc/init.d/displaycameras repair

 
 
 
Update the rc.d file to initialize the script on startup
 

Code:
sudo update-rc.d displaycameras defaults
 
sudo update-rc.d displaycameras remove 

 
 
I recommend setting a static IP address.
This will come into play later with the WeMo emulation.
 
 
Set up automated reboot and restart using the crontab
crontab options * * * * * (five registers * = all of that category)
registers 1-5
1) min (0-59)
2) hour (0-23)
3) day of month (1-31)
4) month (1-12)
5) day of week (0-7) : 0 and 7 are both Sunday
 
0 3 * * * sudo reboot -> reboots the PI everyday at 3AM -> 3:00
1-59/5 * * * * /etc/init.d/displaycameras repair -> restarts the cameras every 5 minutes if they hang but not during reboots -> i.e. minute 0 to 1 not included
 
Edit the crontab
 

Code:
crontab -e

 
 
 
Add to bottom of file:
-------------------------------------------------------------- 
0 3 * * * sudo reboot 
30 0-23/4 * * * /etc/init.d/displaycameras repair
-------------------------------------------------------------- 
 
 
Turn Off screen saver
 

Code:
sudo nano /etc/kbd/config 

 
BLANK_TIME=0
 
POWERDOWN_TIME=0
 
 

Code:
sudo nano ~/.bashrc

 
setterm -blank 0 -powerdown 0
 
 
That's it for the first part.
Here are two links I used for the next part.
 
Alexa WEMO
http://www.instructables.com/id/Hacking-the-Amazon-Echo/
 
GPIO Relay
http://www.instructables.com/id/Control-Any-Remote-From-a-Raspberry-Pi-and-Amazon-/?ALLSTEPS
 
Thanks for sharing, very interesting.
 
Are you communicating with the cameras over the wire or WiFi ? 
 
With my cameras, I have a main stream (1920x1080) and one sub-stream (640x480, I think).  The main streams go to an Xprotect Milestone box, and then you can view live/recording by connecting to the Milestone server or directly to the cameras.  There seems to be no problem using the same main stream both for recording to the Xprotect box and viewing using a web browser connected to the camera.
 
Yet, I cannot figure out a simple way to display permanently a hi-res 4x4 image via an HDMI input on my TV.
 
I thought about running an Xprotect app or maybe just a browser on an Intel Windows stick connected to the TV HDMI port, but I am not sure it's a good idea since each main stream uses about 2-3Mbit/s, and I'd prefer to use WiFi rather than a pull an rj45 cable for something which is mere a convenience -- I can easily see the same 4x4 on my iPad.  Also, I am not sure if a 640x480 4x4 on a big screen TV would make any sense in comparison to the full resolution display on the iPad.
 
vc1234 said:
Thanks for sharing, very interesting.
 
Are you communicating with the cameras over the wire or WiFi ? 
 
With my cameras, I have a main stream (1920x1080) and one sub-stream (640x480, I think).  The main streams go to an Xprotect Milestone box, and then you can view live/recording by connecting to the Milestone server or directly to the cameras.  There seems to be no problem using the same main stream both for recording to the Xprotect box and viewing using a web browser connected to the camera.
 
Yet, I cannot figure out a simple way to display permanently a hi-res 4x4 image via an HDMI input on my TV.
 
I thought about running an Xprotect app or maybe just a browser on an Intel Windows stick connected to the TV HDMI port, but I am not sure it's a good idea since each main stream uses about 2-3Mbit/s, and I'd prefer to use WiFi rather than a pull an rj45 cable for something which is mere a convenience -- I can easily see the same 4x4 on my iPad.  Also, I am not sure if a 640x480 4x4 on a big screen TV would make any sense in comparison to the full resolution display on the iPad.
The limiting factors are going to be your network and camera (how many concurrent streams they can support and how much bandwidth you can support)
 
Most commonly you're going to have 2 streams going to your recording device, the compressed H264 (most commonplace these days, but could be MP4V, etc) and generally a MJPEG low res, low FPS stream that would be used for motion based detection or analytics....that's how everyone is doing it these days. You're not grabbing an additional stream from the camera, you are grabbing the stream from the VMS in your case.
 
The most simple way to get the video to the monitor is a small client which is outside of any VMS, and grabbing a different stream from the camera than what is going to be used on the VMS side, typically ONVIF is the easiest to do this with.
 
All of my cameras are PoE hardwired.
The RPi is on a PoE hardline connection too.
My entire LAN is gigabit, but the PoE devices are limited to megabit.
 
DELInstallations said:
The most simple way to get the video to the monitor is a small client which is outside of any VMS, and grabbing a different stream from the camera than what is going to be used on the VMS side, typically ONVIF is the easiest to do this with.
Yes, that's what I thought too.  Just cannot find something small to play the stream with.  I heard about the Inter Windows stick that plugs into the  HDMI port, but do not know  if it's any good. Comments on Amazon are not encouraging. Due to esthetics, even an RPI would probably look out of place.  The TV is mounted on a brick wall so it's not easy to add any wires beyond what's already there.
 
Thank you Desert_AIP for providing the camera stuff for the RPi.
 
I have a few of the RPi's and have not really attached them to an video stuff. 
 
Tried RPi2 KODI a while ago and it was slower than my currently utilized Aopen Digital engines so left it alone. 
 
I do stream CCTV to Kodi and it works with favorites.
 
So above you are doing a 4 X 4 camera stream (640X480) to your LCD TV (1900X1280?)
 
Desert_AIP said:
You could use one of those Android boxes and an IPCamera app.
There's a mobile app for both Android and iPhone from Milestone which works OK.  Would the Android phone/tablet app run on an Android HDMI stick just as well ?  E.g. on this one:
 
http://www.htpcbeginner.com/cx-919-android-stick/
 
I do not have much experience with Android OS, so I am not sure if sticks use the same OS as ordinary phones.
 
vc1234 said:
Yes, that's what I thought too.  Just cannot find something small to play the stream with.  I heard about the Inter Windows stick that plugs into the  HDMI port, but do not know  if it's any good. Comments on Amazon are not encouraging. Due to esthetics, even an RPI would probably look out of place.  The TV is mounted on a brick wall so it's not easy to add any wires beyond what's already there.
Do you have network and/or POE there?
 
I've installed a ton of Aimetis thin clients and they work really well.
 
DELInstallations said:
Do you have network and/or POE there?
 
I've installed a ton of Aimetis thin clients and they work really well.
Yes, it is a possibility -- the box can be hidden behind the TV, but I am still attracted to the idea of plugging in an Android stick, also behind the TV, into an HDMI port. The stick can also be used for other purposes.  I guess I'll get an Amazon Fire TV stick and try to install the Milestone mobile client and see how good it'll look on the screen.
 
The WeMo emulation setup is pretty straightforward, just a few commands.
Let each one run until completion before moving on.
Some take several minutes.
 
Code:
sudo apt-get install python-pip ; sudo pip install requests
 
sudo wget "https://github.com/toddmedema/echo/archive/master.zip"
 
sudo unzip master.zip -d echo
 
 
Then navigate to the echo-master directory and start the python script.
 
Code:
cd echo/echo-master
 
python example-minimal.py
 
 
After you start the script you have to tell Alexa to discover your devices.
 
Say
 
Code:
 
"Alexa, discover my devices."
 
She will be busy for about 30 seconds.  
When she's done she should report she found one device (unless you have others).
 
Then you can test the emulation.
 
 
Say
 
Code:
 
"Alexa, turn my device on (or off)."
 
She should respond "OK" after she gets the proper response back from the RPi, and on the RPi screen you'll see several lines describing that "device" was turned on or off.
 
Take a look at the second link for adding and controlling a GPIO relay to the WeMo emulation.
I used that and modified it to send the CEC commands.
Also note, you can add multiple WeMo devices to a single RPi with one IP address.  Each device simply needs an individual port number.  The notes in the WeMo link above explains this a lot.
I found I can give a device multiple names, each with a different port number, then group them int he action script so a command to any of them has the same effect.
 
So I may use the term "Flood Lights", "Security Lights" and "Exterior Floods" all to describe my perimeter lights.
If I say "Alexa, turn on Flood Lights"  or "Alexa, turn on Exterior Floods", etc. she sends the on command to the appropriate device.  This saves programming lines in the Python script, and does not tie you to a specific name for a unit.
(I'm still working on sending out UPB commands BTW, I cant get the serial commands to be sent to my PIM).
 
Also, the Echo is fairly smart at parsing commands.  
So "Alexa, turn on Security Lights", and "Alexa, Security Lights on." give similar results.
 
To add multiple devices give each a unique name and port number in the TRIGGERS line.
i.e.
 
 TRIGGERS = {"Garage": 52000,"Security Lights": 52001,"Security": 52002,"Bath": 52003}
 
I solved this issue simply and cheaply as well. Just use a TV Box ( I use a Minix Box). Load the IP Cam Pro app on it and you have nice HD cam viewing, control, sound, playback, recording,
 
Plus the assed bonus of Kodi bringing you NO Cost worldwide TV and Movie viewing.
 
Problem solved >$100
 
Preference here is to just create scripted CCTV streams and make them favorites on KODI. (Ubuntu preferred over Android - that is me).
 
IPTV works great for me.  Enjoy watching old television here live news from around the world. (And generally do not like to watch regular TV).
 
TV.jpg
 
Back
Top