Wanting to embed just the video stream on other Site

Support and queries relating to all previous versions of ZoneMinder
Locked
Ricardol
Posts: 3
Joined: Fri Mar 21, 2008 8:40 pm

Wanting to embed just the video stream on other Site

Post by Ricardol »

Hello. I am running zoneminder 1.22 on kubuntu 7.10 and i have a question. I would like to take just the video stream from one monitor and embed it on another web site. i read in the forums that i could take the url from the jpeg image that shows in the monitor page from zoneminder console and use that. But when i load that url in a blank firegox or explorer page, i get just the first frame of the stream, and the frame wont refresh. Can somoene tell me what could be the problem?
Thanks
Ricardo
User avatar
zoneminder
Site Admin
Posts: 5215
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Post by zoneminder »

You might not need just the url, but also the enclosing embed or object tags.
Phil
Ricardol
Posts: 3
Joined: Fri Mar 21, 2008 8:40 pm

Post by Ricardol »

Could you explain that idea to me a little more?
Thanks
User avatar
zoneminder
Site Admin
Posts: 5215
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Post by zoneminder »

If you are just viewing an mjpeg stream then you just need something like

Code: Select all

<img src="http://<yourip>/cgi-bin/nph-zms?mode=jpeg&monitor=1&scale=100&maxfps=2&auth=beabc4e2e6aa50f15f910e844" alt="Front" border="0" width="352" height="288">
with the url inside an img tag, but if you were wanting to stream an mpeg feed then you would need this

Code: Select all

<embed type="video/x-ms-asf" 
src="http://<yourip>/cgi-bin/nph-zms?mode=mpeg&monitor=1&scale=100&bitrate=25000&maxfps=2&format=asf&auth=b569dd73a50f15f910e8446"
width="352"
height="288"
name="Front"
autostart="1"
autoplay="1"
showcontrols="0"
controller="0">
</embed>
and so on. Likewise the url you present to IE for mjpeg streaming might need to wrap the url in references to the cambozola applet.

So basically just having the url to the zms feed is not enough, it needs to be wrapped in appropriate html to display the content type for the relevant browser.
Phil
azir
Posts: 14
Joined: Tue Jan 22, 2008 7:30 am
Location: Surabaya, Indonesia

Post by azir »

I use this script for my similiar case.
place the script zm_img.php to the web root directory of zoneminder
(mine is /var/www/htdocs/zm)

please add opening an closing php tag yourself, i got problem with formatting here
seem like i need to familiarize myself with bbcode
:D

Code: Select all

/* 
** zm_img.php
*/
import_request_variables( "CGP" );
// Use new style autoglobals where possible
if ( version_compare( phpversion(), "4.1.0", "<") )
{
  	$_SESSION = &$HTTP_SESSION_VARS;
  	$_SERVER = &$HTTP_SERVER_VARS;
}
if ( $_SERVER['REMOTE_ADDR'] != 'xxx.xxx.xxx.xxx' ) {
    exit();
}

if ( !isset($PHP_SELF) )
{
	$PHP_SELF = $_SERVER['PHP_SELF'];
}

if ( isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on' )
{
	$protocol = 'https';
}
else
{
	$protocol = 'http';
}

if(!isset($bandwidth))
{
    $bandwidth  = "low";
}

define( "ZM_BASE_URL", $protocol.'://'.$_SERVER['HTTP_HOST'] );
ini_set( "session.name", "ZMSESSID" );
ini_set( "session.use_cookies", "0" );
ini_set( "session.use_trans_sid", "1" );
session_start();


require_once "zm_config.php";
require_once "zm_funcs.php";
userLogin('foo', 'bar');

if(isset($_GET['mid'])) {
    $mid = $_GET['mid'];
}
else {
    $mid = 1;
}

$scale = 100;
$streamarg = array( "mode=jpeg", 
                    "monitor=".$mid, 
                    "scale=".$scale, 
                    "maxfps=".ZM_WEB_VIDEO_MAXFPS );
$stream_src = getStreamSrc( $streamarg );
$stream_src = str_replace("&", "&", $stream_src);
header("Location: $stream_src&ZMSESSID=".session_id());
exit();
My zm running in built in authentication mode, I created user foo with password bar for the script above, fix with yours
If your zm is not running in authenticated mode, comment the userLogin(... line.
Here is an example page shows how to use it

Code: Select all

<html>
<head><title>ZM image</title></head>
<body>
<monitor>
<img src='http://yyy.yyy.yyy.yyy/zm/zm_img.php?mid=1" />
<br>
<monitor>
<img src='http://yyy.yyy.yyy.yyy/zm/zm_img.php?mid=2" />
</body>
</html>
note:
xxx.xxx.xxx.xxx : ip address of remote viewer page / hosting (the other Site)
yyy.yyy.yyy.yyy : ip address or FQDN of box where zm installed

Hope that helps
Ricardol
Posts: 3
Joined: Fri Mar 21, 2008 8:40 pm

Post by Ricardol »

Thank you very much for all your help. I will try this ideas and post results.
Ricardo
Locked