Skip to main content
View as Markdown

Trim (In-Place Content Replacement) - Content Management

Trim (In-Place Content Replacement)​

Trim shortens a video without changing its entry ID, embed codes, or analytics history.

Basic Trim​

Extract a segment and replace the original content:

curl -X POST "$KALTURA_SERVICE_URL/service/media/action/updateContent" \
-d "ks=$KALTURA_KS" \
-d "format=1" \
-d "entryId=$KALTURA_ENTRY_ID" \
-d "resource[objectType]=KalturaOperationResource" \
-d "resource[resource][objectType]=KalturaEntryResource" \
-d "resource[resource][entryId]=$KALTURA_ENTRY_ID" \
-d "resource[resource][flavorParamsId]=0" \
-d "resource[operationAttributes][0][objectType]=KalturaClipAttributes" \
-d "resource[operationAttributes][0][offset]=10000" \
-d "resource[operationAttributes][0][duration]=60000"

This trims the entry to a 60-second segment starting at 10 seconds. The source entryId in the inner resource points to the same entry being updated.

Poll Replacement Status​

while true; do
REPLACEMENT=$(curl -s -X POST "$KALTURA_SERVICE_URL/service/baseEntry/action/get" \
-d "ks=$KALTURA_KS" -d "format=1" -d "entryId=$KALTURA_ENTRY_ID" | jq -r '.replacementStatus')
echo "replacementStatus: $REPLACEMENT"
[ "$REPLACEMENT" = "2" ] && break
[ "$REPLACEMENT" = "4" ] && echo "Replacement failed" && break
sleep 5
done

Approve Replacement​

curl -X POST "$KALTURA_SERVICE_URL/service/media/action/approveReplace" \
-d "ks=$KALTURA_KS" \
-d "format=1" \
-d "entryId=$KALTURA_ENTRY_ID"

After approval, the entry's content is replaced with the trimmed version. The entry retains its original ID, metadata, embed URLs, and analytics.