This website uses cookies to enhance your browsing experience. By continuing to use this website, you agree to our use of cookies. Click here to learn more, including how you can manage your cookie preferences.

Back

Server Side Clipping and Trimming

Kaltura server now supports the new abilities to clip or trim an entry. The trimming or clipping is done physically on the file system using conversion engines such as FFMPEG.
Clipping vs Trimming:

  1. Clipping– Create a new entry from an existing entry. Allows you to specify the start and end time for the new entry – the clip, this can be used to create a 2 minutes intro video to a long lecture or to take parts from one, such as homework assignments. You can also clip a long lecture to several shorter clips divided by subjects. The new entry will point to it’s source entry which it was clipped from, so you can always know what was the source entry for the clip – this can be found on the KaltruraBaseEntry->rootEntryId property.You can find all the clips that were created from a given entry, for example entry ID ‘0_ad523s’, by this simple API call:
    $filter = new KalturaMediaEntryFilter();
    $filter->rootEntryIdEqual = '0_ad523s'; //Add your source entry id here
    $results = $client->media->listAction($filter, null);

    In order to chain several clips from a single video, create a dynamic playlist with this filter:

    $filter = new KalturaMediaEntryFilterForPlaylist();
    $filter->rootEntryIdEqual = '0_ad523s'; //Add your source entry id here
  2. Trimming – No new entry is created. Sometimes, you may want to trim the start and/or end of a video, removing redundant parts. Trimming is performed on the source flavor of the entry, modifying that video permanently.

 

In order to trim an entry using Kaltura’s API just follow these steps:
*written in PHP and uses our PHP client library.
// Params
$overwrite = true; //Decides whether to trim the entry or clip it
// Entry Data
$entryId = '0_ad523s';//Add your entry ID
$startTime = 100; //Set the start time of the clip / trim in milliseconds
$endTime = 5000; //Set the end time of the clip / trim in milliseconds
$clipDuration = $endTime - $startTime;
// Create New Clip
$operation1 = new KalturaClipAttributes();
$operation1->offset = $startTime;
$operation1->duration = $clipDuration;
// Add New Resource
$resource = new KalturaOperationResource();
$resource->resource = new KalturaEntryResource();
$resource->resource->entryId = $entryId;
$resource->operationAttributes = array($operation1);
if( $overwrite ) {
// Trim Entry
try {
$resultEntry = $client->media->updateContent($entryId, $resource);
} catch( Exception $e ){
die('{"error": "' . $e->getMessage() . '"}');
}
} else {
// Create New Media Entry
$entry = new KalturaMediaEntry();
$entry->name = "New Clipped Entry Name";
$entry->description = "New Clipped Entry Description";
$entry->mediaType = 1; //The new media type
// New Clip
$resultEntry = $client->media->add($entry);
$resultEntry = $client->media->addContent($resultEntry->id, $resource);
}

*Code was taken from our new clipping application
So trim away!

Let’s Get Going