JMF Solutions

Audio/Video Editing Example

 
Problem
You have several audio or video clips, or possibly different parts of a single movie that you'd like to concatenate together to create a single seamless movie. In addition, you'd like to apply some special effects in the transition between the clips.

Solution
Although the JMF API does not have any explicit media editing classes or methods, the API is flexible enough to create editing applications in several different ways. One such method is to create a custom DataSource class.

The advantage of creating this as a DataSource is that it can be directly connected to a processor which can then multiplex the data streams and write the output to a data sink. The parameters to this DataSource class are a list of files , the start and end times for each file and the effects to apply between the clips.

This example is not very complete and makes assumptions about the input formats. Some of the restrictions are - the input audio files need to be sampled at 44,100 Hz, all the input videos should be of the same dimensions, and the input audio cannot be in MPEG format. This final restriction is due to a bug in the JMF 2.0 implementation.

The SuperGlueDataSource basically opens one input file at a time using a processor, requests output in a raw format, strips away data not contained within the start and end times and feeds them as a stream one file after the other. Since the stream is to be connected to a processor, it needs to maintain consistency in the format of the data on individual tracks. While concatenating these files, it also applies effects on the last few buffers of the first file and the first few buffers of the next file, as specified by the overlap durations.

The MiniME application is an example of how to use the SuperGlueDataSource. Do not expect to use this as a general-purpose editing tool. Feel free to extend these classes to create your own media editing application and add more special effects.
 
Requirements
 
Platform: JDK 1.1.6 or later
JMF API: 2.0 or later
Implementation: AJ, WPP, SPP *
Other software requirements: Swing 1.1


* AJ = All Java, WPP = Windows Performance Pack, SPP = Solaris Performance Pack
 
Related Classes
 
 
How to run this sample
 
  1. Download the jar file and unjar it ("jar xvf minime.jar")

  2. Compile all the java files

  3.     java MiniME <url1> <url2> ...
    Note: If you are using Java 1.1, then make sure that you have Swing 1.1.x in your CLASSPATH.
 
Source Code
The jar file contains the sources - minime.jar
 
 
 
 
Left Curve
Java SDKs and Tools
Right Curve
Left Curve
Java Resources
Right Curve


Duke's Choice RHS Banner

JavaOne 2014 Replay banner