Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Datajuicer Data juicer VideoResizeResolutionMapper

From Leeroopedia
Knowledge Sources
Domains Data_Processing, Mapping
Last Updated 2026-02-14 16:00 GMT

Overview

Concrete tool for resizing video resolution based on width and height constraints provided by Data-Juicer.

Description

VideoResizeResolutionMapper is a mapper operator that resizes videos to fit within configurable minimum and maximum width and height constraints, with optional aspect ratio preservation and divisibility enforcement. It checks each video's dimensions against min/max width and height limits, computes target dimensions using FFmpeg's scale filter with optional force_original_aspect_ratio mode ("disable", "decrease", or "increase"), ensures output dimensions are divisible by a configurable integer (default: 2), and saves the resized video to the output directory.

Usage

Use when you need to normalize video resolution across datasets, ensuring videos meet the dimensional requirements of downstream training pipelines and models.

Code Reference

Source Location

Signature

@OPERATORS.register_module("video_resize_resolution_mapper")
class VideoResizeResolutionMapper(Mapper):
    def __init__(self, min_width: int = 1, max_width: int = sys.maxsize, min_height: int = 1, max_height: int = sys.maxsize, force_original_aspect_ratio: str = "disable", force_divisible_by: PositiveInt = 2, save_dir: str = None, *args, **kwargs):

Import

from data_juicer.ops.mapper.video_resize_resolution_mapper import VideoResizeResolutionMapper

I/O Contract

Inputs

Name Type Required Description
min_width int No Minimum allowed video width (default: 1)
max_width int No Maximum allowed video width (default: sys.maxsize)
min_height int No Minimum allowed video height (default: 1)
max_height int No Maximum allowed video height (default: sys.maxsize)
force_original_aspect_ratio str No Aspect ratio mode: "disable", "decrease", or "increase" (default: "disable")
force_divisible_by PositiveInt No Output dimensions must be divisible by this value (default: 2)
save_dir str No Directory for generated video files; if not specified, saves alongside input files

Outputs

Name Type Description
samples Dict Transformed samples with resolution-adjusted video file paths

Usage Examples

process:
  - video_resize_resolution_mapper:
      min_width: 480
      max_width: 1920
      min_height: 360
      max_height: 1080
      force_original_aspect_ratio: "decrease"

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment