Trim a media item

Use the Platform Management API v2 to trim an existing media item

You can trim any video on demand (VOD) using the Platform Management API V2. If you use the Live Channels product, you can trim excess content from the start and end of the Live Event video once the event has ended.

πŸ“˜

If you prefer, you can also trim media through your JW Player dashboard.



Trim media

πŸ“˜

Important

  • Only videos that have MP4 format originals with the H.264 codec and .mp4 file extension can be trimmed.
  • Media ID does not change when trimming a video.
  • Although a media item can be retrimmed up to and including its original length in the future, JW Player does not store an original file in its exact form. Therefore, you should retain your original files locally.

Use the following steps to trim your media:

  1. Make a PUT /v2/sites/{site_id}/media/{media_id}/reupload/ call to trim a specific media item. Within the JSON body, define trim_in_point as the new beginning timecode of the media item and define trim_out_point as the new ending timecode of the media item.
  2. Refer to PUT /v2/sites/{site_id}/media/{media_id}/reupload/ for more information about acceptable metadata body parameters.

In the following snippets, only the media item's trim_in_point value is defined, while the trim_out_point is null. This will trim the media item from the beginning and leave the media item’s ending timecode intact. Both values are required to trim.


curl --request PUT \
     --url https://api.jwplayer.com/v2/sites/{site_id}/media/{media_id}/reupload/ \
     --header 'Accept: application/json' \
     --header 'Authorization: {secret}' \
     --header 'Content-Type: application/json' \
     --data '
{
     "upload": {
          "trim_in_point": "00:00:27",
          "trim_out_point": "null",
          "method": "direct"
     }
}
'
import requests

url = "https://api.jwplayer.com/v2/sites/{site_id}/media/{media_id}/reupload/"

payload = {"upload": {
        "trim_in_point": "00:00:27",
        "trim_out_point": "null"
    }}
headers = {
    "Accept": "application/json",
    "Content-Type": "application/json",
    "Authorization": "{secret}"
}

response = requests.request("PUT", url, json=payload, headers=headers)

print(response.text)

Sample Response

{
    "created": "2021-12-21T06:36:20+00:00",
    "duration": 3643.05,
    "error_message": null,
    "external_id": "wMZDVnBD-event-aIacvmlE",
    "hosting_type": "hosted",
    "id": "{media_id}",
    "last_modified": "2022-02-09T21:45:52+00:00",
    "media_type": "video",
    "metadata": {
      "author": "",
      "category": "Automotive",
      "custom_params": {
      "livestream_channel_id": "{livestream_channel_id}"
      },
"description": "",
"language": null,
"permalink": "",
"protection_rule_key": null,
"publish_end_date": null,
"publish_start_date": "2021-12-21T06:36:00+00:00",
"tags": [
"preview"
],
"title": "Model T In Action 2021-12-21 at 06:36"
    },
    "mime_type": null,
    "relationships": {},
    "schema": null,
    "source_url": null,
    "status": "ready",
    "trim_in_point": "00:11:46",
    "trim_out_point": "01:12:29",
    "type": "media",
    "upload_link": "https://jwplayer-upload.s3-accelerate.amazonaws.com/3RM7Lf6o?AWSAccessKeyId=AKIA5SWKMFCV3YLQ7LLR&Signature=f%2BvADrriLd8YpIyU3XY9Yu4Fdr0%3D&Expires=1649810884"
}

Did this page help you?