JMF Solutions

Concatenating Multiple Inputs

Given a list of input media files, the object is to concatenate them to generate one contiguous output media file. The problem gets more complicated if the input media contain data with different formats. In such cases, we need to transcode them to matching formats before performing the concatenation.

A sample application is written.  It accepts a list of input URL's. For each input URL, a Processor is created. Using the TrackControls from these Processors, it finds the matching tracks and performs the necessary transcoding if the tracks are not in matching formats. A custom DataSource is then created to accept the output DataSources from these Processors. It reads from the DataSources and in turn generates a continuous stream of data. This custom DataSource is then used to create another Processor to generate the concatenated output stream. The output from this last Processor then goes to a file DataSink to generate the final output data to a file.

  • The track formats of the final output may differ from the original input due to transcoding. For audio, downsampling may occur.
  • Only matching tracks can be concatenated. Tracks without matching tracks will be disabled. e.g., Concatenating an audio only file with an audio/video file will result in an audio only file.
  • As much as possible, the program attempts to maintain A/V synchronization across the concatenated files. There are some cases while that fail.

Platform: JDK 1.1.6 or later
JMF API: 2.0 or later
Implementation: AJ, WPP, SPP *

* AJ = All Java, WPP = Windows Performance Pack, SPP = Solaris Performance Pack

Related Classes
How to run this sample
java Concat -o <output URL> <input URL> ...
java Concat -o file:/c:/temp/ file:/c:/movies/amovie.avi file:/c:/movies/
Source Code
Left Curve
Java SDKs and Tools
Right Curve
Left Curve
Java Resources
Right Curve
Java May 2015 SM banner

Java SE Advanced Best Practices WebCast

Duke's Choice RHS Banner

JavaOne 2014 Replay banner