devxlogo

Video Surveillance: Configuring the Server

Video Surveillance: Configuring the Server

In the first part of the tutorial, you learned how to create a web camera stream on your PC.

Now we need to read the stream and accept it at the remote location. This task can also be done in Java (using Apache Tomcat and Java Server Pages), but since PHP is a more popular solution for building websites, I’ll explain how to solve this problem using PHP.

Displaying the Video Using VLC

Before we start working with the code, I would like to point out that if you just want to watch the video on a remote location (without using storage, secure login etc.), you could do that with using VLC media player only. Just open the program, click File > Open network stream, paste the port and IP address there, and click play.

Displaying the Video on a Web Page

The code used to display a web camera stream on a remote location (i.e. web page) depends on the video format. For example, if the video stream format was .swf, we would have to use the Flash player code; if the stream was .wmv format, we would use Windows media player. Let’s start with the flash video format:

codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="400" height="400">quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash">

The only thing you need to change for this code to work is the video name (myvideo.swf). In this case, just use the IP address of the stream. Note that we use two HTML tags (object and embed) for maximum browser compatibility. Also have in mind that the code will not work without having the right player installed (flash player in this case).

Windows Media Video (.wmv)

The following code displays a windows media video on a web page:

 

QuickTime (.mov)

To show a QuickTime video on a web page, use this code:

MPEG-4 Video (.mp4)

MPEG-4 videos are also opened with QuickTime, but the HTML code is different:

Displaying the Video from PHP

One of the possible problems with previous streaming methods is that anyone who knows to view the HTML source of a web page can see your stream’s address. This can be solved by showing a video stream directly from PHP.

First, you need to check php.ini file and find “allow_url_fopen” option. It should be set to “1”, in order to allow PHP file functions to open external URLs. After that, create a PHP page with the following code:

The code is pretty self-explanatory. The only things that need to be changed are the path to the stream (IP address in this case) and Content-type header. Content-type is different for each video format and can be seen here.

In the third part of this tutorial, you will learn how to display the received data.

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist

©2024 Copyright DevX - All Rights Reserved. Registration or use of this site constitutes acceptance of our Terms of Service and Privacy Policy.