Border Detection

Automatically detect and remove unwanted borders from videos.

Features

  • Detects all types of black borders (letterbox, pillarbox, windowbox)
  • Analyzes border properties including thickness, location, and color
  • Calculates aspect ratio changes and crop percentages
  • Preserves video quality during cropping
  • Can process videos globally or scene-by-scene

Inputs

  • file: Video file to process
  • processing_type: How to process the video
    • full-video: Process the entire video at once; useful for quickly processing a single video
    • by-scene: Process each scene separately; useful for processing a video with varying borders and content
  • output_type: What to return
    • metadata: Just detection results as a dictionary
    • cropped-video: Cropped video file
    • cropped-video-and-metadata: Both cropped video and detection results as a tuple

Outputs

The tool provides detailed analysis of each video including:

  • Border dimensions (top, bottom, left, right)
  • Border colors in RGB format
  • Original and cropped aspect ratios
  • Percentage of frame being cropped

Pricing

The pricing is based on the duration of the processed video and the resolution. Here's the breakdown:

OperationStandard Resolution4K or Higher Resolution
Metadata Only (metadata)$0.01 per minute$0.02 per minute
Cropped Video (cropped-video)$0.05 per minute$0.10 per minute
Cropped Video and Metadata (cropped-video-and-metadata)$0.05 per minute$0.10 per minute

When using scene-based processing (by-scene mode), an additional scene detection cost is added:

Scene DetectionStandard Resolution4K or Higher Resolution
Cost per minute$0.02$0.04

For example, processing a 10-minute 1080p video with scene-based detection and cropping would cost:

  • Scene detection: $0.02 × 10 = $0.20
  • Video cropping: $0.05 × 10 = $0.50
  • Total: $0.70

Note: 4K resolution is defined as 3840x2160 pixels or higher. The pricing is automatically adjusted based on the input video's resolution.

Output Payload Structure

When processing a video, the detection function returns a detailed dictionary with the following structure:

{
  "video": {
    "original_width_px": 640,      // Original frame width in pixels
    "original_height_px": 360,     // Original frame height in pixels
    "original_aspect_ratio": "16/9" // Original aspect ratio as a fraction
  },
  "bar_info": {
    "left": {
      "width": 54,                // Width of left black bar in pixels
      "type": "pillarbox",        // Type of this specific bar
      "color": [0, 0, 0]          // Color of the bar in RGB format
    },
    "right": {
      "width": 52,                // Width of right black bar in pixels
      "type": "pillarbox",        // Type of this specific bar
      "color": [0, 0, 0]          // Color of the bar in RGB format
    },
    "top": {
      "height": 0,                // Height of top black bar in pixels
      "type": "none",             // No bar detected on this side
      "color": null               // No color if no bar detected
    },
    "bottom": {
      "height": 0,                // Height of bottom black bar in pixels
      "type": "none",             // No bar detected on this side
      "color": null               // No color if no bar detected
    }
  },
  "crop_info": {
    "width_px": 534,              // Width of cropped video in pixels
    "height_px": 360,             // Height of cropped video in pixels
    "aspect_ratio": "89/60",      // Cropped aspect ratio as a fraction
    "percentage_removed": 16.6    // Percentage of frame area being removed by crop
  },
  "summary": "Pillarbox detected, covering 16.6% of frame area" // Human-readable summary
}

When processing by scene, the output also includes scene information:

{
  // ... all fields above ...
  "scene_info": {
    "scene_index": 0,            // Index of the scene
    "start_time": 0.0,           // Start time in seconds
    "end_time": 5.0,             // End time in seconds
    "start_frame": 0,            // Start frame number
    "end_frame": 150             // End frame number
  }
}