AWS Machine Learning Blog · 2026/10/20 00:49:19

TwelveLabs Pegasus 1.5 上线 Bedrock 支持视频结构化检索

出处作者 / 发布主体:Ron Tal原标题:Pegasus 1.5 from TwelveLabs is now available in Amazon Bedrock
68AI 研判分
核心综述

TwelveLabs 的视频语言模型 Pegasus 1.5 正式登陆 Amazon Bedrock。该版本实现了从长视频中自动提取带时间戳的结构化元数据,支持无需预索引的直接分析、多模态提示及实时处理,显著降低了视频内容检索与理解的工程门槛。

报道全文原始报道全文

本文目录12 个章节

2026 年 10 月 9 日,我们宣布 TwelveLabs 的 Pegasus 1.5 现已在 Amazon Bedrock 上可用。Pegasus 1.5 是一款视频语言模型,能够将长视频转换为带有时间戳的结构化元数据。您只需描述工作流中重要的时刻,模型便会以 JSON 格式返回所有匹配的片段。

视频是一种重要且复杂的非结构化数据类别,但其中大部分内容仍然无法搜索且未被充分利用。从历史上看,要从这类内容中提取结构化、可操作的洞察信息,通常需要耗费大量人力进行手动审查或使用碎片化的工具链。

在早期版本的 Pegasus 中,您可以将模型指向某个剪辑,提出问题并获得答案。而现在,Pegasus 1.5 能够分析整个视频,找出所有符合用户定义标准的片段,并返回带时间戳的结构化元数据。此外,它还引入了视频分割、结合参考图像的多模态提示以及即时处理功能。

通过 Amazon Bedrock 上的 Pegasus 1.5,您可以直接从 Amazon Simple Storage Service (Amazon S3) URI 或 base64 字符串分析视频,无需预先建立索引,并且您的数据始终保留在 AWS 数据边界内。

在这篇文章中,我们将介绍 Pegasus 1.5 的新特性、该模型在 Amazon Bedrock 上的打包方式,以及如何发送第一个请求。随后,我们将详细讲解视频分割、结构化 JSON 输出和多模态提示。

Pegasus 1.5 的新特性

与之前的版本相比,Pegasus 1.5 具有以下变化:

  • 基于时间的元数据生成。 您可以定义对工作流至关重要的片段、事件或领域特定线索,例如编辑片段、体育比赛动作、说话人变更或品牌出现。Pegasus 1.5 会以 JSON 格式返回所有匹配的片段,包含开始和结束时间,并填充所请求的字段。
  • 多模态提示。 片段定义可以将文本描述与视觉参考相结合。这使得定位特定产品、标志或人物成为可能,同时还能识别他们在屏幕上的行为。
  • 即时处理。 无需摄取管道或预索引步骤。视频直接从 Amazon S3 发送,结果在响应中返回。
  • 扩展的处理容量。 Pegasus 1.5 可在单次请求中分析长达两小时的视频,而 Pegasus 1.2 仅支持一小时。

Pegasus 1.5 保留并增强了使 Pegasus 1.2 成为强大视频理解工具的核心能力,包括:

  • 视频转文本生成:根据视频内容创建详细的文本描述。
  • 细粒度视觉理解:分析视频帧中的物体、屏幕文字和数值内容。
  • 时间定位:准确识别视频中特定事件的时间戳。
  • 多模态理解:结合视觉、音频和文本信息进行综合分析。
  • 多语言支持:全面支持英语,部分支持阿拉伯语、中文、法语、德语、意大利语、日语、韩语、葡萄牙语、俄语、西班牙语、泰语和越南语。

Pegasus 1.5 在 Amazon Bedrock 上的工作原理

Pegasus 1.5 接收一段视频以及一个文本提示词或一组片段定义,并返回文本或 JSON。你可以通过 bedrock-runtime 端点调用 InvokeModel API 来使用它;如果你希望响应在生成过程中以流式方式返回,则可以使用 InvokeModelWithResponseStream。

设置项值
模型 IDtwelvelabs.pegasus-1-5-v1:0
AWS 区域美国西部(俄勒冈),us-west-2
推理模式按需
APIInvokeModel, InvokeModelWithResponseStream

每个请求会在两种分析模式之一中运行,通过 analysisMode 字段进行选择:

分析模式analysisMode你发送的内容你收到的结果
通用general(默认)inputPrompt 中的文本提示词message 中的文本回答,或在提供 schema 时返回 JSON
基于时间的元数据time_based_metadataresponseFormat 中的片段定义包含开始和结束时间以及你所请求字段的 segments 列表

你可以通过两种方式指定视频源。S3 位置(s3Location)需要对象的 uri 和 bucketOwner 账户 ID,适用于长视频。Base64 字符串(base64String)将视频嵌入请求体中,最大支持 25 MB,适用于短片段。

为了按应用程序跟踪成本,你可以从 Pegasus 1.5 模型创建一个应用推理配置文件(application inference profile),为其添加标签,并在调用时使用其 Amazon Resource Name (ARN) 代替模型 ID。

Pegasus 1.5 入门指南

以下章节概述了如何开始使用 Pegasus 1.5。

先决条件

在开始之前,请确保你已具备:

  1. 一个已启用 Amazon Bedrock 访问权限的活跃 AWS 账户。
  2. Python 3.10 或更高版本,并已安装适用于 Python 的 AWS SDK (Boto3)。
  3. 拥有 bedrock:InvokeModel 和 bedrock:InvokeModelWithResponseStream 的 AWS Identity and Access Management (IAM) 权限。
  4. 在 Amazon Bedrock 控制台中为 TwelveLabs Pegasus 1.5 启用了模型访问权限。
  5. 视频存储在 Amazon S3 存储桶中,或者您可以发送内联的短视频片段。

以下策略授予对 Pegasus 1.5 执行两种调用操作的权限。

JSON
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "bedrock:InvokeModel",
                "bedrock:InvokeModelWithResponseStream"
            ],
            "Resource": [
                "arn:aws:bedrock:us-west-2::foundation-model/twelvelabs.pegasus-1-5-v1:0"
            ]
        }
    ]
}

Boto3 使用您常规的 AWS 凭证对请求进行签名。您也可以通过设置 AWS_BEARER_TOKEN_BEDROCK 环境变量,使用 Amazon Bedrock API 密钥进行身份验证。在生产环境中,建议使用 aws-bedrock-token-generator 包从您的 IAM 凭证生成短期密钥,因为它会自动过期。Bearer 令牌身份验证还需要 bedrock:CallWithBearerToken 权限。

发送您的第一个请求

安装 Boto3:

BASH
pip install boto3

以下示例以通用模式分析存储在 Amazon S3 中的视频。此示例使用全局跨区域推理 (CRIS) 端点。若要改为针对美国地理端点,请将端点 URL 中的 “global.” 替换为 “us.”。

PYTHON
import boto3
import json
from botocore.config import Config

AWS_REGION = "us-west-2"
MODEL_ID = "global.twelvelabs.pegasus-1-5-v1:0"

bedrock_runtime = boto3.client(
    service_name="bedrock-runtime",
    region_name=AWS_REGION,
    config=Config(
        # keep a longer read_timeout for lengthier invocations such as video segmentation
        read_timeout=900,
        retries={"max_attempts": 0},
        connect_timeout=10,
    ),
)

# Analyze a video stored in Amazon S3
payload = {
    "inputPrompt": "Summarize this video and identify the key topics discussed.",
    "mediaSource": {
        "s3Location": {
            "uri": "s3://amzn-s3-demo-pegasus-15/your-video.mp4",
            "bucketOwner": "your-account-id"
        }
    },
    "temperature": 0.2,
    "maxOutputTokens": 4096,
    "includeMetering": True
}

response = bedrock_runtime.invoke_model( modelId=MODEL_ID, body=json.dumps(payload) ) result = json.loads(response["body"].read()) print(result["message"])

文本

响应在 `message` 字段中携带答案,在 `input_tokens` 和 `output_tokens` 字段中携带 token 计数,并在 `stopReason` 字段中说明生成结束的原因。如果 `stopReason` 为 `length`,则表示答案在未完成之前达到了 `maxOutputTokens` 限制,因此在依赖输出结果之前请检查此字段:

```python
if result["stopReason"] == "length":
    print("The answer was cut off. Raise maxOutputTokens and try again.")
print("Tokens in:", result["input_tokens"], "out:", result["output_tokens"])

通用模式下的请求字段:

字段是否必需描述
inputPrompt是关于视频的问题或指令
mediaSource.s3Location.uri需要一种视频源视频的 S3 URI
mediaSource.s3Location.bucketOwner与 uri 一起使用拥有该存储桶的 AWS 账户 ID
mediaSource.base64String需要一种视频源Base64 编码的视频,最大 25 MB
temperature否输出的随机性,范围从 0 到 1。默认值为 0.2
maxOutputTokens否生成的最大 token 数,范围从 512 到 98,304
responseFormat否答案必须遵循的 JSON Schema
analysisMode否general(默认)或 time_based_metadata

对于短视频片段,你可以直接内联发送视频,而不是从 S3 获取:

PYTHON
import base64

with open("your-video.mp4", "rb") as f:
    video_b64 = base64.b64encode(f.read()).decode("utf-8")

payload["mediaSource"] = {"base64String": video_b64}
response = bedrock_runtime.invoke_model(modelId=MODEL_ID, body=json.dumps(payload))
print(json.loads(response["body"].read())["message"])

请注意,上述示例使用了可选属性 includeMetering。设置 includeMetering: True 会使 Pegasus 1.5 在非流式响应中添加两个计费用量字段:outputTokenCount 和 inputVideoSecond(即所分析视频的时长,单位为秒)。

流式传输响应

对于交互式应用程序,InvokeModelWithResponseStream 会在生成答案时以块的形式返回结果。每个块都在 message 字段中携带下一段文本:

PYTHON
response = bedrock_runtime.invoke_model_with_response_stream(
    modelId=MODEL_ID,
    body=json.dumps(payload)
)
for event in response["body"]:
    chunk = json.loads(event["chunk"]["bytes"])
    print(chunk.get("message", ""), end="", flush=True)
print()

返回结构化 JSON

在通用模式下,你可以将回答约束为 JSON Schema,以便下游代码直接解析。将 responseFormat.type 设置为 json_schema,并将 schema 放在 jsonSchema 下。回答将以 JSON 字符串的形式出现在 message 中:

PYTHON
payload = {
    "inputPrompt": "Analyze this video and return a structured summary.",
    "mediaSource": {
        "s3Location": {
            "uri": "s3://amzn-s3-demo-pegasus-15/your-video.mp4",
            "bucketOwner": "your-account-id"
        }
    },
    "temperature": 0,
    "maxOutputTokens": 2048,
    "includeMetering": True,
    "responseFormat": {
        "type": "json_schema",
        "jsonSchema": {
            "type": "object",
            "properties": {
                "summary": {"type": "string"},
                "key_scenes": {"type": "array", "items": {"type": "string"}},
                "setting": {"type": "string"}
            },
            "required": ["summary", "key_scenes", "setting"]
        }
    }
}
response = bedrock_runtime.invoke_model(modelId=MODEL_ID, body=json.dumps(payload))
summary = json.loads(json.loads(response["body"].read())["message"])
print(summary["summary"])
for scene in summary["key_scenes"]:
    print(" -", scene)

视频分段:将视频转换为结构化数据

基于时间的元数据生成是 Pegasus 1.5 与早期版本差异最大的地方。你不再发送提示词(prompt),而是发送一个或多个分段定义,模型会返回视频中符合每个定义的每一个分段。

将 analysisMode 设置为 time_based_metadata,并将 responseFormat.type 设置为 segment_definitions。这些定义取代了 inputPrompt,因此请省略该字段。每个定义包含:

  • id:定义的名称,会在其匹配的每个分段上返回。
  • description:匹配分段的特征描述。
  • fields:要为每个分段提取的值,每个值都包含一个 name、一个 type(string、boolean、number、integer、array 或 timestamp)以及一个 description。

以下示例识别新闻广播中的每个编辑部分,并为每个部分返回标题、摘要和关键主题:

PYTHON
payload = {
    "analysisMode": "time_based_metadata",
    "mediaSource": {
        "s3Location": {
            "uri": "s3://amzn-s3-demo-pegasus-15/news-broadcast.mp4",
            "bucketOwner": "your-account-id"
        }
    },
    "responseFormat": {
        "type": "segment_definitions",
        "segmentTimeFormat": "hh:mm:ss",
        "segmentDefinitions": [
            {
                "id": "editorial_section",
                "description": "A distinct editorial section of the broadcast, "
                "such as a new story, topic, or segment of the program.",
                "fields": [
                    {"name": "segment_title", "type": "string",
                     "description": "A descriptive title"},
                    {"name": "summary", "type": "string",
                     "description": "A brief summary of the segment content"},
                    {"name": "key_topics", "type": "array", "items": {"type": "string"},
                     "description": "Main topics discussed"}
                ]
            }
        ]
    },
    "temperature": 0,
    "maxOutputTokens": 32768,
    "includeMetering": True
}
response = bedrock_runtime.invoke_model(
    modelId=MODEL_ID,
    contentType="application/json",
    accept="application/json",
    body=json.dumps(payload)
)
result = json.loads(response["body"].read())
for segment in result["segments"]:
    print(segment["start_sec"], "-", segment["end_sec"], segment["segment_title"])
    print(" ", segment["summary"])
    print(" topics:", ", ".join(segment["key_topics"]))

上述示例代码在针对体育视频片段进行测试时,可能会产生如下所示的输出结果。

JSON
{
    "segments": [
        {
            "start_sec": "00:04:24",
            "end_sec": "00:05:22",
            "segment_title": "换人与补时",
            "summary": "裁判宣布补时三分钟,双方球队进行换人调整,为可能到来的点球大战做准备。",
            "key_topics": ["换人", "补时", "点球大战准备", "战术调整"]
        },
        {
            "start_sec": "00:05:22",
            "end_sec": "00:08:57",
            "segment_title": "最后时刻的尝试与终场哨声",
            "summary": "比赛最后几分钟双方展开激烈对抗,多次出现险些破门的机会,最终裁判吹响终场哨,比赛以 3-3 平局收场。",
            "key_topics": ["终场哨", "平局"]
        },
        {
            "start_sec": "00:08:57",
            "end_sec": "00:09:29",
            "segment_title": "比赛结束与点球大战准备",
            "summary": "比赛以 3-3 平局告终,进入点球大战环节。双方球员握手致意,并为决定胜负的关键时刻做好准备。",
            "key_topics": ["比赛结束", "点球大战", "球员握手", "决赛"]
        }
    ],
    "definition_errors": [],
    "input_tokens": 249408,
    "output_tokens": 802,
    "stopReason": "stop",
    "finish_reason": "stop"
}

每个片段都包含 start_sec、end_sec 以及你定义的 fields。segmentTimeFormat 参数控制时间格式的写法:设置为 seconds 时返回可用于算术运算的数字,而设置为 hh:mm:ss 或 hh:mm:ss.fff 时则返回可读性更强的字符串格式时间戳。响应中还包含一个 definition_errors 列表,当所有定义均成功处理时,该列表为空。

单个请求可以包含多个片段定义,例如一个用于编辑章节,另一个用于屏幕上的品牌露出。Pegasus 1.5 会在一个 segments 列表中返回所有匹配的片段,并为每个片段标记 _definition_id,以便区分来源。以下示例在前一个请求的基础上添加了第二个定义,并对结果进行了分组:

PYTHON
from collections import defaultdict

payload["responseFormat"]["segmentDefinitions"].append({ "id": "brand_appearance", "description": "A shot where a company logo or branded product " "is clearly visible on screen.", "fields": [ {"name": "brand", "type": "string", "description": "The brand shown"}, {"name": "is_prominent", "type": "boolean", "description": "Whether the brand is the main focus of the shot"} ] }) response = bedrock_runtime.invoke_model(modelId=MODEL_ID, body=json.dumps(payload)) result = json.loads(response["body"].read()) by_definition = defaultdict(list) for segment in result["segments"]: by_definition[segment["_definition_id"]].append(segment) for definition_id, segments in by_definition.items(): print(definition_id, len(segments), "segments")

文本

由于 schema 只需定义一次,相同的定义即可应用于整个视频库,从而为每个资产生成一致的元数据。

### 多模态提示:为查询添加视觉上下文

Pegasus 1.5 引入了多模态提示功能,允许你在文本提示中附带参考图像。当你希望询问模型关于特定物体、人物或场景的问题时,这非常有用,因为展示往往比描述更直观。

例如,你可以提供一张产品图片,要求模型识别视频中该产品出现的每一个时刻。或者,你可以提供特定 Logo 的参考图像,要求模型检测品牌露出及其时间戳。这一能力提升了视频分析的精度,并开启了诸如视觉品牌监控、植入广告分析以及基于图像的引导式内容搜索等应用场景。

参考图像的附加方式因模式而异。在通用模式下,将它们放在 `promptV2.mediaSources` 中,与 `promptV2.inputText` 中的问题并列。在分段模式(`analysisMode: time_based_metadata`)下,将它们附加到 `responseFormat.segmentDefinitions` 中每个分段定义的 `mediaSources` 上。这样,一个定义既可以匹配视觉参考,也可以匹配文本描述。每张图像需要一个 `name`、一个值为 `image` 的 `media_type`,以及恰好一个来源:要么是内联的 `base64String`,要么是包含 `uri` 和 `bucketOwner` 的 `s3Location`。单个请求最多可携带 30 张参考图像。

通用模式的请求会就参考图像中显示的物体向模型提问。以下示例 payload 和响应展示了通用模式下的用法。

```python
payload = {
    "analysisMode": "general",
    "mediaSource": {"s3Location": {"uri": "s3://...", "bucketOwner": "..."}},
    "promptV2": {
        "inputText": "Does the object in the reference image appear in this video?",
        "mediaSources": [
            {"name": "ref1", "media_type": "image", "base64String": "..."}
        ]
    }
    …
}
JSON
{
    "input_tokens": 144,
    "output_tokens": 11,
    "message": "Yes, the green canoe appears in the video.",
    "stopReason": "stop"
}

在分段模式(segmentation mode)下,参考图像包含在定义中,因此 Pegasus 仅返回该产品出现的片段。以下示例载荷和响应展示了分段模式的用法。

PYTHON
payload = {
    "analysisMode": "time_based_metadata",
    "mediaSource": {"s3Location": {"uri": "s3://...", "bucketOwner": "..."}},
    "responseFormat": {
        "type": "segment_definitions",
        "segmentTimeFormat": "hh:mm:ss",
        "segmentDefinitions": [
            {
                "id": "product_appearance",
                "description": "A shot showing the product in the reference image",
                "fields": [
                    {"name": "what", "type": "string", "description": "what is on screen"}
                ],
                "mediaSources": [
                    {"name": "ref1", "media_type": "image",
                     "s3Location": {"uri": "s3://...", "bucketOwner": "..."}}
                ]
            }
        ]
    }
}
JSON
{
    "segments": [
        {"start_sec": "00:00:00", "end_sec": "00:00:02",
         "what": "A family of four in a green canoe, paddling on a calm river surrounded by towering red rock formations."},
        {"start_sec": "00:00:09", "end_sec": "00:00:10",
         "what": "The family back in the canoe, paddling away from the shore, with the children smiling and enjoying the serene surroundings."}
    ],
    "definition_errors": [],
    "input_tokens": 4498,
    "output_tokens": 292,
    "stopReason": "stop",
    "finish_reason": "stop"
}

监控使用情况

Pegasus 1.5 会在 AWS/Bedrock 命名空间下发布 Amazon CloudWatch 指标,并以其模型 ID 进行标识,包括 Invocations、OutputTokenCount、InvocationLatency 和 InvocationClientErrors。您可以利用这些指标来跟踪调用量和延迟情况。当需要按应用程序细分使用情况时,请将其与应用推理配置文件(application inference profiles)配合使用。

用例

Pegasus 1.5 专为管理大量长视频内容的组织而设计:

  • 新闻与广播档案:团队可以一次性定义编辑片段、主题和发言人变更,从而对过去仅能通过转录关键词搜索的多年素材进行编目。
  • 体育转播商与联赛:在完整比赛录像中检测战术动作、得分事件及其他关键时刻,加速精彩集锦的制作。
  • 流媒体应用:场景级元数据支持基于时刻的推荐、情境化广告投放以及片段级的品牌安全审查。

在上述每种场景中,人员仍保留在工作流程中。他们的工作重心从手动查找和标记每一个时刻,转变为审核和优化由模型生成的元数据。

输入要求

Pegasus 1.5 支持以下视频规格:

  • 时长:最长 2 小时。
  • 文件大小:来自 Amazon S3 的文件最大为 2 GB,或以 base64 字符串形式传入时最大为 25 MB。
  • 分辨率:360×360 至 5184×2160。
  • 宽高比:介于 1 到 2.4 之间,或其倒数。
  • 格式:FFmpeg 支持的格式。

现已可用

TwelveLabs Pegasus 1.5 今日已在 Amazon Bedrock 的美国西部(俄勒冈)AWS 区域上线。请查阅完整区域列表以获取未来更新信息,并访问 Amazon Bedrock 定价页面了解价格详情。Pegasus 1.5 通过 AWS Marketplace 计费,因此相关费用将显示在你的 AWS 账单及 AWS Cost Explorer 中的 TwelveLabs 名下,而非 Amazon Bedrock。

开始使用:

我们非常期待看到你在 Amazon Bedrock 上使用 TwelveLabs Pegasus 1.5 构建出什么成果。


TwelveLabs Pegasus 1.5 上线 Bedrock 支持视频结构化检索 | Today for AI