Service: Trim Media - EyevinnOSC/community GitHub Wiki
Trim Media (serviceId eyevinn-function-trim) is a serverless media function that trims a single media file or an ABR bundle of media files and uploads the output to an S3 bucket. In Eyevinn Open Source Cloud (OSC) it is a long-running service instance exposing a REST API. License: MIT. This page also covers Scene Detect.
- Trim a single media file, or a bundle of ABR renditions, to one or more time ranges given as an edit decision list (EDL).
- Read the source from S3-compatible storage (for example MinIO) and upload the result to an S3 bucket.
- Run trim as jobs: create, check status and cancel through the API.
- Uses FFmpeg to convert the input into a file that can be uploaded.
Prerequisite: an S3-compatible bucket with the source video. If you need object storage on OSC, create a MinIO instance first and confirm it is running.
Store the S3 credentials with create-service-secret (serviceId eyevinn-function-trim), for example accesskeyid and secretaccesskey, then create the instance with create-service-instance using serviceId: "eyevinn-function-trim". The name must be alphanumeric and at most 20 characters.
{
"name": "mytrim",
"awsRegion": "us-east-1",
"awsAccessKeyId": "{{secrets.accesskeyid}}",
"awsSecretAccessKey": "{{secrets.secretaccesskey}}"
}Wait with wait-for-service-ready, then use describe-service-instance for the instance URL. OSC CLI form: osc create eyevinn-function-trim mytrim -o awsRegion="us-east-1" -o awsAccessKeyId="{{secrets.accesskeyid}}" -o awsSecretAccessKey="{{secrets.secretaccesskey}}".
| Option | Required | Type | Meaning |
|---|---|---|---|
| name | Yes | string | Name of the instance. Letters, digits and underscore only, at most 20 characters. |
| awsRegion | Yes | string | AWS region where the output S3 bucket resides (AWS_REGION; it can also be given in the request payload). Tutorials use us-east-1 for MinIO on OSC. |
| awsAccessKeyId | Yes | string, sensitive | AWS access key id for S3 bucket access (AWS_ACCESS_KEY_ID). For MinIO, its access key. |
| awsSecretAccessKey | Yes | string, sensitive | AWS secret access key for S3 bucket access (AWS_SECRET_ACCESS_KEY). For MinIO, its secret key. |
The key id and secret are sensitive: store them as service secrets and reference them as {{secrets.NAME}}, which only works as the entire field value.
Endpoints:
| Endpoint | Method | Description |
|---|---|---|
/ |
GET | Heartbeat of the service |
/trim |
POST | Create a new trim job; settings in the body |
/trim/<jobId> |
GET | Status of a trim job |
/trim/<jobId> |
DELETE | Cancel a trim job |
OSC puts an authentication gate in front of instance URLs other than /, so calls from outside may need a service access token.
Trim a single file (start and end in seconds):
curl -X POST "https://<instance-url>/trim" \
-H "Content-Type: application/json" \
-d '{
"source": ["s3://mybucket/input.mp4"],
"sourceType": "single",
"outputDirectory": "s3://mybucket/output",
"edl": {
"name": "trimmed",
"segments": [{ "start": 10, "end": 20 }]
}
}'Trim an ABR bundle by listing all renditions in source and setting "sourceType": "abr":
{
"source": [
"s3://mybucket/demo/240.mp4",
"s3://mybucket/demo/360.mp4",
"s3://mybucket/demo/720.mp4"
],
"sourceType": "abr",
"outputDirectory": "s3://mybucket/output",
"edl": { "name": "reel-demo1", "segments": [{ "start": 10, "end": 20 }] }
}Scene Detect Media Function (serviceId eyevinn-function-scenes) detects scene changes and extracts keyframes in a video file or stream. It has a single option and is created with create-service-instance. See Scene Detect Media Function.
| Option | Required | Type | Meaning |
|---|---|---|---|
| name | Yes | string | Name of the instance. At most 20 characters, alphanumeric. |