跳到主要内容
Vane Data / API 参考

read_video_frames

read_video_frames 把选中的帧按行流式输出,data: IMAGE('RGB', image_height, image_width)。它返回 Relation,每帧一行,而不是每个输入一行。

签名

example.py
vane.read_video_frames(
    path, image_height, image_width, is_key_frame=None,
    *, sample_interval_seconds=None, start_time=0, end_time=None,
    max_input_bytes=8589934592, max_decoded_frames=1000000, max_pixels=33554432,
    max_partition_bytes=10485760, frame_limit=None, read_task_count=None,
    on_error="raise", indexes=None, connection=None,
) -> Relation

SQL:read_video_frames(source, height, width [, is_key_frame], start_time => ..., ...)。

参数

名称类型说明默认值
path路径字符串、os.PathLike、FILE/VIDEOFILE 值或其列表精确的输入路径或 FILE 视图;不支持目录或 glob 发现必填
image_height / image_width正整数输出帧尺寸;data 为 IMAGE('RGB', H, W)必填
is_key_framebool 或 NoneTrue 只选关键帧,False 只选非关键帧,None 不按关键帧标记筛选None
sample_interval_seconds数值或 None时间戳达到下一个间隔点时输出帧None
start_time / end_time数值相对流起始的闭区间时间窗口(秒)0 / None
max_input_bytes整数编码逻辑视图上限8 GiB(上限 16 GiB)
max_decoded_frames整数每文件解码上限(含被过滤帧)1,000,000
max_pixels整数输入与输出像素上限32 Mi 像素
max_partition_bytes整数硬性单批输出负载预算10 MiB(上限 256 MiB)
frame_limit整数或 None全局有序帧上限;使用单个有序工作单元None
read_task_count整数或 None本地任务和 Ray 切分的均衡文件分组数,上限为文件数默认每文件一组
on_error"raise" / "skip""skip" 只抑制编码格式失败"raise"
indexes索引 BLOB 列表或 None已验证的关键帧寻址索引,每个输入一份None
connection连接或 None执行扫描的查询会话当前连接

返回值与错误

每选中一帧一行:path、原始 file 视图、frame_index、frame_time、时间基与时间戳字段(frame_pts、frame_dts、frame_duration)、is_key_frame 和 data。顶层的 NULL/None 或空列表返回具有声明 schema 的空表;列表中的 NULL 元素和其他 FILE 子类型会直接报错。绑定时校验参数,不打开视频。跨文件任务的行顺序不保证,需要时用 ORDER BY。

示例

example.py
import vane


con = vane.connect()
frames = vane.read_video_frames(
    "clip.mp4", 224, 224,
    start_time=1, end_time=5, sample_interval_seconds=0.5,
    connection=con,
)
frames.select("path", "frame_index", "frame_time", "data").show()

来源与相关页面