Distributed Transcoding

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:

Creating the split files

  1. Create a convert control to split the source file into smaller files. These files will be transcoded on separate machines.

  2. Specify the IltmmConvert::get_SourceFile for the conversion.

  3. Specify the IltmmConvert::put_TargetFormat of the Convert Control to the ltmmConvert_TargetFormat_LTES format.

  4. 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.TargetFormat - Set this to the final format to be used when the split files are merged back together.

  5. 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).

  6. Start the conversion. When complete, you should have several split files (determined by the settings in the Writer Filter), and a catalog file.

    Creating the Split Files

Transcoding each split file

In a typical scenario, each split file would be copied to a separate machine and the file would be transcoded as described below:

  1. Create a convert control to transcode the specified split file.

  2. Specify the IltmmConvert::get_SourceFile for the conversion. In this case, it would be the corresponding split file.

  3. Add the desired video compressor to the convert control. The same compressor must be used on each split file.

  4. Specify the IltmmConvert::put_TargetFormat  of the Convert Control to the ltmmConvert_TargetFormat_LTES format.

  5. 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.

  6. 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).

  7. Start the conversion. When the conversion on each machine is complete, you will be ready to merge all the individual clips back together.

    Transcoding Each Split File

The above process should be repeated for the audio stream as well. See Notes On Stream Types, below, for more information.

Merging the split files

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:

  1. Create a convert control to merge the individual split files.

  2. 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.

  3. Specify the IltmmConvert::put_TargetFormat  of the Convert Control to the desired output. This should match the TargetFormat set earlier in the writer filter.

  4. Set the IltmmConvert::put_TargetFile to the desired output file name.

  5. 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.

Merging the Split Files

LTESC Format

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> 

Notes on stream types

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.

Known issues

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.

Help Version 21.0.2021.7.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Filters C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.