Java Media Framework
Encyclopedia
The Java Media Framework (JMF) is a Java library that enables audio, video and other time-based media to be added to Java
Java (programming language)
Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...

 applications and applets. This optional package, which can capture, play, stream, and transcode multiple media formats
File format
A file format is a particular way that information is encoded for storage in a computer file.Since a disk drive, or indeed any computer storage, can store only bits, the computer must have some way of converting information to 0s and 1s and vice-versa. There are different kinds of formats for...

, extends the Java Platform, Standard Edition
Java Platform, Standard Edition
Java Platform, Standard Edition or Java SE is a widely used platform for programming in the Java language. It is the Java Platform used to deploy portable applications for general use...

 (Java SE) and allows development of cross-platform multimedia applications.

Versions and licensing

An initial, playback-only version of JMF was developed by Sun Microsystems
Sun Microsystems
Sun Microsystems, Inc. was a company that sold :computers, computer components, :computer software, and :information technology services. Sun was founded on February 24, 1982...

, Silicon Graphics
Silicon Graphics
Silicon Graphics, Inc. was a manufacturer of high-performance computing solutions, including computer hardware and software, founded in 1981 by Jim Clark...

, and Intel, and released as JMF 1.0 in 1997. JMF 2.0, developed by Sun and IBM
IBM
International Business Machines Corporation or IBM is an American multinational technology and consulting corporation headquartered in Armonk, New York, United States. IBM manufactures and sells computer hardware and software, and it offers infrastructure, hosting and consulting services in areas...

, came out in 1999 and added capture, streaming, pluggable codec
Codec
A codec is a device or computer program capable of encoding or decoding a digital data stream or signal. The word codec is a portmanteau of "compressor-decompressor" or, more commonly, "coder-decoder"...

s, and transcoding. JMF is branded as part of Sun's "Desktop" technology of J2SE opposed to the Java server-side and client-side application frameworks. The notable exceptions are Java applet
Java applet
A Java applet is an applet delivered to users in the form of Java bytecode. Java applets can run in a Web browser using a Java Virtual Machine , or in Sun's AppletViewer, a stand-alone tool for testing applets...

s and Java Web Start
Java Web Start
In computing, Java Web Start is a framework developed by Sun Microsystems that allows users to start application software for the Java Platform directly from the Internet using a web browser....

, which have access to the full JMF in the web browser's or appletviewer's underlying JRE.

JMF 2.0 originally shipped with an MP3 decoder and encoder. This was removed in 2002, and a new MP3 playback-only plug-in was posted in 2004.

JMF binaries are available under a custom license, and the source is available under the SCSL.

The current version ships with four JAR (file format)
JAR (file format)
In software, JAR is an archive file format typically used to aggregate many Java class files and associated metadata and resources into one file to distribute application software or libraries on the Java platform.JAR files are built on the ZIP file format and have the .jar file extension...

 files, and shell scripts to launch four JMF-based applications:
  • JMStudio - A simple player GUI
  • JMFRegistry - A GUI for managing the JMF "registry," which manages preferences, plug-ins, etc.
  • JMFCustomizer - Used for creating a JAR file that contains only the classes needed by a specific JMF application, which allows developers to ship a smaller application.
  • JMFInit


SJMF is available in an all-Java version and as platform-specific "performance packs", which can contain native-code players for the platform, and/or hooks into a multimedia engine specific to that platform. JMF 2.0 offers performance packs for Linux, Solaris (on SPARC) and Windows.

In January 2011, Tudor Holton of Bentokit Project released a Debian package for the JMF to alleviate difficulties that had arisen over time when installing the JMF on Debian
Debian
Debian is a computer operating system composed of software packages released as free and open source software primarily under the GNU General Public License along with other free software licenses. Debian GNU/Linux, which includes the GNU OS tools and Linux kernel, is a popular and influential...

 and Ubuntu
Ubuntu (operating system)
Ubuntu is a computer operating system based on the Debian Linux distribution and distributed as free and open source software. It is named after the Southern African philosophy of Ubuntu...

 GNU/Linux. This package does not contain the JMF, but presents the user with the JMF License, retrieves it from the Oracle website, and then installs it. A similar Debian package  installer for the JMF MP3 Plugin was also built in February 2011.

Design concepts

JMF abstracts the media it works with into DataSources (for media being read into JMF) and DataSinks (for data being exported out). It does not afford the developer significant access to the particulars of any given format; rather, media is represented as sources (themselves obtained from URL's) that can be read in and played, processed, and exported (though not all codecs support processing and transcoding).

A Manager class offers static methods that are the primary point-of-contact with JMF for applications.

Criticism and alternatives

Many JMF developers have complained that the JMF implementation supplied in up-to-date JRE's supports relatively few up-to-date codecs and formats. Its all-Java version, for example, cannot play MPEG-2
MPEG-2
MPEG-2 is a standard for "the generic coding of moving pictures and associated audio information". It describes a combination of lossy video compression and lossy audio data compression methods which permit storage and transmission of movies using currently available storage media and transmission...

, MPEG-4
MPEG-4
MPEG-4 is a method of defining compression of audio and visual digital data. It was introduced in late 1998 and designated a standard for a group of audio and video coding formats and related technology agreed upon by the ISO/IEC Moving Picture Experts Group under the formal standard ISO/IEC...

, Windows Media
Windows Media
Windows Media is a multimedia framework for media creation and distribution for Microsoft Windows. It consists of a software development kit with several application programming interfaces and a number of prebuilt technologies, and is the replacement of NetShow technologies.The Windows Media SDK...

, RealMedia
RealMedia
RealMedia is a proprietary multimedia container format created by RealNetworks. Its extension is ".rm". It is typically used in conjunction with RealVideo and RealAudio and is used for streaming content over the Internet....

, most QuickTime
QuickTime
QuickTime is an extensible proprietary multimedia framework developed by Apple Inc., capable of handling various formats of digital video, picture, sound, panoramic images, and interactivity. The classic version of QuickTime is available for Windows XP and later, as well as Mac OS X Leopard and...

 movies, Flash
Adobe Flash
Adobe Flash is a multimedia platform used to add animation, video, and interactivity to web pages. Flash is frequently used for advertisements, games and flash animations for broadcast...

 content newer than Flash 2, and needs a plug-in to play the ubiquitous MP3
MP3
MPEG-1 or MPEG-2 Audio Layer III, more commonly referred to as MP3, is a patented digital audio encoding format using a form of lossy data compression...

 format. While the performance packs offer the ability to use the native platform's media library, they're only offered for Linux, Solaris and Windows. In particular, MS Windows-based JMF developers new to JMF often expect support for some newer formats on all platforms when such formats are only, in fact, supported on MS Windows.

While JMF is considered a very useful framework, the freely-available implementation provided by Sun is suffering from a lack of updates and maintenance. JMF does not get much maintenance effort from Sun; the API has not been enhanced since 1999, and the last news item on JMF's home page was posted in September 2008. While JMF is built for extensibility, there are few such third-party extensions. Furthermore, content editing functionality in JMF is effectively non-existent. You can do simple recording and playback for audio and video, but the implementation provided by Sun can do little else.

Platforms beyond those that Sun provides support to are left to their corresponding JRE vendors. While Sun still provides a forum for discussion of its implementation, there have been several efforts to implement open-source alternatives.

Alternatives

Depending on a developer's needs, several other libraries may be more suitable than JMF. These include:

Code example

The following example shows an AWT
Abstract Window Toolkit
The Abstract Window Toolkit is Java's original platform-independent windowing, graphics, and user-interface widget toolkit. The AWT is now part of the Java Foundation Classes — the standard API for providing a graphical user interface for a Java program.AWT is also the GUI toolkit for a...

file-selection dialog, and attempts to load and play the media file selected by the user.


import javax.media.*;
import java.io.File;
import java.awt.*;

public class TrivialJMFPlayer extends Frame {

public static void main (String[] args) {
try {
Frame f = new TrivialJMFPlayer;
f.pack;
f.setVisible (true);
} catch (Exception e) {
e.printStackTrace;
}
}
public TrivialJMFPlayer
throws java.io.IOException,
java.net.MalformedURLException,
javax.media.MediaException {
FileDialog fd = new FileDialog
(this, "TrivialJMFPlayer", FileDialog.LOAD);
fd.setVisible(true);
File f = new File(fd.getDirectory, fd.getFile);
Player p = Manager.createRealizedPlayer
(f.toURI.toURL);
Component c = p.getVisualComponent;
add(c);
p.start;
}
}


Much of the example is involved with the building of the AWT GUI. Only two lines touch JMF. Manager.createRealizedPlayer implicitly creates a DataSource from a URL representation of the file, creates a Player, and realizes it, meaning that all resources necessary for playback are allocated and initialized. The getVisualComponent asks the Player for an AWT Component suitable for use in a GUI. If a control component were desired, it would be obtained with getControlPanelComponent and added to the GUI separately. Note that the developer is not concerned with the format of the media - this code works equally well for any media format that JMF can import and read.
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK