You need to enable JavaScript to run this app.
AI 数据湖服务

AI 数据湖服务

复制全文
视频处理
视频音频检测
复制全文
视频音频检测

算子介绍

描述

视频音频检测处理器

特点

  • 使用 ffprobe 检测视频中是否存在音频流
  • 自动下载远程文件
  • 支持超时控制
  • 支持多种视频格式
  • 返回布尔值表示是否存在音频

Daft 调用

算子参数

输入

输入列名

说明

input_col

输入视频路径数组

输出

布尔值数组,True 表示存在音频,False 表示不存在,None 表示检测失败

参数

如参数没有默认值,则为必填参数

参数名称

类型

默认值

描述

timeout

int or None

None

ffprobe执行超时时间(秒) 默认值:None(无超时)

调用示例

下面的代码展示了如何使用 Daft(适用于分布式)运行算子检测视频中是否存在音频。

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.context.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     │
    # ╰────────────────────────────────┴───────────╯
最近更新时间:2026.01.08 19:14:20
这个页面对您有帮助吗?
有用
有用
无用
无用