You need to enable JavaScript to run this app.
Lake AI Service

Lake AI Service

Copy page
Download PDF
Video processing
Video metadata extraction
Copy page
Download PDF
Video metadata extraction

Operator introduction

Description

Video metadata extraction operator

Key features

  • Supports multiple video file formats
  • Extracts complete video metadata information
  • Uses the ffprobe tool for metadata extraction
  • Supports local files, remote files (TOS/S3), and HTTP/HTTPS links

Extracted information

  • Basic information: duration, format, bitrate
  • Video information: resolution, frame rate, encoder
  • Audio information: sample rate, number of channels, encoder

Daft invocation

Operator parameters

Input

Input column name

Note

input_col

Array of input file paths

Output

Array of structs containing metadata

Parameters

If a parameter does not have a default value, it is required

Parameter name

Type

Default value

Description

timeout

int or None

None

Timeout for executing the ffprobe command (in seconds). The default is None (no timeout).

Examples

The following code demonstrates how to use Daft (in distributed environments) to run the operator and extract metadata information from video files.

from __future__ import annotations

import os

import daft
from daft import col
from daft.las.functions.udf import las_udf
from daft.las.functions.video import VideoExtractMetadata

if __name__ == "__main__":
    TOS_TEST_DIR_URL = os.getenv("TOS_TEST_DIR_URL", "las-cn-beijing-public-online.tos-cn-beijing.volces.com")

    if os.getenv("DAFT_RUNNER", "native") == "ray":
        import logging

        import ray

        def configure_logging():
            logging.basicConfig(
                level=logging.INFO,
                format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
                datefmt="%Y-%m-%d %H:%M:%S",
            )
            logging.getLogger("tracing.span").setLevel(logging.WARNING)
            logging.getLogger("daft_io.stats").setLevel(logging.WARNING)
            logging.getLogger("DaftStatisticsManager").setLevel(logging.WARNING)
            logging.getLogger("DaftFlotillaScheduler").setLevel(logging.WARNING)
            logging.getLogger("DaftFlotillaDispatcher").setLevel(logging.WARNING)

        ray.init(dashboard_host="0.0.0.0", runtime_env={"worker_process_setup_hook": configure_logging})
        daft.set_runner_ray()

    daft.set_execution_config(actor_udf_ready_timeout=600)
    daft.set_execution_config(min_cpu_per_task=0)

    samples = {
        "input_path": [
            f"https://{TOS_TEST_DIR_URL}/public/archive/video_extract_metadata/music_sample.mp4",
        ],
    }
    ds = daft.from_pydict(samples)

    # Using Daft to extract video metadata
    constructor_kwargs = {
        "timeout": 600,
    }

    ds = ds.with_column(
        "metadata",
        las_udf(
            VideoExtractMetadata,
            construct_args=constructor_kwargs,
            num_cpus=1,
            concurrency=1,
            batch_size=1,
        )(col("input_path")),
    )

    ds.show()
    # ╭────────────────────────────────┬─────────────────────────────────────────────────────╮
    # │ input_path                     ┆ metadata                                            │
    # │ ---                            ┆ ---                                                 │
    # │ Utf8                           ┆ Struct                                              │
    # ╞════════════════════════════════╪═════════════════════════════════════════════════════╡
    # │ https://las-public-data-qa.to… ┆ {duration: 7.367, format_name: "mov,mp4,m4a,3gp... │
    # ╰────────────────────────────────┴─────────────────────────────────────────────────────╯
Last updated: 2026.05.12 19:06:35