Über uns Produkte Support

How to Edit Fragmented MP4 HLS Streams (M3U8) With the Video Editing SDK



   Von Olga Krovyakova - 1. April 2019

With the newly released version 4.2, Solveig Multimedia's Video Editing SDK extends the suported formats.
Current version is generally focused on the online-based stream formats.

Video Editing SDK v.4.2 supports the following formats:

  • Fragmented MP4 HLS streams
  • HTTP hosted MP4 files
  • YouTube online videos

In this article you'll find the demonstration of the Fragmented MP4 HLS streams support.


TRY Video Editing SDK FREE


Fragmented MP4 HLS streams support

Video Editing SDK v.4.2 support the following features for Fragmented MP4 HLS streams:


You can easily open the Fragmented MP4 HLS M3U8 stream and work with it just like with the local files. You can navigate through the file as well as play it back. Only parts necessary for preview of the stream will be downloaded to your PC.

To preview the Fragmented MP4 HLS stream, you can build the following graph:

The graph contains a SolveigMM HLS Source as a source filter and Elecard AVC Video Decoder as a video decoder filter. Both filters shipped with the SDK.

Use the SMM Trim C++ Sample Application to test the support of the Fragmented MP4 HLS streams playback and trimming.
The following video demonstrates how you what you can do with the Fragmented MP4 HLS streams by means of the Video Editing SDK v.4.2:


Video Editing SDK is now capable of trimming of the Fragmented MP4 HLS streams. Video Editing Engine is the main component in charge. What you need to do is configure the Video Editing Engine, specify the XTL, describing your current task, then run it and wait for the completion.

Video Editing Engine is a COM component, exposing the ITrimmerObjControl, and you create it as follows:

hr = ::CoCreateInstance( CLSID_TrimmerObjControl, NULL, CLSCTX_INPROC, IID_ITrimmerObjControl, (void**)&m_pITrimmerObjControl );

To configure the Editing Engine you sould use the IModuleConfig interface:

hr = m_pITrimmerObjControl->QueryInterface(IID_IModuleConfig, (void **)&m_pModuleCfgEditObj);

You must use the obtained interface to set an XTL string, containing your trimming task, and optionally specify the callback to track the operation progress:

VARIANT var1 = {0}, var2 = {0};

var1.vt = VT_BSTR;
var1.bstrVal = ...; //task string in XTL format
hr = m_pModuleCfgEditObj->SetValue( &SMAT_XTLString, &var1 );

var2.vt = VT_BYREF|VT_UI1;
var2.pbVal = (BYTE*) &m_xCTrimmerObjControlCB; //pointer to the callback class
hr = m_pModuleCfgEditObj->SetValue( &SMAT_Callback, &var2 );

VARIANT var_res = {0};
hr = m_pModuleCfgEditObj->CommitChanges(&var_res);

You start the trimming process by invoking the ITrimmerObjControl::Start() method:

hr = m_pITrimmerObjControl->Start();

And during the trimming process you can ask the Editing Engine for a progress value:

VARIANT var = {0};
hr = m_pModuleCfgEditObj->GetValue( &SMAT_Progress, &var );

When the processing is done the Editing Engine invokes the ITrimmerObjControlCB::OnStop() from the callback.

Below you can see the XTL sting example, that contains a trimming task:

<timelines version="2">
  <group output="C:\hls\output.m3u8">
   <track video="1" audio="1" text="1" flags="">
    <clip src="http://smarteditingonline.solveigmm.com/files/test_multibitrate.m3u8"
                    start="160413589" stop="229542097" timeFormat="100ns_units">
    <clip src="http://smarteditingonline.solveigmm.com/files/test_multibitrate.m3u8"
                    start="469719350" stop="572525849" timeFormat="100ns_units">

The source file in this XTL is the Fragmented MP4 HLS file, hosted on http://smarteditingonline.solveigmm.com. Two intervals (represented by 'clip'-tags) will be saved from the source file to the output file:

  • 160413589 - 229542097 UNITS (or 16.041 - 22.954 sec) and
  • 469719350 - 572525849 UNITS (or 46.971 - 57.252 sec)

If the source file contains multiple streams (e.g. for different bitrate values), the source structure will be recreated.
The test file http://smarteditingonline.solveigmm.com/files/test_multibitrate.m3u8 contains 2 different streams with different bitrate values (see the picture below).


After trimming the output folder (C:\hls) will contain 2 subfolders with both streams and the M3U8 playlist file (output.m3u8) with the description of streams configurations. The following picture shows the structure of the trimmed HLS:


The structure of the output M3U8 file:




The trimmed file can be found by the following link:

Please refer to the SMM Trim C++ Sample Application source codes for the detailed description on how to configure and run the Video Editing Engine to perform trimming operation.


TRY Video Editing SDK FREE



Über den Autor

imageOlga Krovyakova ist seit 2010 Technical Support Manager bei Solveig Multimedia.

Sie ist Autorin zahlreicher Text- und Video-Richtlinien für Produkte: Video Splitter, HyperCam, WMP Trimmer Plugin, AVI Trimmer+ und TriMP4.

Sie arbeitet jeden Tag mit Programmen und weiß daher sehr gut, wie sie funktionieren. Wenden Sie sich bei Fragen an Olga über support@solveigmm.com.

Sie hilft Ihnen gerne weiter!