Newsletter sign-up
View all newsletters

Sign up for our Enterprise Java Newsletter

Enterprise Java

Program multimedia with JMF, Part 1

Go multimedia by learning how the Java Media Framework compares to your stereo system

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone
The Java Media Framework (JMF) is a large and versatile API used to process time-based media. However, JMF's complexity can take weeks to understand. With that complexity in mind, this article introduces JMF the easy way. We start by drawing an analogy with a stereo system, and then proceed with discussions of JMF's most common interfaces and classes. Finally, we'll see working code that demonstrates part of the API's capabilities.

This article, the first of a two-part series, focuses on the JMF architecture. Part 2 will focus mostly on the code that shows how to register the capture devices, and to play and capture audio and video data.

JMF, currently at version 2.1, is Sun's initiative to bring time-based media processing to Java. Time-based media is data that changes meaningfully with respect to time, such as audio and video clips, MIDI sequences, and animations. Note that Sun recently announced it would release the JMF 2.1 source code under the Sun Community Source Licensing Program (SCSL). Also a complete reference implementation, JMF 2.1 will enable you to do anything imaginable with multimedia. Among others uses, JMF can:

  • Play various multimedia files in a Java applet or application. The formats supported include AU, AVI, MIDI, MPEG, QuickTime, and WAV.
  • Play streaming media from the Internet.
  • Capture audio and video with your microphone and video camera, then store the data in a supported format.
  • Process time-based media and change the content-type format.
  • Transmit audio and video in realtime on the Internet.
  • Broadcast live radio or television programs.


However, before you write a JMF application, you need to fully understand the JMF architecture, its interfaces, and its classes.

The JMF architecture

To easily understand the JMF architecture, take your stereo system as a comparison. When you play a Sarah Vaughan CD with your CD player, the CD provides the music data to the system. This data has been previously captured using microphones and other devices in the recording studio. The microphone serves as an audio capture device. The CD itself is a data source to the stereo system.

The CD player outputs the music signal to the speaker -- the output device. However, from the CD player we can also plug in an earphone. In this case, the earphone acts as the output device.

JMF uses the same model. As you read on, you will come across terms such as:

  • Data source
  • Capture device
  • Player
  • Processor
  • DataSink
  • Format
  • Manager


Let's look at these terms in more detail.

Data source

A data source encapsulates the media stream much like a music CD. In JMF, a DataSource object represents the audio media, video media, or a combination of the two. A DataSource can be a file or an incoming stream from the Internet. The good thing about this class is, once you determine its location or protocol, the DataSource encapsulates both the media location, and the protocol and software used to deliver the media. Once created, a DataSource can be fed into a Player to be rendered, with the Player unconcerned about where the DataSource originated or what was its original form.

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone
Comments (7)
Login
Forgot your account info?

address for part 2By Anonymous on March 5, 2010, 6:34 amhttp://www.javaworld.com/javaworld/jw-05-2001/jw-0504-jmf2.html

Reply | Read entire comment

You are my GuruBy Anonymous on January 26, 2010, 3:04 pmVery nicely explained. A great tutorial for someone like me who is starting to use JMF for some applications. Thanks a lot.

Reply | Read entire comment

muy bien explicadoBy Anonymous on January 26, 2010, 12:45 pmmuy bien explicado

Reply | Read entire comment

Thanks, where can i find part 2?By Anonymous on December 6, 2009, 12:13 amSir this was very informative but where is part 2??

Reply | Read entire comment

GreatBy Anonymous on November 23, 2009, 10:30 pmYou explained it very well. Thank you.

Reply | Read entire comment

View all comments

Add comment
Anonymous comments subject to approval. Register here for member benefits.
Have a JavaWorld account? Log in here. Register now for a free account.
Resources