-->
Save your seat for Streaming Media NYC this May. Register Now!

Creating Interactive Video With MPEG4

Real Examples
So, enough of this background – let's dive into some working examples. The enabler for our little foray into interactive MPEG4 is the IBM alphaWorks Toolkit for MPEG4. The toolkit can be downloaded for evaluation purposes for free at the alphaWorks site. Download and unzip the IBMToolkitForMpeg zipfile and you'll find three components inside:
    • AVGen, a utility to combine separate audio and video files into a single mp4 file.
    • M4Play, an MPEG4 player (we'll use this to view our creation)
    • XMTBatch, the compiler that makes XMT-O metafiles into movies

You'll need a recent Java runtime to run it – the newer the better, available by clicking the "Get It Now" link at http://java.com/en/index.jsp.

To create my first simple interactive MPEG4 presentation, I decided to remake the watermarking using SMIL example for my recent article "How to Brand Your Video with a Watermark." In that example, a semi-transparent watermark overlays the video in the bottom right-hand corner of the video image. If you pass the mouse over the watermark, it "lights up", becoming opaque until you move the mouse away.

You can download the complete XMT source code and MPEG4 media for this example, or you can view the finished product [5MB progressive download].

Here's the XMT-O source code for our sample program. It starts with all the standard XML declarations and such:

<?xml version="1.0" encoding="UTF-8"?><xmt-o xmlns="urn:mpeg:mpeg4:xmto:schema:2002" xsi:schemalocation="urn:mpeg:mpeg4:xmto:schema:2002 xmt-o.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink"></xmt-o>

That's followed by a section which, just like with SMIL, defines the color and size of the playback window, as well as any regions and subregions we'll need. Notice that the syntax has subtle differences from SMIL 2.0.

<head> <layout metrics="pixel" type="xmt/xmt-basic-layout"> <toplayout width="300" height="300" backgroundcolor="white"> <region id="video_region"> <region id="watermark_region" translation="100 -90" size="91 27"></region> </region> </toplayout> </layout> </head>With the head defined, we'll add the body section, which describes our media. You'll notice that it looks a lot like SMIL, with the familiar video, audio, and img tags. I created the media files with Quicktime Pro, loading in my AVI source media and using Export to convert to MPEG4. Notice that in the src attributes of the video and audio tags, I had to append #video and #audio to specify which track of the source MPEG4 file I was referring to.

<body> <par> <video src="rainier_hike.mp4#video" region="video_region" begin="0s" dur="indefinite"></video> <audio src="rainier_hike.mp4#audio" begin="0s" dur="indefinite"></audio> <img src="emedia_icon91x27.jpg" id="sm_mark" region="watermark_region" begin="0s" dur="indefinite"> <material id="mat1" transparency=".5"> <set id="set1" begin="sm_mark.inBoundsEvent" end="sm_mark.outOfBoundsEvent" attributename="transparency" to=".1"></set> <set id="set2" begin="sm_mark.outOfBoundsEvent" end="sm_mark.inBoundsEvent" attributename="transparency" to=".5"></set> </material> </par></body>To try this yourself, first download the mp4_watermark_example.zip file from the MPEG4 samples page. Then open up the directory into which you previously downloaded and unzipped the IBM Toolkit for MPEG4. If you're using Windows, double-click on XMTBatch.bat. On any platform, you can launch it by typing java -cp IBMToolkitForMpeg4.jar XmtBatch at the command prompt. Simply select the XMT-O input file and an MP4 output file destination, and click Start. You can view the MP4 by double-clicking M4Play.bat (from a command-line: java -cp IBMToolkitForMpeg4.jar M4Play) and opening the MP4 file.

Streaming Covers
Free
for qualified subscribers
Subscribe Now Current Issue Past Issues