You are here

Fun With Cameras!

5 posts / 0 new
Last post
w6bi's picture
Fun With Cameras!

Fun With Cameras! (this is a long post - sorry!)


Part One - grabbing screenshots and displaying them.

The streaming protocol RTSP that most modern IP cameras use can be a pain in the butt to configure and view. If you've successfully installed one your local ham network, congratulations!

But now what? RTSP works well, but the average ham operator new to our network won't be able to view it without some advance configuration, and honestly most video streams are downright boring (until they aren't..)

The best way to allow wide viewing is to just grab a screenshot of the camera(s) periodically and post them on a web site. We post ours both to a hamnet website, and also to an Internet website (

There are probably at least several ways to do a screengrab, but we use a program called ffmpeg. It's available for both Windows and Linux. We run it in a script on a Raspberry Pi running Raspbian Buster.

The command to fetch a screenshot under Linux would be similar to this (this is for a Sunba camera - YMMV):

ffmpeg -f lavfi -i anullsrc -rtsp_transport tcp -i rtsp://yourhostname.local.mesh:554/user=view_password=view_channel=0_str... -ss 00:00:01.50 -vframes 1 /tmp/webcam2/siminorthcam1.jpg -nostats -hide_banner -v 0

This grabs a frame from the camera, using UserID and password of 'view' and stores it in /tmp/webcam2 (in this case).

It's not necessary but because there's no guarantee that all of your screengrabs will be the same resolution, as part of that same script we resize them to 1024 pixels of horizontal resolution. (Under Linux the command is 'convert' which is part of the ImageMagick package). It also applies a label to the screenshot [optional]:

convert /tmp/webcam2/siminorthcam1.jpg -background Khaki label:"Simi North PTZ Cam $DATE_WITH_TIME" -gravity Center -append -resize 1024 /tmp/webcam2/siminorthcam1.jpg

After we've run that script against all the cameras and gathered up all the images in /tmp/webcam2, we ship them up to a cloud server:

scp /tmp/webcam2/*.jpg

Then for good measure, we also ship them up to a server on our mesh network:

scp /tmp/webcam2/*.jpg pi@k6pvr-svr.local.mesh:/var/www/html/cameras/

Once they're there, you'll have to display them with some simple HTML commands.

Part Two - when the stuff hits the fan...

Viewing camera video in real time is vital when you've got an incident going (like in our case, most often a brushfire approaching).

Having an IP camera streaming video on a ham network is only part of the solution; you need it to be widely available. In Part One we showed how to disseminate screenshots. But when you absolutely need to make the live video available to the widest audience, the best place to put it is on YouTube.

The article I used to implement that was this one:…/streaming-rtsp-to-youtube…

It works for both Windows and Linux.

The command we use to start a stream (again, under Linux) is similar to this:

ffmpeg -f lavfi -i anullsrc -rtsp_transport tcp -i rtsp://siminorthcam1.local.mesh:554/user=view_password=view_channel=0_st... -tune zerolatency -vcodec libx264 -t 12:00:00 -pix_fmt + -c:v copy -c:a aac -strict experimental -f flv rtmp://<your YouTube StreamKey goes here>

You can then disseminate the YouTube URL to the public for wider viewing. Since the video stream is stored by YouTube, it can be viewed again after the fact, which our local county fire department did. (It turns out that the video of the night time fire was the first video anyone recorded, and reportedly they found it useful).

I've attached a couple of screenshots from memorable recent brushfires. Your disasters may vary...

AA7AU's picture
Thanks for posting this.

Thanks for posting this.
Well done. Been waiting to attempt this exact thing and just been putting it off. I really appreciate cookbook-type approaches to start from. Would love to see a complete rPi script if you could post it intact (with masking as necessary). I assume you're using a cron job to run it. Would also be interesting to see a more complex project where a rotating historical set of images were saved in a separate folder for time-lapse or history or whatever.

This part of your ffmpeg command "view_channel=0_str... -ss" seems like strange syntax with the "...". Was that a posting artifact?

- Don - AA7AU


w6bi's picture
Copy & paste..

Good catch, Don - it was some replacement error or something along the way.  Here's the correct command:

ffmpeg -f lavfi -i anullsrc -rtsp_transport tcp -i rtsp://siminorthcam1.local.mesh:554/user=view_password=view_channel=0_st... -ss 00:00:01.50 -vframes 1 /tmp/webcam2/siminorthcam1.jpg -nostats -hide_banner -v 0

Orv W6BI

AA7AU's picture
Looks like it still has the "

Looks like it still has the "..." editing artifact? Perhaps try posting with inserted artificial line-breaks to shorten command string, perhaps at one of the "_" delimiters. My guess is that the CMS has some sort of internal line/string length rules .We are defaulting to actually posting in "Rich Text"/HTML [grumble], perhaps check "switch to text editor" option.

Thanks again,
- Don - AA7AU

w6bi's picture
Plan C...

I've tried a couple of times, Don, and can't get past the substitution, even by using a text editor.Nor can I upload the bash script.  So here's a screenshot of part of the script :-/

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer