convert ZM/zms output stream to RTSP (for Amazon Alexa)

Add any particular hints or tricks you have found to help with your ZoneMinder experience.
Post Reply
carteriii
Posts: 65
Joined: Sun Oct 28, 2007 3:13 pm

convert ZM/zms output stream to RTSP (for Amazon Alexa)

Post by carteriii »

I would like to view my ZoneMinder cameras through an Amazon Echo Spot (or Echo Show). This requires providing an H.264 stream with RTSP or RTP protocol. You can find details of Amazon's requirements here: https://developer.amazon.com/docs/smart ... kills.html

There is a fantastic github repo created by another Zoneminder user (https://github.com/goruck/alexa-ip-cam), but that person is using only Axis cameras that directly support RTSP, so that github project isn't really taking a zm output video stream which I believe is simply mjpeg.

On the surface it would seem feasible that some use of ffserver/ffmpeg could take a URL to zm's mjpeg stream (e.g. /cgi-bin/nph-zms?mode=jpeg&monitor=1&user=xxx&pass=xxx) and convert it to RTSP for use by as an Amazon Alexa Smart Home Camera. I do see zms has an "mpeg" mode, but I assume jpeg mode would be better so there aren't two separate conversions happening.

Has anyone done this before, or if you're an ffserver/ffmepg expert, would you please you offer a sample configuration for this? I may be able to fumble my way through some ffserver/ffmpeg options, but I'd appreciate any configuration tips if someone has done this before, particularly to ensure the conversion is only happening when someone is access the RTSP stream.
carteriii
Posts: 65
Joined: Sun Oct 28, 2007 3:13 pm

Re: convert ZM/zms output stream to RTSP (for Amazon Alexa)

Post by carteriii »

Just a quick update that I've been trying (mostly failing) to get ffserver & ffmpeg to create an RTSP stream of ZM's mjpeg stream. I've been trying to view this with VLC, which only gives me a blank/black screen. Until I can view the feed with VLC, there's no point in doing any of the Alexa-specific work.

I'll keep playing with this, but if someone else here is good with ffserver/ffmpeg, please feel free to suggest an ffserver.conf file and/or ffmpeg command line that works :D

In case someone else also wants to try (hint! hint! please!), this is my starting ffmpeg command in the "Feed". In case it isn't obvious, I've sanitized everything in the ZM URL here so please don't think that part is the problem:

Code: Select all

Launch ffmpeg -i https://mydomain.com/zm/cgi-bin/nph-zms?mode=jpeg&scale=100&maxfps=5&monitor=2&user=user&pass=pass&connkey=xxxxxx&rand=yyyyy
... and these are the two streams I've tried (one h264, and one straight mjpeg), both reading the feed with the ffmpeg command above and starting from the sample in the default conf file:

Code: Select all

<Stream live.h264>
Format rtp
Feed feed1.ffm
VideoCodec libx264
VideoFrameRate 24
VideoBitRate 100
VideoSize 640x480
AVPresetVideo default
AVPresetVideo baseline
AVOptionVideo flags +global_header

# Suppress audio (or you'll get an error)
NoAudio
</Stream>

<Stream live.mjpeg>
Format rtp
Feed feed1.ffm
VideoCodec mjpeg
VideoFrameRate 5
VideoBitRate 100
VideoSize 640x480
AVPresetVideo default
AVPresetVideo baseline
AVOptionVideo flags +global_header

# Suppress audio (or you'll get an error)
NoAudio
</Stream>
mrd
Posts: 269
Joined: Wed Apr 26, 2006 12:39 am
Location: Boston USA

Re: convert ZM/zms output stream to RTSP (for Amazon Alexa)

Post by mrd »

This may be a very unhelpful reply and I may have missed the entire point of what you are trying to do, but I view my local cameras through their direct streams with Amazon fire tablets using an app called TinyCam Pro. It works very well for me and I don't put any load on the ZM server that way.
MRD
carteriii
Posts: 65
Joined: Sun Oct 28, 2007 3:13 pm

Re: convert ZM/zms output stream to RTSP (for Amazon Alexa)

Post by carteriii »

mrd wrote: Mon Aug 20, 2018 12:29 pm This may be a very unhelpful reply and I may have missed the entire point of what you are trying to do
As I said in the first sentence of my first post: "I would like to view my ZoneMinder cameras through an Amazon Echo Spot (or Echo Show)." The part that may be missing from that statement is that this setup will allow me to use a voice command to display the stream on one of those devices.

For what it's worth, I do have the RTSP stream figured out but I simply haven't had time to get back to this and work through the details of the alexa-ip-cam project. I'll post more details once I've had time to work through the rest of what needs to be done.
vtdstein95
Posts: 31
Joined: Sun Jan 24, 2016 3:13 pm

Re: convert ZM/zms output stream to RTSP (for Amazon Alexa)

Post by vtdstein95 »

carteriii any update on this? I too would like to view my zoneminder "front door" camera on the Echo Show. I like to play around and may have some time next week, so anything you can share to get me started would be much appreciated.
carteriii
Posts: 65
Joined: Sun Oct 28, 2007 3:13 pm

Re: convert ZM/zms output stream to RTSP (for Amazon Alexa)

Post by carteriii »

I changed focus slightly, trying instead to use Monocle (https://monoclecam.com/) which is a hosted service that converts an RTSP stream in order to display it on an Amazon Echo. I used ffserver to convert the mjpeg stream from ZoneMinder to an h.264 rtsp stream, but it's been horribly flaky. I haven't been able to figure out if it's the slow frame rate from ZoneMinder or if there are some additional settings that ffserver (via ffmpeg) could take to improve it. So far it hasn't been reliable enough for me to really use it.

I do have one camera which provides a native rtsp stream, and Monocle works well for that.

If any of you have ffserver/ffmpeg experience enough to work on the ffserver conversion of Zoneminder's mjpeg stream, please do. For what it's worth, I've been using VLC to try to view the rtsp stream, so I know the problem is with my conversion & doesn't have anything to do with Monocle . For example, I'll use VLC to open a network stream to my ffserver instance with a URL such as rtsp://192.168.1.6:8091/mudroomdoor264. It only displays the video 1 out of about every 10 tries, and even then, it's after a long delay.

ZoneMinder is configured to capture a default of 5 fps from each of my analog cameras, and my ffserver.conf file includes this for the stream:

Code: Select all

<Stream mudroomdoor264>
Feed mudroomdoor.ffm
Format rtp

VideoCodec libx264
AVPresetVideo baseline

VideoFrameRate 10
VideoBufferSize 2000
VideoBitRate 800
VideoQMin 1
VideoQMax 31
VideoSize 640x480
Noaudio
</Stream>
Post Reply