Code Snippet

Just another Code Snippet site

Random Post :




[VMs] Windows VMs

https://modern.ie/en-us/virtualization-tools

Capture RTSP image from Rpi and sent to Bloger (using Gmail account)

Mail config :

Unsecure app must be allowed on Gmail : https://myaccount.google.com/lesssecureapps

Install SSMTP and Mpack

sudo apt-get update
sudo apt-get install -y ssmtp mpack

edit: /etc/ssmtp/ssmtp.conf

root=rpi3abc@gmail.com
mailhub=smtp.gmail.com:465
FromLineOverride=YES
AuthUser=rpi3abc@gmail.com
AuthPass=testing123
UseTLS=YES

Send mail :

mpack -s subject picture.png mail.address@example.com

Capture Image from RTSP feed:

sudo apt-get update
sudo apt-get install -y ffmpeg
ffmpeg -y -i rtsp://admin:admin@192.168.10.113:554/live -vframes 1 do.jpg

Script

#!/bin/bash

## ------------------- ##
## Vars
## ------------------- ##
timestamp=`date +%Y%m%d-%H%M%S`
humanReadableDate=`date "+%d/%m/%Y %H:%M"`
recipient=aaa@blogger.com
liveStreamUrl="rtsp://192.168.100.233:554/user=admin_password=OmvItLOM_channel=1_stream=0.sdp?real_stream"


## ------------------- ##
## Capture live stream
## ------------------- ##
#ffmpeg -y -i $liveStreamUrl  -vframes 1 "/tmp/${timestamp}.jpg"
#ffmpeg -rtsp_transport tcp -y -i  $liveStreamUrl -f image2 -vframes 1  "/tmp/${timestamp}.jpg"
ffmpeg -rtsp_transport tcp -y -i  $liveStreamUrl  -vframes 1  "/tmp/${timestamp}.jpg"


## ------------------- ##
## Send Mail
## ------------------- ##
mpack -s "${humanReadableDate}" "/tmp/${timestamp}.jpg" $recipient


## ------------------- ##
## Remove Picture
## ------------------- ##
rm -Rf "/tmp/${timestamp}.jpg"

Cron

0 9,14 * * * /bin/bash /home/pi/sendImage.sh

Picture at 9:00 and 14:00 everyday

sudo service cron reload

, , , , , ,

Previous Posts Next posts