From camera to website: Building an open source video streamer
by W. Michael Petullo
YouTube is a very popular web service that allows people to share video content online. Although YouTube and other streaming video websites satisfy many users, you may have reasons to create your own streaming video website. Perhaps you work for a company that wants a more professional face on their media. Or, you may want more control over exactly how your videos are presented.
I am a soldier in the U.S. Army, currently deployed to Afghanistan. I wanted to be able to share videos with my family from away from home. I wished to maintain my privacy and have better control over my audience. Whether you wish to share videos for educational purposes, share screencasts for documenting software features, or simply entertain, this article will show you how to set up a streaming video website using open source software.
This technique outlines acquiring a video stream from a digital video camera, processing the video stream to the distribution format, and creating a website that will stream the video to users.
Video cameras of the class described in this article have two things in common. First, they store video using the Digital Video (DV) format. Second, they interface with a computer using an IEEE-1394 bus. If a video camera satisfies these two requirements, then it should be compatible with the techniques described here.
In order to facilitate real-time processing and increase the visual quality of recordings, the DV format provides for very limited compression of video data. As a result, files in the DV format tend to be very large. At its rate of approximately 36Mb per second, DV can consume 1GB of disk space in four minutes. Obviously, DV is not a good choice for a distribution format. Before uploading our video content to the website, we will compress its audio using Vorbis and its video using Theora. The audio and video tracks will be encapsulated using the Ogg container format.
Acquiring video
The first step is to acquire a video stream from a digital video camera. Dvgrab is the application that supports this step. Install it on Fedora using the command:
yum install dvgrab
The dvgrab utility interacts with a digital video camera over an IEEE-1394 bus to record the camera’s video stream to a computer’s hard disk. To copy data from a camera, place the camera in play mode and use rewind or fast forward to position the camera’s tape to the beginning of the desired video segment. Connect the camera to the computer using an IEEE-1394 cable. The command dvgrab --format raw --autosplit sample- will begin the transfer. As the transfer begins, the camera will begin to run its tape.
If the camera has an LCD panel, it will display the tape as it plays. The --autosplit option was used, dvgrab will attempt to identify separate recordings and save them using the filename sample-NUM.dv.
Editing and compressing video
Once a video is captured to disk, it is now ready for editing. There are several up-and-coming free software video editor applications. One such application is Pitivi.
Pitivi is written in Python and uses the GStreamer media framework. To install Pitivi (and some necessary GStreamer plugins), use the command yum install pitivi gstreamer-plugins-good.
Once Pitivi is installed, we will use it to encode our DV recording with Ogg. After starting the Pitivi application, click on the button labeled “Import clips…” Select video files and press the “Add” button to make them available within Pitivi.
Once you have selected all of the clips you want, press “Close.” You should now see your videos displayed in the top left corner of the Pitivi application as seen in Figure 2. You may drag and drop the videos into the timeline at the bottom of the application’s window. Once done, the window should look something like Figure 3.
Now that we have assembled our clips, it is time to encode them into the final video. This is done by selecting File->Render. The application will present a new window. Click on the button labeled “Choose File” and enter a name for the file you are about to create. Next, click on “Modify”
to select the target video’s parameters. Figure 4 show the parameters appropriate for our website. We will encode a 320×240 resolution video using Ogg, Vorbis, and Theora. Click “Ok” and then “Record.”

Fig 4. Pitivi encoding parameters
Depending on the length of your video, encoding may take a long time. While you wait for it to encode, download and install the Apache webserver using the command yum install httpd. Once your video processing is complete, copy the resulting file to /var/www/html. I will call this file example.ogg.
Distributing video
Cortado is a Java applet capable of playing streamed video from within a web browser. The applet is open source and is maintained by a company named Fluendo. We will use Cortado to provide a cross-platform way to play the videos on our website. The Cortado applet may be downloaded from Fluendo’s website. The file we will use is cortado-ovt-stripped-0.2.2.jar, which should be copied to /var/www/html. The “ovt” in the filename stands for Ogg, Vorbis, and Theora, the media formats supported by the applet.
Now that we have our video and Java applet installed in /var/www/html, we will write a quick HTML file that references both objects. The following is a simplified index.html for our project that should also be placed in /var/www/html:
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US"> <head> <title>Test video>/title> </head> <body> <applet code="com.fluendo.player.Cortado.class" archive="cortado-ovt-stripped-0.2.2.jar" width="320" height="240"> <param name="url" value="http://www.example.com/example.ogg"/> <param name="keepAspect" value="true"/> <param name="video" value="true"/> <param name="audio" value="true"/> <param name="bufferSize" value="200"/> </applet> </body> </html>
This HTML document references the Cortado Java applet that exists in the same directory. The applet takes several parameters, most notably the “url” and “bufferSize.” The “url” points to the video file and must be a full URL. The fully qualified domain name or IP address referenced must match that of the webserver. The “bufferSize” parameter sets the size of the client-side buffer and should be increased if the video does not play smoothly because of network latency. For a description of Cortado’s parameters, see the Cortado README file, distributed with the project’s source code.
All the tools necessary for building a very simple video website are now at your fingertips. It is time to start the Apache web server and welcome your audience. To start Apache, execute the command:
/sbin/service httpd start
To ensure it starts each time the server reboots, execute:
/sbin/chkconfig httpd on
Loading the URL http://www.example.com/ in a Java-enabled browser will play the video file. When running Fedora, the java-1.7.0-icedtea-plugin is capable of executing the Cortado applet.
You’re now ready to record, encode, and share a video over the web–with complete control over how they are presented. And, better yet: The software used is a completely open source solution for streaming video.










April 24th, 2008 at 11:34 pm
Very nice and straightforward method for creating free content.
In relation to Pitivi, there is a recently accepted project in Fedora from a Google Summer of Code student, to improve Pitivi and tools for non-linear video editing. For Fedora, it gives us another tool to make useful content, and it also helps push forward adoption of free culture. As that project progresses, testers can help improve the work and outcome by bringing their non-linear editing to the Pitivi work.
April 24th, 2008 at 11:53 pm
There are screenshots missing from this article? I see references to Figure 2 and Figure 3 but no figure…
April 25th, 2008 at 1:34 am
Nice mini How-To article.
Keep up the good work over there Michael.
April 25th, 2008 at 9:39 am
My apologies–the images got lost somewhere in the editing process. They’ve been added back now, enjoy!
April 26th, 2008 at 10:22 am
Nice tutorial, great work!
April 26th, 2008 at 6:53 pm
Thanx for an informative article. I was actually looking for live streaming. I have a UVC compliant Webcam of good quality and supported under linux. I was looking for an application which can take the input from the camera and feed it to gstreamer. I would be thankful if someone can suggest such an application
Thanks
anand
April 26th, 2008 at 7:08 pm
Anand: see Flumotion, http://www.flumotion.net/.
June 12th, 2008 at 12:29 am
i want to be able to view remote camera on the other end of my second clinic from a distant location it is like remote access i do it wit data but video i am not able to do or see image appears as blank can u help