Skip to main content
Endpoint: POST https://fal.run/fal-ai/birefnet/v2/video Endpoint ID: fal-ai/birefnet/v2/video

Try it in the Playground

Run this model interactively with your own prompts.

Quick Start

import fal_client

def on_queue_update(update):
    if isinstance(update, fal_client.InProgress):
        for log in update.logs:
           print(log["message"])

result = fal_client.subscribe(
    "fal-ai/birefnet/v2/video",
    arguments={
        "video_url": "https://storage.googleapis.com/falserverless/example_inputs/birefnet-video-input.mp4"
    },
    with_logs=True,
    on_queue_update=on_queue_update,
)
print(result)

Input Schema

model
ModelEnum
default:"General Use (Light)"
Model to use for background removal. The ‘General Use (Light)’ model is the original model used in the BiRefNet repository. The ‘General Use (Light 2K)’ model is the original model used in the BiRefNet repository but trained with 2K images. The ‘General Use (Heavy)’ model is a slower but more accurate model. The ‘Matting’ model is a model trained specifically for matting images. The ‘Portrait’ model is a model trained specifically for portrait images. The ‘General Use (Dynamic)’ model supports dynamic resolutions from 256x256 to 2304x2304. The ‘General Use (Light)’ model is recommended for most use cases.The corresponding models are as follows:
  • ‘General Use (Light)’: BiRefNet
  • ‘General Use (Light 2K)’: BiRefNet_lite-2K
  • ‘General Use (Heavy)’: BiRefNet_lite
  • ‘Matting’: BiRefNet-matting
  • ‘Portrait’: BiRefNet-portrait
  • ‘General Use (Dynamic)’: BiRefNet_dynamic Default value: "General Use (Light)"
Possible values: General Use (Light), General Use (Light 2K), General Use (Heavy), Matting, Portrait, General Use (Dynamic)
operating_resolution
OperatingResolutionEnum
default:"1024x1024"
The resolution to operate on. The higher the resolution, the more accurate the output will be for high res input images. The ‘2304x2304’ option is only available for the ‘General Use (Dynamic)’ model. Default value: "1024x1024"Possible values: 1024x1024, 2048x2048, 2304x2304
output_mask
boolean
default:"false"
Whether to output the mask used to remove the background
refine_foreground
boolean
default:"true"
Whether to refine the foreground using the estimated mask Default value: true
sync_mode
boolean
default:"false"
If True, the media will be returned as a data URI and the output data won’t be available in the request history.
video_url
string
required
URL of the video to remove background from
video_output_type
VideoOutputTypeEnum
default:"X264 (.mp4)"
The output type of the generated video. Default value: "X264 (.mp4)"Possible values: X264 (.mp4), VP9 (.webm), PRORES4444 (.mov), GIF (.gif)
video_quality
VideoQualityEnum
default:"high"
The quality of the generated video. Default value: "high"Possible values: low, medium, high, maximum
video_write_mode
VideoWriteModeEnum
default:"balanced"
The write mode of the generated video. Default value: "balanced"Possible values: fast, balanced, small

Output Schema

video
VideoFile
required
Video with background removed
mask_video
VideoFile
Mask used to remove the background

Input Example

{
  "model": "General Use (Light)",
  "operating_resolution": "1024x1024",
  "output_mask": false,
  "refine_foreground": true,
  "sync_mode": false,
  "video_url": "https://storage.googleapis.com/falserverless/example_inputs/birefnet-video-input.mp4",
  "video_output_type": "X264 (.mp4)",
  "video_quality": "high",
  "video_write_mode": "balanced"
}

Output Example

{
  "video": {
    "content_type": "video/webm",
    "duration": 8,
    "file_name": "birefnet-video-output.webm",
    "fps": 24,
    "height": 1080,
    "num_frames": 192,
    "url": "https://storage.googleapis.com/falserverless/example_outputs/birefnet-video-output.webm",
    "width": 1920
  }
}

Limitations

  • model restricted to: General Use (Light), General Use (Light 2K), General Use (Heavy), Matting, Portrait, General Use (Dynamic)
  • operating_resolution restricted to: 1024x1024, 2048x2048, 2304x2304
  • video_output_type restricted to: X264 (.mp4), VP9 (.webm), PRORES4444 (.mov), GIF (.gif)
  • video_quality restricted to: low, medium, high, maximum
  • video_write_mode restricted to: fast, balanced, small