The LEAD Elementary Stream Source and Writer Filters allow developers to create applications that use multiple physical machines to transcode a single file, reducing the total conversion time. The process of splitting the source file into multiple pieces, transcoding each of those pieces on a separate machine, and merging those transcoded files back into a single file is done seamlessly without any gaps at the split points or loss of audio/video synchronization.
These filters are included as part of the LEADTOOLS Multimedia Suite.
Take the following steps to create a multi-machine transcoding application:
Create a convert control to split the source file into smaller files. These files will be transcoded on separate machines.
Specify the IltmmConvert::get_SourceFile for the conversion.
Specify the IltmmConvert::put_TargetFormat of the Convert Control to the ltmmConvert_TargetFormat_LTES format.
Obtain an instance of the LEAD Elementary Stream Writer filter using the IltmmConvert::GetSubObject method and set the following properties:
ILTESWriter.VideoClipMethod- This tells the Writer whether to split the source into a fixed number of files, or by specified intervals..
ILTESWriter.VideoClipDuration - If splitting the source into a variable number of output files, specify the interval for each split file.
ILTESWriter.VideoClipCount - If splitting the source into a fixed number of output files, set this to the number of split files the writer should create.
ILTESWriter.TargtFormat - Set this to the final format to be used when the split files are merged back together.
Set the IltmmConvert::put_TargetFile to <filename>.ltesc. By specifying LTESC as the extension, you are telling the writer to split the source, and create a catalog file (explained below).
Start the conversion. When complete, you should have several split files (determined by the settings in the Writer Filter), and a catalog file.
In a typical scenario, each split file would be copied to a separate machine and the file would be transcoded as described below:
Create a convert control to transcode the specified split file.
Specify the IltmmConvert::get_SourceFile for the conversion. In this case, it would be the corresponding split file.
Add the desired video compressor to the convert control. The same compressor must be used on each split file.
Specify the IltmmConvert::put_TargetFormat of the Convert Control to the ltmmConvert_TargetFormat_LTES format.
Obtain an instance of the LEAD Elementary Stream Writer filter using the IltmmConvert::GetSubObject method and set the VideoClipMethod to eLTESWriter_ClipMethod_None. The Original file has been split, so we do not need to split it again. We are only performing a normal (1:1) conversion here.
Set the IltmmConvert::put_TargetFile to <filename>.ltes. By specifying LTES as the extension, you are telling the writer to create single output file (do not split the source).
Start the conversion. When the conversion on each machine is complete, you will be ready to merge all the individual clips back together.
The above process should be repeated for the audio stream as well. See Notes On Stream Types, below, for more information.
Once all split files have been transcoded, you will be ready to merge all the individual clips back together as described below. The source path of all transcoded clips (audio and video) should match the paths of the corresponding clips in the original catalog file:
Create a convert control to merge the individual split files.
Specify the IltmmConvert::get_SourceFile for the conversion. In this case, it would be the catalog file. When using a catalog file as the source of a conversion, the output will be the merged output of all clips in the catalog file.
Specify the IltmmConvert::put_TargetFormat of the Convert Control to the desired output. This should match the TargetFormat set earlier in the writer filter.
Set the IltmmConvert::put_TargetFile to the desired output file name.
Start the conversion. When the conversion is complete, the result will be a single file that was compressed using multiple machines.
The above process should be repeated for the audio stream as well. See Notes on stream types below for more information.
The LTESC format (LEADTOOLS Elementary Stream Catalog) is used as an index file and contains XML which represents all information necessary to merge all split files back together. Below is an example of a LTESC file.
<?xml version="1.0" encoding="utf-8" ?>
<ltesCatalog>
<stream id="stream 1" type="{73646976-0000-0010-8000-00AA00389B71}">
<clip src="test-1-c1.ltes" start="0" duration="100100001" />
<clip src="test-1-c2.ltes" start="0" duration="100100111" />
<clip src="test-1-c3.ltes" start="0" duration="100100111" />
<clip src="test-1-c4.ltes" start="0" duration="100100111" />
<clip src="test-1-c5.ltes" start="0" duration="20020000" />
</stream>
<stream id="stream 2" type="{73647561-0000-0010-8000-00AA00389B71}">
<clip src="test-2.ltes" start="0" duration="419635001" />
</stream>
</ltesCatalog>
Stream - This represents a stream in the catalog file. Since audio streams usually convert very quickly, the audio stream is never split. Only the video stream is split.
Type - Represents the GUID of the stream major type. In most cases, this is audio or video but other stream types are supported as well. As stated above, only video streams will be split.
Clip - Each stream contains a collection of clips. These are the individual files which were split from the source file, transcoded, then merged back together.
Src - The file path for the corresponding clip.
Start - The start time for the corresponding clip.
Duration - The length of the corresponding clip.
When merging the split files back together, it is important that the path to all transcoded split files is updated in the catalog file. You can either update the catalog file directly, or create a separate catalog file which is a copy of the original, but with updated file paths.
The transcoding process for the video stream is the most CPU intensive part of transcoding, and it responsible for the majority of the transcode time. Transcoding the audio stream is much faster and less CPU intensive. As a result, the LTES writer only splits the video stream. Any other stream (like the audio), can still be transcoded, but that entire stream will be transcoded at one time.
The Microsoft MPEG4 decoder occasionally drops the last frame of a conversion. Synchronization does not get lost in the merged video, but the last frame of each split file will be lost. To resolve this issue, we recommend you use the LEAD MPEG-4 Decoder. You can do this by either increasing the merit of the LEAD Decoder, or setting the SetPreferredFilter function of the LEAD MPEG4 Decoder.
LEAD Elementary Stream Source Filter
LEAD Elementary Stream Writer Filter