Difference between revisions of "External Live Stream"

From ZoneMinder Wiki
Jump to navigationJump to search
(29 intermediate revisions by the same user not shown)
Line 17: Line 17:
</pre>
</pre>


==Setup==
In 1.32 and 1.34, you may have to adjust the following setting for auth_relay if authentication is used. Note that this conflicts with [[ZMNinja]], which requires auth_relay to be set to hashed, I believe.
<pre>
Post by rockedge» Fri Jun 30, 2017 8:09 pm
in a WordPress page or post I use something like this: Remember that
with certain authorizations set, the URL would be slightly different.
this URL works when :
Options->System->OPT_USE_AUTH = ON
Options->System->AUTH_TYPE = Builtin
Options->System->AUTH_RELAY = NONE
<h2><img class="aligncenter"
src="http://your_zm_server/cgi-bin/nph-zms?mode=jpeg&scale=100&maxfps=5&buffer=1000&monitor=1&user=admin" alt="stream down" width="420" height="340" /></h2>
</pre>
ref:https://forums.zoneminder.com/viewtopic.php?f=36&t=26292
<small>Note that this URL omits password. But it is given in the top example.</small>
==Tips==
===Quickly Change pixel settings for page===
===Quickly Change pixel settings for page===
It should be possible to get CSS on this page, so the videos auto fill the page appropriately (haven't gotten around to it) but it's also possible to use sed here to adjust the pixels as needed
It should be possible to use CSS and have the videos fill the page appropriately (I haven't gotten around to it. Contributions welcome.) but it's also possible to use sed here to adjust the pixels as needed:
<pre>
<pre>
sed s/oldpx/newpx/g -i cameras.html
sed -e 's/oldpx/newpx/g' -i cameras.html
</pre>
</pre>


===Refresh Page Periodically===
===Refresh Page Periodically===
You can do this with xdotool (see [[Dedicated_SBC_Camera_Monitor#Refresh_Screen_Periodically]] )or possibly with html:[https://forums.zoneminder.com/viewtopic.php?f=39&t=28897]
Refreshing the page is a good idea, so that any streams don't drop out for any reason. You can do this with xdotool (see [[Dedicated_SBC_Camera_Monitor#Refresh_Screen_Periodically]] )or possibly with html:[https://forums.zoneminder.com/viewtopic.php?f=39&t=28897]


<pre>
<pre>
<meta http-equiv="refresh" content="300">
<meta http-equiv="refresh" content="300"><!-- EDIT: This may not work. Perhaps try js -->
</pre>
</pre>
===Scale may be required for large numbers of cameras or SBCs===
See that scale=100 option in the URL? That is used to downscale or downsample the video stream resolution. But, since you set the height and width, it won't make the video smaller. If you have a 2K stream, but you are viewing it at 640x480, you don't need 100% scaling. Lower the number to keep the bandwidth / memory usage down.
Where this is required, is when you have a lot of monitors, say 20+ cameras. Or you have an SBC that can't handle full res streams. In these scenarios, if you don't scale, you will either see the CPU max out on the watching computer, or you will see video feeds drop in and out periodically. For more details, see how ZM handles the URL for montage.


===Single Snapshot URL===
===Single Snapshot URL===
The URL for a single snapshot is:
The URL for a single snapshot is:
  http://serverip/zm/cgi-bin/nph-zms?mode=single&monitor=2&scale=100&maxfps=5&buffer=1000&user=somename&pass=somepass
  http://serverip/zm/cgi-bin/nph-zms?mode=single&monitor=2&scale=100&maxfps=5&buffer=1000&user=somename&pass=somepass
Adjust Monitor # as needed.
Adjust Monitor # as needed. (Also see note in setup section above).
 
===Alternative Single Snapshop JPG via ZMU===
zmu is a binary, along with zma, and zmc that can do various functions. One of them is creating a jpeg.
 
<pre>
/usr/bin# zmu -h
zmu <-d device_path> [-v] [function] [-U<username> -P<password>]
zmu <-m monitor_id> [-v] [function] [-U<username> -P<password>]
General options:
  -h, --help          : This screen
  -v, --verbose          : Produce more verbose output
...
  -i, --image [image_index]    : Write captured image to disk as <monitor_name>.jpg, last image captured
                  or specified ring buffer index if given.
</pre>
 
===ffplay===
It is possible to use ffplay to directly stream a single camera feed (bypassing ZM) to the desktop. Although refreshing may be more involved.
ffplay -i rtsp://user:Password@ipaddress:554/video


==See Also==
==See Also==


* [[OpenVPN]]
* [[OpenVPN]]
[[Category:Dummies_Guide]]

Revision as of 14:12, 2 November 2021

Here is an html file you might use in a ZM client Desktop SBC Camera Monitor to view the streams from the ZM Server. You will need to adjust the resolution, number of cameras, and monitor id of the URL to your setup.

In my experience, Clients viewing the Streams (up to 3 clients, with 20+ cameras) do not slow down the ZM Server.

For more details, see Dummies_Guide#Watching_the_Cameras

<html><body bgcolor="black">
<img width="412px" height="268px" src="http://IPOFZMSERVER/zm/cgi-bin/nph-zms?mode=jpeg&monitor=1&scale=100"&user="watchinguser"&pass="somepassword" >
<img width="412px" height="268px" src="http://IPOFZMSERVER/zm/cgi-bin/nph-zms?mode=jpeg&monitor=2&scale=100"&user="watchinguser"&pass="somepassword" >
<img width="412px" height="268px" src="http://IPOFZMSERVER/zm/cgi-bin/nph-zms?mode=jpeg&monitor=3&scale=100"&user="watchinguser"&pass="somepassword" >
<img width="412px" height="268px" src="http://IPOFZMSERVER/zm/cgi-bin/nph-zms?mode=jpeg&monitor=4&scale=100"&user="watchinguser"&pass="somepassword" >
<img width="412px" height="268px" src="http://IPOFZMSERVER/zm/cgi-bin/nph-zms?mode=jpeg&monitor=5&scale=100"&user="watchinguser"&pass="somepassword" >
<img width="412px" height="268px" src="http://IPOFZMSERVER/zm/cgi-bin/nph-zms?mode=jpeg&monitor=6&scale=100"&user="watchinguser"&pass="somepassword" >
</body>
</html>

Setup

In 1.32 and 1.34, you may have to adjust the following setting for auth_relay if authentication is used. Note that this conflicts with ZMNinja, which requires auth_relay to be set to hashed, I believe.

Post by rockedge» Fri Jun 30, 2017 8:09 pm
in a WordPress page or post I use something like this: Remember that 
with certain authorizations set, the URL would be slightly different.
this URL works when :
Options->System->OPT_USE_AUTH = ON
Options->System->AUTH_TYPE = Builtin
Options->System->AUTH_RELAY = NONE


<h2><img class="aligncenter" 
src="http://your_zm_server/cgi-bin/nph-zms?mode=jpeg&scale=100&maxfps=5&buffer=1000&monitor=1&user=admin" alt="stream down" width="420" height="340" /></h2>

ref:https://forums.zoneminder.com/viewtopic.php?f=36&t=26292

Note that this URL omits password. But it is given in the top example.

Tips

Quickly Change pixel settings for page

It should be possible to use CSS and have the videos fill the page appropriately (I haven't gotten around to it. Contributions welcome.) but it's also possible to use sed here to adjust the pixels as needed:

sed -e 's/oldpx/newpx/g' -i cameras.html

Refresh Page Periodically

Refreshing the page is a good idea, so that any streams don't drop out for any reason. You can do this with xdotool (see Dedicated_SBC_Camera_Monitor#Refresh_Screen_Periodically )or possibly with html:[1]

<meta http-equiv="refresh" content="300"><!-- EDIT: This may not work. Perhaps try js -->

Scale may be required for large numbers of cameras or SBCs

See that scale=100 option in the URL? That is used to downscale or downsample the video stream resolution. But, since you set the height and width, it won't make the video smaller. If you have a 2K stream, but you are viewing it at 640x480, you don't need 100% scaling. Lower the number to keep the bandwidth / memory usage down.

Where this is required, is when you have a lot of monitors, say 20+ cameras. Or you have an SBC that can't handle full res streams. In these scenarios, if you don't scale, you will either see the CPU max out on the watching computer, or you will see video feeds drop in and out periodically. For more details, see how ZM handles the URL for montage.

Single Snapshot URL

The URL for a single snapshot is:

http://serverip/zm/cgi-bin/nph-zms?mode=single&monitor=2&scale=100&maxfps=5&buffer=1000&user=somename&pass=somepass

Adjust Monitor # as needed. (Also see note in setup section above).

Alternative Single Snapshop JPG via ZMU

zmu is a binary, along with zma, and zmc that can do various functions. One of them is creating a jpeg.

/usr/bin# zmu -h
zmu <-d device_path> [-v] [function] [-U<username> -P<password>]
zmu <-m monitor_id> [-v] [function] [-U<username> -P<password>]
General options:
  -h, --help           : This screen
  -v, --verbose          : Produce more verbose output
 ...
  -i, --image [image_index]    : Write captured image to disk as <monitor_name>.jpg, last image captured
                   or specified ring buffer index if given.

ffplay

It is possible to use ffplay to directly stream a single camera feed (bypassing ZM) to the desktop. Although refreshing may be more involved.

ffplay -i rtsp://user:Password@ipaddress:554/video

See Also