Summary
Send animated GIFs from Blue Iris to your phone.
Overview
Blue Iris gives you tons of different ways to work with your videos. I chose to animate JPEGs instead of video since I assume most people on Blue Iris use the proprietary *.bvr format and JPEGs are easier to convert. The JPEG method has the benefit of being less disruptive for most BI users. On the other hand, if you record in MP4 in BI, there are probably more efficient ways to create GIF files.
In my example below, GIF conversion is done on my BlueIris server since it has the most horsepower in my environment. I am using FFmpeg to do the processing since it works on Windows, the standalone binary is easy to use, lightweight, and can be run without a full-blown installation. The *.BAT files are written with FFmpeg in mind. If you want to do it on a linux environment, you can use imagemagick and the shell script would be cleaner.
This process follows several steps:
- Configure Blue Iris to save JPEGs from video triggers
- Convert them into animated GIFs. This process can be done with any number of methods.
- Send converted GIF to Pushover for mobile notifications.
- Bonus - link the notification to a live view of your camera feed.
Requirements
- openHAB switch item to trigger pushover alert
- Pushover binding
- Blueiris with JPEG snapshots turned on
- CIFS share from Blue Iris machine accessible and mounted to openHAB machine.
- FFmpeg binary https://ffmpeg.org/ &
- wget binary (or alternatively you can have BI post a REST/mqtt request) http://gnuwin32.sourceforge.net/packages/wget.htm
Configuration for BI server to capture JPEGs :
- Create a subfolder for Blue Iris to store JPEG alert images. For example: D:\BlueIris\New\frontdoor
- Inside the folder above, create another subfolder to temporarily stage JPEGs for conversion
In my case, I’m using D:\BlueIris\New\frontdoor\gif_processing - On the camera you want to capture, go to camera properties - record.
- Check JPEG snapshot each
- Change snapshot time to match whatever framerate you want for your GIF. I’m using .5 seconds.
- Check only when triggered
- Create capture path to match the location of the folder you created above (i.e. frontdoor)
You should now have a set of JPEGs automatically generated and stored in D:\BlueIris\New\frontdoor whenever blueiris triggers for your camera. Repeat process for other cameras, but remember to set your alert paths accordingly. I suggest keeping separate folders for easier processing.
Create BAT files on BI server for GIF generation and trigger openHAB
Download FFmpeg to the BI server and store ffmpeg.exe somewhere in your path or in the same folder as your bat files. For the purpose of this example, I’m going to assume everything in this section (ffmpeg.exe and bat files) is saved to D:\BlueIris\Alert\
DOS scripting is terrible, and I’m terrible at it, but here’s the best I could come up with quickly. I was not able to get the DOS-based loop to break properly, so you need all 3 bat files for now (I will go back and refactor this to just one script or maybe change to powershell in the future)
front_door_motion.bat
This will call either on or off actions based on BI alerts
@echo off
IF "%1"=="" (
call front_door_motion_on.bat
) else (
call front_door_motion_off.bat
)
front_door_motion_on.bat
When the camera detects motion, this script copies the latest 8 JPEGs from the snapshot folder above, creates the animated GIF in D:\BlueIris\Alert\out.gif, and alerts openHAB of the trigger via legacy call. I’m using ping as a wait command to give BI enough time to generate the image files. Adjust those variables for your own environment. This method has a drawback in that it takes about 10-15 seconds before it alerts OH.
Make sure you have a switch item setup in openHAB to accept the trigger call from wget. In my case, I’m using MotionSensorFrontDoorCameraTripped. Item file listed below.
@echo off
PING 127.0.0.1 -n 5
setlocal EnableDelayedExpansion
CALL :ProcessJPGS
:ProcessJPGS
set i=8
for /f %%a in ('dir /b/a-d/o-d/t:w D:\BlueIris\New\frontdoor\*.jpg') do (
copy "D:\BlueIris\New\frontdoor\%%a" "D:\BlueIris\New\frontdoor\gif_processing\"!i!".jpg"
set /a i-=1
if !i!==0 (
echo y|del D:\BlueIris\Alert\out.gif
echo y|ffmpeg.exe -f image2 -framerate 5 -i D:\BlueIris\New\frontdoor\gif_processing\%%d.jpg -vf scale=480x270 "D:\BlueIris\Alert\out.gif"
PING 127.0.0.1 -n 3
wget.exe "http://<OHserver>:<OHport>/classicui/CMD?MotionSensorFrontDoorCameraTripped=ON" -O nul
goto :eof
)
)
front_door_motion_off.bat
Reset OH item and clean up staging files
@echo off
wget.exe "http://<OHserver>:<OHport>/classicui/CMD?MotionSensorFrontDoorCameraTripped=OFF" -O nul
echo y|del "D:\BlueIris\New\frontdoor\gif_processing\*.jpg"
Configure BI to run the BAT files you just created
Under camera properties - alerts
- check Run a program or execute a script
- Configure as follows:
openHAB setup
Set up your OH server with a CIFS mount (or samba share if you want to go the other direction) to access D:\BlueIris\Alert\ on the blueiris machine. The rule below assumes this mount point is /mnt/blueirisalerts/.
To reduce false positives, the OH rule is set to only trigger if both the camera and PIR sensor detect motion at the same time. My production version expands this to compare times and only trigger if the camera trips first. This way it only records one-way traffic (people leaving the house don’t trigger an alert).
camera.items
Switch MotionSensorFrontDoorCameraTripped "Front Door Camera Motion"
Contact FrontDoorMotionTripped "Front Door PIR sensor Tripped [MAP(en.map):%s]" {mios="unit:vera,device:28/service/SecuritySensor1/Tripped"}
frontdoorbell.rules
var String PushOverAPIKey = "xxxxxxxxxxxxxxxxxxxxxxxxxx"
var String PushOverUserKey = "xxxxxxxxxxxxxxxxxxxxxxxxxx"
rule "FrontDoorActivity"
when
Item MotionSensorFrontDoorCameraTripped changed from OFF to ON
or Item FrontDoorMotionTripped changed from CLOSED to OPEN
then
if (FrontDoorMotionTripped.state.toString == "OPEN" && MotionSensorFrontDoorCameraTripped.state.toString == "ON") { //camera tripped first = arrival or both sensors tripped
sendPushoverMessage(pushoverBuilder("Someone's at the front door").withApiKey(PushOverAPIKey).withDevice(PushOverUserKey).withTitle("Front Door").withAttachment("/mnt/blueirisalerts/out.gif").withUrl("https://yyyyy.com").withUrlTitle("Live"))
}
end