Skip to main content
Extract specific segments from videos and sample frames at precise intervals for analysis, processing, or content creation. Perfect for highlight extraction, content moderation, quality control, and automated video analysis workflows.

Key Features

  • Precise Trimming: Cut videos to exact time ranges with millisecond precision
  • Smart Frame Sampling: Extract frames at regular intervals or specific timestamps
  • Quality Preservation: Maintain original video quality in trimmed segments
  • Batch Processing: Process multiple trim operations on single or multiple videos
  • Flexible Output: Export as video segments or individual frame images
  • Intelligent Keyframe Detection: Automatically identify and extract key moments

Response Format

{
  "trimmed_video_url": "https://api.vlmrun.com/trimmed/segment_12345.mp4",
  "sampled_frames": [
    {
      "frame_number": 30,
      "timestamp": "00:00:01.000",
      "frame_url": "https://api.vlmrun.com/frames/frame_30.jpg"
    },
    {
      "frame_number": 60,
      "timestamp": "00:00:02.000",
      "frame_url": "https://api.vlmrun.com/frames/frame_60.jpg"
    }
  ],
  "trim_range": {
    "start_time": "00:00:10.000",
    "end_time": "00:00:30.000",
    "duration": "00:00:20.000"
  },
  "original_duration": "00:05:30.000",
  "frames_extracted": 20,
  "processing_time": "5.2s"
}

Trimming Options

Time-Based Trimming

  • Start/End Times: Specify exact start and end timestamps
  • Duration-Based: Trim by specifying start time and duration
  • Multiple Segments: Extract multiple segments from single video
  • Keyframe Alignment: Align cuts to nearest keyframes for clean edits

Frame Sampling Methods

  • Uniform Sampling: Extract frames at regular intervals (e.g., every 1 second)
  • Keyframe Sampling: Extract only keyframes for efficient analysis
  • Custom Timestamps: Extract frames at specific timestamps
  • Adaptive Sampling: Intelligently sample based on scene changes

Use Cases

Content Analysis

  • Quality Control: Sample frames for quality verification
  • Content Moderation: Extract frames for automated content review
  • Thumbnail Generation: Create video thumbnails from key moments
  • Scene Detection: Sample frames to identify scene changes

Highlight Extraction

  • Event Detection: Extract segments with specific events or actions
  • Key Moments: Identify and trim important video moments
  • Summary Creation: Create video summaries from key segments
  • Clip Generation: Generate short clips for social media

Batch Processing

  • Large Video Libraries: Process multiple videos efficiently
  • Consistent Sampling: Apply same sampling strategy across videos
  • Parallel Processing: Extract frames from multiple videos simultaneously
  • Automated Workflows: Integrate into automated video pipelines

Execute Agent

Run this capability using the agent execute endpoint:
from pathlib import Path
from vlmrun.client import VLMRun

client = VLMRun(base_url="https://agent.vlm.run/v1", api_key="<VLMRUN_API_KEY>")

# Upload the video
file = client.files.upload(file=Path("full_video.mp4"))

# Execute video trimming and frame sampling
response = client.agent.execute(
    inputs={"file": file.public_url},
    config={
        "prompt": "Trim video from 10s to 30s and sample frames every 2 seconds",
        "capability": "video_trimming",
        "start_time": "00:00:10",
        "end_time": "00:00:30",
        "sample_interval": 2,
        "output_format": "both"
    }
)

# Poll for results
import time
while True:
    execution = client.agent.executions.get(execution_id=response.execution_id)
    if execution.status == "completed":
        print(execution.response)
        break
    elif execution.status == "failed":
        print(f"Error: {execution.error}")
        break
    time.sleep(2)

Best Practices

  • Keyframe Alignment: Align cuts to keyframes for clean, efficient trimming
  • Sample Rate: Choose appropriate frame sampling rate based on your analysis needs
  • Quality Settings: Balance file size and quality for your use case
  • Batch Processing: Process multiple videos or segments efficiently

Try Video Trimming

Experience video trimming and frame sampling with live examples in our interactive notebook