Page 1 of 2
RTSP and RPi Bookworm
Posted: Wed 17 Apr 2024 3:43 pm
by Nottub
Sadly it seems that VLC on the RPi does not support RTSP, when using Bookworm os.
My old RPi (Buster) uses the RTSP stream in VLC to create my snapshots of the current weather. That still works ok (but very processor intensive).
With my new RPi (Bookworm) I’ll have to work something out to get my Hikvision camera images onto my IONOS host.
The inbuilt snapshot facility of the Hikvision timestamps every image, so preventing linking to my web page.
Just a heads up if anyone is in the same boat.
V4 running well on the new RPi though.
Martyn
Re: RTSP and RPi Bookworm
Posted: Wed 17 Apr 2024 4:25 pm
by Nossie
I found this on an unrelated forum
not including RTSP was a decision for Debian only - so if you remove VLC that's included in bookworm - you can install it via snap and it should work??
There was a Debian policy decision that will cause Debian VLC build to not stream rtsp, you have to use vlc as a flat-pack or snap to get around that if you plan on using VLC to test your cameras.
Re: RTSP and RPi Bookworm
Posted: Wed 17 Apr 2024 7:54 pm
by ConligWX
Use something like ffmpeg's "convert" That's what I do. Grabs a snapshot adds layers and text etc then posts to my website.
I can post the script if needed.
Re: RTSP and RPi Bookworm
Posted: Wed 17 Apr 2024 8:02 pm
by Nottub
Nossie wrote: ↑Wed 17 Apr 2024 4:25 pm
I found this on an unrelated forum
not including RTSP was a decision for Debian only - so if you remove VLC that's included in bookworm - you can install it via snap and it should work??
There was a Debian policy decision that will cause Debian VLC build to not stream rtsp, you have to use vlc as a flat-pack or snap to get around that if you plan on using VLC to test your cameras.
Thanks Ian, looks like a good (easy) option.
Martyn
Re: RTSP and RPi Bookworm
Posted: Wed 17 Apr 2024 8:04 pm
by Nottub
ConligWX wrote: ↑Wed 17 Apr 2024 7:54 pm
Use something like ffmpeg's "convert" That's what I do. Grabs a snapshot adds layers and text etc then posts to my website.
I can post the script if needed.
Now that sounds interesting. I’m not very technical on coding matters, but would welcome an alternative to consider.
Thanks for the offer.
Martyn
Re: RTSP and RPi Bookworm
Posted: Wed 17 Apr 2024 9:23 pm
by ConligWX
so I use ffmpeg to grab the screen capture of an rtsp feed and save it to a jpg image.
I process a camdataT.txt with cumulusmx and save to camdata.txt (used to show values on the final image)
Code: Select all
Temp: <#temp>°C • Pressure: <#press> hPa • Hum: <#hum>% • Wind: <#wspeed> mph <#currentwdir> • Rain: <#rfall>mm • UV Index: <#UV> • SolarRad: <#SolarRad> W/m² • CloudBase: <#cloudbase>
I then use imagemagick's "convert" to add overlays and text to top and bottom of image and save it to another jpg that is used on my website.
this script is run every minute and updated text applied too to final image. you dont have to run every minute but I do. thats just called using a cronjob.
Code: Select all
*/1 * * * * /share/scripts/webcam.sh
webcam.sh file below.
all files, paths, IPs etc are fictitious
Code: Select all
#!/bin/sh
#
#set variable yday to be like 20100208
#
#tday=$(date -d today +%Y%m%d%H%M%S);
#stamp=$(date '+DATE: %d/%m/%y%nTIME:%H:%M:%S');
tday=$(date +%Y%m%d%H%M%S);
#stamp=$(date +%Y%m%d);
# get weather image
/opt/ffmpeg/ffmpeg -rtsp_transport tcp -i rtsps://192.168.1.22:5678/hYHihPWuoJzS5W0A?enableSrtp -vf scale=2688:1512 -frames 1 /share/weather/sky1.jpg -y;
# next 2 lines add weather info
testdata="$(/bin/cat /share/wx/camdata.txt)";
testdata1=`date +"%A %d-%b-%Y %R %Z"`;
# use Convert to add WX values and date etc to the image
/share/convert -fill RoyalBlue4 -draw "fill-opacity 0.4 rectangle 0 0 2688 30" \
-fill red -draw "fill-opacity 0.6 rectangle 0 31 2688 33" \
-fill RoyalBlue4 -draw "fill-opacity 0.7 rectangle 0 1482 2688 1512" \
-fill red -draw "fill-opacity 0.6 rectangle 0 1479 2688 1481" \
-fill white -pointsize 22 -font /share/ZFS21_DATA/db_backup/script/arialbold.ttf -draw "text 10,20 'Conlig Weather Station: $testdata1 • www.conligwx.org'" \
-fill yellow -pointsize 22 -draw "text 10,1507 '$testdata'" /share/wx/sky1.jpg /share/wx/skywebcam.jpg;
# convert image.jpg to 150kb for WUnderground
/share/convert /share/wx/skywebcam.jpg -define jpeg:extent=150kb /share/wx/image.jpg;
image is available 24/7 but its night time here so image is not worth showing at present. I'll post an image tomorrow of the final image.
you can also use ffmpeg to create a timelapse video is your want to with another script I have.
Re: RTSP and RPi Bookworm
Posted: Thu 18 Apr 2024 12:45 pm
by Nottub
ConligWX wrote: ↑Wed 17 Apr 2024 9:23 pm
so I use ffmpeg to grab the screen capture of an rtsp feed and save it to a jpg image.
I process a camdataT.txt with cumulusmx and save to camdata.txt (used to show values on the final image)
Code: Select all
Temp: <#temp>°C • Pressure: <#press> hPa • Hum: <#hum>% • Wind: <#wspeed> mph <#currentwdir> • Rain: <#rfall>mm • UV Index: <#UV> • SolarRad: <#SolarRad> W/m² • CloudBase: <#cloudbase>
I then use imagemagick's "convert" to add overlays and text to top and bottom of image and save it to another jpg that is used on my website.
this script is run every minute and updated text applied too to final image. you dont have to run every minute but I do. thats just called using a cronjob.
Code: Select all
*/1 * * * * /share/scripts/webcam.sh
webcam.sh file below.
all files, paths, IPs etc are fictitious
Code: Select all
#!/bin/sh
#
#set variable yday to be like 20100208
#
#tday=$(date -d today +%Y%m%d%H%M%S);
#stamp=$(date '+DATE: %d/%m/%y%nTIME:%H:%M:%S');
tday=$(date +%Y%m%d%H%M%S);
#stamp=$(date +%Y%m%d);
# get weather image
/opt/ffmpeg/ffmpeg -rtsp_transport tcp -i rtsps://192.168.1.22:5678/hYHihPWuoJzS5W0A?enableSrtp -vf scale=2688:1512 -frames 1 /share/weather/sky1.jpg -y;
# next 2 lines add weather info
testdata="$(/bin/cat /share/wx/camdata.txt)";
testdata1=`date +"%A %d-%b-%Y %R %Z"`;
# use Convert to add WX values and date etc to the image
/share/convert -fill RoyalBlue4 -draw "fill-opacity 0.4 rectangle 0 0 2688 30" \
-fill red -draw "fill-opacity 0.6 rectangle 0 31 2688 33" \
-fill RoyalBlue4 -draw "fill-opacity 0.7 rectangle 0 1482 2688 1512" \
-fill red -draw "fill-opacity 0.6 rectangle 0 1479 2688 1481" \
-fill white -pointsize 22 -font /share/ZFS21_DATA/db_backup/script/arialbold.ttf -draw "text 10,20 'Conlig Weather Station: $testdata1 • www.conligwx.org'" \
-fill yellow -pointsize 22 -draw "text 10,1507 '$testdata'" /share/wx/sky1.jpg /share/wx/skywebcam.jpg;
# convert image.jpg to 150kb for WUnderground
/share/convert /share/wx/skywebcam.jpg -define jpeg:extent=150kb /share/wx/image.jpg;
image is available 24/7 but its night time here so image is not worth showing at present. I'll post an image tomorrow of the final image.
you can also use ffmpeg to create a timelapse video is your want to with another script I have.
Thanks for this. When I get time over the next couple of days I’ll see if I can get head round the code, and where to put it on the RPi.
Many thanks
Martyn
Re: RTSP and RPi Bookworm
Posted: Thu 18 Apr 2024 1:52 pm
by Nottub
Presume I need to download ffmpeg to trial the code ?
Starting to amend the code for my setup. I assume this looks right so far?:
This to take the snapshot from my webcam (
rtsp://admin:***************.***.*.**/streaming/channels/101) and send the image (still called sky1.jpg) to my desktop.
Code: Select all
/opt/ffmpeg/ffmpeg -rtsp_transport tcp -i rtsp://admin:***************.***.*.**/streaming/channels/101 -vf scale=2688:1512 -frames 1 C:\Users\Desktop\sky1.jpg -y;
Thanks
Martyn
Re: RTSP and RPi Bookworm
Posted: Thu 18 Apr 2024 3:27 pm
by ConligWX
yes you'll need to install ffmpeg unless it is already installed.
as to the path, yes that looks ok, though dependant on where ffmpeg is installed/symlinked.
Re: RTSP and RPi Bookworm
Posted: Thu 18 Apr 2024 6:01 pm
by Nottub
ConligWX wrote: ↑Thu 18 Apr 2024 3:27 pm
yes you'll need to install ffmpeg unless it is already installed.
as to the path, yes that looks ok, though dependant on where ffmpeg is installed/symlinked.
It appears that ‘ffmpeg’ is installed in RPi ‘Bookworm’.
However the code suggests that there should be a directory ‘ffmpeg’, within which there should be a file ‘ffmpeg’ (I presume that’s what’s inferred). Sadly that’s not the case. I have ‘/usr/bin/ffmpeg’ (file), ‘/usr/share/ffmpeg’ (directory but with no simple ‘ffmpeg’ file inside it), and ‘usr/share/man/man1/ffmpeg.1.gz’.
So when I try ‘/usr/bin/ffmpeg/ffmpeg (with the rest of the script for my webcam I get ‘Not a directory’. Understandable as there is no file in that location. Tried various alternatives but to no avail.
Will try again soon.
Martyn
Re: RTSP and RPi Bookworm
Posted: Thu 18 Apr 2024 6:14 pm
by ConligWX
try using the find command.
if ffmpeg is a file here (/usr/bin/ffmpeg)
then use that as the command line
Re: RTSP and RPi Bookworm
Posted: Thu 18 Apr 2024 6:29 pm
by ConligWX
here's my end result.
Screenshot 2024-04-18 192820.png
Re: RTSP and RPi Bookworm
Posted: Thu 18 Apr 2024 7:28 pm
by Nottub
Running the command as sudo:
Code: Select all
pi2@blackberrypi:~ $ sudo find / -name ffmpeg
/usr/share/doc/ffmpeg
/usr/share/ffmpeg
/usr/share/lintian/overrides/ffmpeg
/usr/bin/ffmpeg
find: ‘/home/pi2/thinclient_drives’: Permission denied
find: ‘/run/user/1000/gvfs’: Permission denied
find: ‘/run/user/1000/doc’: Permission denied
pi2@blackberrypi:~ $
Re: RTSP and RPi Bookworm
Posted: Thu 18 Apr 2024 7:29 pm
by Nottub
ConligWX wrote: ↑Thu 18 Apr 2024 6:29 pm
here's my end result.
Screenshot 2024-04-18 192820.png
Hmm nice, just what I'd like to do.
Thanks for your time
Martyn
Re: RTSP and RPi Bookworm
Posted: Thu 18 Apr 2024 8:33 pm
by ConligWX
Nottub wrote: ↑Thu 18 Apr 2024 7:28 pm
Running the command as sudo:
Code: Select all
pi2@blackberrypi:~ $ sudo find / -name ffmpeg
/usr/share/doc/ffmpeg
/usr/share/ffmpeg
/usr/share/lintian/overrides/ffmpeg
/usr/bin/ffmpeg
find: ‘/home/pi2/thinclient_drives’: Permission denied
find: ‘/run/user/1000/gvfs’: Permission denied
find: ‘/run/user/1000/doc’: Permission denied
pi2@blackberrypi:~ $
so if you type in the following command what do you get?
if you get version information then that's probably the one we can use. then next is to check if imagemagick's "convert" is available to use on your OS.
if you find a result type in the path to it and with convert -version to see what it says, heres an example on mine:
Code: Select all
[~] # /usr/local/sbin/convert -version
Version: ImageMagick 6.9.4-8 Q16 x86_64 2024-02-20 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC
Delegates (built-in): bzlib jng jpeg png tiff