|
Nota Técnica: Video en vivo sobre un sitio de alta
demanda (Unix)
La información en este artículo se aplica a:
- AXIS 2100/2120/2400/2401/2420 desde la versión de firmware
2.12
Resumen
Este artículo muestra como incluir en una página web hospedada en
un servidor Unix video en vivo generado por una Cámara de Red Axis
usando un servidor ftp intermedio.
Más información
¡¡Así es como se implementó la demo de Goldie!!
Si un sitio tiene muchas conexiones simultaneas usted debe
"proteger" la Cámara de Red Axis de una sobrecarga de usuarios. Un
sitio de alta demanda en Internet puede sobrecargar la Cámara de Red
Axis ya que sólo pueden recibir sus imágenes en vivo un máximo de 10
usuarios simultáneos.
Puede prevenir esto haciendo un buffer de las imágenes en un
servidor web de alto desempeño. La Cámara de Red Axis tiene
integrada una función que le permite descargar imágenes
automáticamente al "servidor buffer". Abajo explicaremos como puede
llevar esto a cabo en un servidor web Unix.

Descripción general del sistema (Ver la imagen superior)
Configure la Cámara de Red Axis para enviar imágenes de manera
secuencial a un servidor FTP. Puede hacer esto utilizando el
asistente de configuración del producto. El servidor Web (en la
mayoría de los casos la misma computadora que el servidor FTP)
generará a partir de estas imágenes un flujo de imágenes para todos
los usuarios que accedan a la página web.
Configurando el servidor Web Unix intermedio
- Crear el directorio donde usted desea que resida la demo.
- Copiar el componente ActiveX Axis para despliegue de imágenes
(disponible
aquí) a su directorio demo y nómbrelo AxisCamControl.ocx.
- Crear el script CGI que generará el flujo de imágenes a partir
de las imágenes recibidas desde la cámara.
Usted debe ingresar los siguientes parámetros:
$DIR - El directorio donde son descargadas las imágenes por la
Cámara de Red Axis.
$fileName - El nombre de archivo con que son almacenadas las
imágenes.
$freq - La frecuencia de actualización.
- Crear una página web que contenga el código html del ejemplo.
Cambie la URL Base, archivo y archivo OCX.
Ejemplo
Script Perl:
#!/usr/bin/perl
#
#
require 'stat.pl';
#########################################################
# Path to where the image file is stored
$DIR = "/cam/root/";
#Filename the image is stored as
$fileName = "fish.jpg";
#Maximum of images/s sent
$freq = 3;
#Max number of images to send on a connection
$maxImages = 900;
#Max number of seconds until update is considered stopped
#(ie the camera is no longer updating the image)
$maxNoUpdate = 30;
#########################################################
$con_type = "jpeg";
# Unbuffer the output so it streams through faster and better.
$| = 1;
# No input record separator when reading from file via <>.
undef $/;
# Print HTTP headers...
# NOTE: If your web server returns "Error, faulty header"
# The Line below must be commented away since your web server
includes the
# HTTP/1.0 200 OK on its own.
print "HTTP/1.0 200 OK\n";
print "Content-type: multipart/x-mixed-replace; boundary=--myboundary\n\n";
print "--myboundary\n";
$rounds=0;
#max 400 images
while ($rounds < $maxImages)
{
$rounds = $rounds +1;
$basefile = $DIR . $fileName;
@fstat = stat($basefile);
# If the same image time stamp is on the image file for more
then
# X seconds then I presume that the image is no longer updated
and will
# End the connection
if ($fstat[$ST_MTIME] ne $oldimagetime)
{
$sameCount = 0;
$oldimagetime = $fstat[$ST_MTIME];
}
#We may send the same image multiple times but there is a strict
limit
if ($sameCount > ($maxNoUpdate * $freq))
{
die;
}
$sameCount = $sameCount +1;
$rounds=$rounds +1;
print "Content-type: image/$con_type\n\n";
# This is where we act
open(PIC,"$basefile");
print STDOUT <PIC>;
close(PIC);
print "\n\n--myboundary\n";
# Pause for 1/$freq seconds, if this time is more then a second
# we recomend you replace with sleep(NbrOfSeconds)
select(undef,undef,undef,(1/$freq));
} |
Archivo HTML:
<html>
<head>
<title>MJPG Live Demo</title>
</head>
<body>
<center>
<h2>Motion JPEG image on a UNIX web server via an intermediate
FTP server</h2>
<!-- Cut from here to the end of image display comment -->
<!-- Note: If you do not see a JavaScript below in the view
source window you must -->
<!-- first save the html file from your browser, then open the
saved -->
<!-- file in a text editor, for instance Notepad.-->
<SCRIPT LANGUAGE="JavaScript">
// Set the BaseURL to the url of your Web server
// Example: var BaseURL = "http://www.axis.com/";
var BaseURL = "http://[WebServer]/";
// DisplayWidth & DisplayHeight specifies the displayed width &
height of the image.
// The values depend on what Network Camera and resolution are
used.
// Select the Network Camera and resolution by removing the "//"
at the beginning
// of the applicable line.
// Note that only one can be enabled.
// AXIS 2100
// var DisplayWidth = "320";var DisplayHeight = "240";//
Resolution 320x240:
// var DisplayWidth = "640";var DisplayHeight = "480";//
Resolution 640x480:
// AXIS 2120/2400/2401/2420 PAL
// var DisplayWidth = "352";var DisplayHeight = "288";//
Resolution 352x288:
// var DisplayWidth = "704";var DisplayHeight = "576";//
Resolution 704x576:
// AXIS 2120/2400/2401/2420 NTSC
// var DisplayWidth = "352";var DisplayHeight = "240";//
Resolution 352x240:
// var DisplayWidth = "704";var DisplayHeight = "480";//
Resolution 704x480:
// This is the filepath to the Perl script
// Example: var File = "nph-update.cgi";
var File = "nph-update.cgi";
// This is the filepath to the ActiveX ocx needed by Internet
Explorer
// note the version number that is needed.
// Example: var OcxFile = "AxisCamControl.ocx#Version=1,0,1,42";
var OcxFile = "AxisCamControl.ocx#Version=1,0,1,42";
// No changes required below this point
var output = "";
if ((navigator.appName == "Microsoft Internet Explorer")&&(navigator.platform
!= "MacPPC")&&(navigator.platform != "Mac68k"))
{
// If Internet Explorer for Windows then use ActiveX
output = "<OBJECT ID=\"CamImage\" WIDTH="
output += DisplayWidth;
output += " HEIGHT=";
output += DisplayHeight;
output += " CLASSID=CLSID:917623D1-D8E5-11D2-BE8B-00104B06BDE3
";
output += "CODEBASE=\"";
output += BaseURL;
output += OcxFile;
output += "\">";
output += "<PARAM NAME=\"URL\" VALUE=\"";
output += BaseURL;
output += File;
output += "\"> <BR><B>Axis ActiveX Camera Control</B><BR>";
output += "The AXIS ActiveX Camera Control, which enables you ";
output += "to view live image streams in Microsoft Internet";
output += " Explorer, could not be registered on your computer.";
output += "<BR></OBJECT>";
}
else
{
// If not IE for Windows use the browser itself to display
output = "<IMG SRC=\"";
output += BaseURL;
output += File;
output += "?dummy=garb\" HEIGHT=\"";
// The above dummy cgi-parameter helps some versions of NS
output += DisplayHeight;
output += "\" WIDTH=\"";
output += DisplayWidth;
output += "\" ALT=\"Moving Image Stream\">";
}
document.write(output);
</script>
<!-- End of image display part -->
</body>
</html> |
Axis no se hace responsable por la manera en que estos cambios
de configuración puedan afectar su sistema. Si la modificación
falla o si se obtienen resultados inesperados, usted puede restaurar
su equipo a los valores de fábrica según se describe en el Manual de
Usuario. |