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.