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 VideoResizeAspectRatioMapper

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

Overview

Concrete tool for resizing videos to fit within an aspect ratio range provided by Data-Juicer.

Description

VideoResizeAspectRatioMapper is a mapper operator that resizes videos to fit within a specified aspect ratio range (min and max), adjusting dimensions to enforce consistent proportions across a video dataset. It calculates the current aspect ratio (width/height), compares it against configurable min/max ratio bounds (specified as fraction strings like "9/21"), and applies either an "increase" or "decrease" strategy to scale the appropriate dimension using FFmpeg, ensuring output dimensions are even numbers for codec compatibility.

Usage

Use when you need to ensure consistent aspect ratios across video datasets, which is critical for batch training of video generation and understanding models that require uniform input dimensions.

Code Reference

Source Location

Signature

@OPERATORS.register_module("video_resize_aspect_ratio_mapper")
class VideoResizeAspectRatioMapper(Mapper):
    def __init__(self, min_ratio: str = "9/21", max_ratio: str = "21/9", strategy: str = "increase", save_dir: str = None, *args, **kwargs):

Import

from data_juicer.ops.mapper.video_resize_aspect_ratio_mapper import VideoResizeAspectRatioMapper

I/O Contract

Inputs

Name Type Required Description
min_ratio str No Minimum aspect ratio as fraction string, e.g. "9/21" or "9:21" (default: "9/21")
max_ratio str No Maximum aspect ratio as fraction string, e.g. "21/9" or "21:9" (default: "21/9")
strategy str No Resizing strategy: "increase" or "decrease" (default: "increase")
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 aspect-ratio-adjusted video file paths

Usage Examples

process:
  - video_resize_aspect_ratio_mapper:
      min_ratio: "9/16"
      max_ratio: "16/9"
      strategy: "increase"

Related Pages

Page Connections

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