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

Lake AI Service

Copy page
Download PDF
Video processing
Video and audio detection
Copy page
Download PDF
Video and audio detection

Operator introduction

Description

Video and audio detection processor

Features

  • Uses ffprobe to detect whether an audio stream exists in the video
  • Automatically downloads remote files
  • Supports timeout control
  • Supports multiple video formats
  • Returns a boolean value indicating whether audio exists

Daft usage

Operator parameters

Input

Input column name

Note

input_col

Array of input video paths

Output

Boolean array: True indicates audio exists, False indicates no audio, None indicates detection failed

Parameters

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

Parameter name

Type

Default value

Description

timeout

int or None

None

ffprobe execution timeout (seconds). Default value: None (no timeout)

Examples

The following code demonstrates how to use Daft in distributed scenarios to run the operator to detect whether audio exists in a video.

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 VideoDetectAudio

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_detect_audio/music_sample.mp4",
            f"https://{TOS_TEST_DIR_URL}/public/archive/video_detect_audio/music_sample_no_audio.mp4",
        ],
    }
    ds = daft.from_pydict(samples)

    # Using Daft to detect audio in video
    constructor_kwargs = {
        "timeout": 600,
    }

    ds = ds.with_column(
        "has_audio",
        las_udf(VideoDetectAudio, construct_args=constructor_kwargs)(col("input_path")),
    )

    ds.show()
    # ╭────────────────────────────────┬───────────╮
    # │ input_path                     ┆ has_audio │
    # │ ---                            ┆ ---       │
    # │ String                         ┆ Bool      │
    # ╞════════════════════════════════╪═══════════╡
    # │ https://las-public-data-qa.to… ┆ true      │
    # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┤
    # │ https://las-public-data-qa.to… ┆ false     │
    # ╰────────────────────────────────┴───────────╯
Last updated: 2026.05.22 11:05:10