Getting to grips with kaltura mix xml, implementing your own clipping

1 reply [Last post]
Joined: 05/06/2009
Points: 29

In an application i am building i had the need to build my own kaltura mixes manually.

Here's an outline of how i did it and some of the pitfalls i encountered along the way

To build the mix initially i used the createMix api function

$partnerID = ***;
$config = new KalturaConfiguration();
$config->partnerId = $partnerID;
$kalturaClient = new KalturaClient();
$kalturaClient->setConfig($config);

//create the mix
$mixEntryId = $kalturaClient->mixing->add($mixEntry);

mixEntryId is the id of the mix entry created, Then i added entries to the mix, using the appendMediaEantry function.

// where $mediaEntryId is the id of the individual video
$kalturaClient->mixing->appendMediaEntry($mixEntryId, $mediaEntryId);

So far so good this created a mix with the desired media entries, the difficulties came when i tried to apply the clipping. There is a member variable in the KalturaMixEntry Object called dataContent. This is the xml which contains the information about the mix. Here we can implement our own clipping.

The dataContent xml is split into 5 parts Metadata, VideoAssets, AudioAssets, VoiceAssets and Plugins. I'll only be talking about VideoAssets and Plugins here.

VideoAssets contain vidasset tags and each one of these represents a video in your mix. Here's an example

<vidAsset k_id="<entry id>" type="VIDEO" name="name"
                   url="http://<kalturaserver>/flvclipper/entry_id/0_3udppugi/clip_from/3000/clip_to/8000/flavor/0">  
    <StreamInfo file_name="/content/entry/data/4/269/<filename>.flv" start_time="3.00"
                           len_time="5.00" posX="0" posY="0" start_byte="-1" end_byte="-1"
                           total_bytes="-1" real_seek_time="-1" volume="1" pan="0"
                           Clipped_Start="3.00" Clipped_Len="5.00"/>  
</vidAsset>

This video has been edited so that it will play from the third to the eighth second
the important parts are:
start_time Clipped_Start
this is where the video will start from
len_time, Clipped _Len
these indicate how long you want it to play for

start_byte, end_byte, total_bytes, and real_seek_time must all be set to -1, the kaltura server will assign the correct values

the url should be set as follows(not sure if this is necessary)
http:///flvclipper/entry_id/0_3udppugi/clip_from/3000/clip_to/8000/flavo...
where 3000 and 8000 are the start and end points in milliseconds

I set all these values by reading in the mix and parsing the data out with simplexml.

The last thing of note is that when i tried to save the mix dataContent out using apiV3 calls the mix that returned would not play on the kdp. I got a black screen. I had to use the setMetaData function from partnerservices2 to achieve this. There seems to be a bug here.

To explore and get information on partnerservices2 go to http:///index.php/partnerservices2/testme and you'll be able to try out a test console.

I hope this is of use to someone, it kept me up till the early hours. If you're interested I can post on how to get transitions in there as well

Joined: 04/13/2011
Points: 24

Hi,

I am creating mix manually as well. The mix I created is having issue with playing sound track. I think there must be something wrong in the section of the mix XML. I am wondering if you can help me on this . Many thanks for your help.

Stephen