Microsoft Foundry教程:基于fal的多模型视频生成工作流
Build a multi-model video generation workflow with fal on Microsoft Foundry
Building a compelling video experience rarely comes down to finding one model that does everything. Early in the creative process, you may want fast text-to-video generation to explore several directions. Once a composition is established, image-to-video can preserve the starting visual while adding motion. For more directed work, reference inputs can provide additional context from images, video, or audio.
构建引人入胜的视频体验,很少取决于找到一个能处理所有任务的模型。在创意过程的早期,你可能希望快速进行文本到视频的生成,以探索多个方向。一旦构图确定,图像到视频可以保留起始视觉效果并添加动态。对于更有针对性的工作,参考输入可以提供来自图像、视频或音频的额外上下文。
Fal on Microsoft Foundry brings these workflows together through a family of video generation models available from the Foundry model catalog. In this tutorial, we build a practical product-campaign workflow that starts with a creative brief and moves through text-to-video, image-to-video, and reference-to-video modalities. Along the way, we show how to select a model for each step, submit asynchronous generation jobs, monitor their status, retrieve the completed video, and structure the code so that it can be reused across models.
Fal on Microsoft Foundry 通过 Foundry 模型目录中提供的一系列视频生成模型,将这些工作流程整合在一起。在本教程中,我们构建了一个实用的产品营销活动工作流程,从创意简报开始,依次经过文本到视频、图像到视频和参考到视频的处理方式。在此过程中,我们将展示如何为每个步骤选择合适的模型、提交异步生成作业、监控其状态、检索完成的视频,以及如何组织代码以便跨模型复用。
The scenario: turn one creative brief into a coordinated campaign
场景:将一个创意简报转化为协调一致的营销活动
Imagine that a creative team is introducing a compact premium travel speaker called Northstar. The team needs three short assets:
假设一个创意团队正在推出一款名为 Northstar 的高端便携式旅行音箱。该团队需要制作三个短视频素材:
- A concept clip to test the campaign mood and visual language quickly.
- A polished hero clip that animates an approved product image.
- A campaign variation that uses reference material to reinforce the established product and audio direction.
- 一段概念短片,用于快速测试营销活动的氛围和视觉语言。
- 一段精致的核心宣传片,对已批准的产品图像进行动画化处理。
- 一段活动变体视频,使用参考资料来强化既定的产品和音频方向。
The creative brief is intentionally specific enough to guide generation while leaving room for model interpretation:
创意简报足够具体,以指导生成过程,同时为模型的解读留出空间:
Creative brief: A matte black portable speaker sits on a weathered stone ledge above a misty alpine lake at sunrise. The camera moves slowly toward the product. Soft wind moves nearby grass. The visual style is premium, cinematic, restrained, and realistic, with cool blues and warm sunrise highlights. Avoid text, logos, extra products, distorted geometry, and abrupt camera movement.
创意简报:一款哑光黑色的便携音箱放置在日出时分云雾缭绕的高山湖泊上方的风化石台上。镜头缓慢向产品推进。微风拂过附近的草地。视觉风格高端、电影感、克制且写实,色调以冷蓝色为主,辅以温暖的日出高光。避免文字、标志、多余产品、几何变形和突兀的镜头运动。
This is a useful application pattern because model choice follows the creative task instead of forcing every task through the same endpoint.
这是一个有用的应用模式,因为模型选择遵循创意任务,而不是强制所有任务都通过同一个端点完成。
Choose the model and modality for the job
为任务选择合适的模型和处理方式
At the time of writing, fal on Microsoft Foundry includes five video models in public preview. All five support text-to-video and image-to-video. MiniMax H3 Max additionally supports reference-to-video. For comprehensive model details, please review the documentation.
截至撰写本文时,Fal on Microsoft Foundry 包含五个处于公开预览阶段的视频模型。这五个模型均支持文本到视频和图像到视频。MiniMax H3 Max 还支持参考到视频。如需了解全面的模型详情,请查阅相关文档。
| Model | Modalities | Best fit in the scenario | Deployment offering |
|---|---|---|---|
| LTX 2.5 Fast | Text-to-video; image-to-video | Rapid concept exploration and iteration | Global Standard PayGo |
| LTX 2.5 Pro | Text-to-video; image-to-video | Higher-quality hero output after direction is approved | Global Standard PayGo |
| Kling v3 Pro | Text-to-video; image-to-video | Cinematic or multi-shot alternatives; native audio is available | US Data Zone |
| MiniMax H3 Max | Text-to-video; image-to-video; reference-to-video | Reference-guided campaign variation | Global Standard PayGo |
| MiniMax H3 Max Turbo | Text-to-video; image-to-video | Alternative fast generation path | Global Standard PayGo |
| 模型 | 模态 | 场景中的最佳适用性 | 部署方案 |
|---|---|---|---|
| LTX 2.5 Fast | 文生视频;图生视频 | 快速的概念探索与迭代 | Global Standard PayGo |
| LTX 2.5 Pro | 文生视频;图生视频 | 方向获批后生成更高质量的核心输出 | Global Standard PayGo |
| Kling v3 Pro | 文生视频;图生视频 | 电影级或多镜头替代方案;支持原生音频 | US Data Zone |
| MiniMax H3 Max | 文生视频;图生视频;参考生视频 | 基于参考的营销活动变体 | Global Standard PayGo |
| MiniMax H3 Max Turbo | 文生视频;图生视频 | 替代的快速生成路径 | Global Standard PayGo |
How the asynchronous API workflow works
异步 API 工作流程的工作原理
Video generation is asynchronous. A production-oriented client should treat submission, status polling, result retrieval, and download as distinct operations:
视频生成是异步的。面向生产环境的客户端应将提交、状态轮询、结果检索和下载视为独立的操作:
- Authenticate to the Foundry resource with a Microsoft Entra bearer token.
- Submit a generation request to the selected model and modality route.
- Capture the request_id returned by the service.
- Poll the status route until the job reaches a terminal state.
- Retrieve the completed result and extract the video URL.
- Download or securely process the generated asset before the result URL expires.
- 使用 Microsoft Entra 承载令牌对 Foundry 资源进行身份验证。
- 向所选模型和模态路由提交生成请求。
- 捕获服务返回的 request_id。
- 轮询状态路由,直到作业达到终止状态。
- 检索已完成的结果并提取视频 URL。
- 在结果 URL 过期之前下载或安全处理生成的资产。
Prerequisites
前提条件
- An Azure subscription.
- A Microsoft Foundry resource and project.
- Subscription Owner or Subscription Contributor access to enable the preview (Fal.EnableDeploy) feature.
- Foundry Owner access on the project to deploy models.
- Azure CLI installed and authenticated with az login.
- Python 3.10 or later with the requests package.
- Model deployments for the fal models used by the walkthrough.
- A publicly reachable HTTPS image URL for image-to-video examples, plus reference URLs for the reference-to-video example.
- 一个 Azure 订阅。
- 一个 Microsoft Foundry 资源和项目。
- 具有订阅所有者或订阅贡献者权限,以启用预览(Fal.EnableDeploy)功能。
- 对项目拥有 Foundry 所有者权限,以便部署模型。
- 已安装 Azure CLI 并通过 az login 完成身份验证。
- Python 3.10 或更高版本,并包含 requests 包。
- 用于本演练中 fal 模型的模型部署。
- 用于图生视频示例的可公开访问的 HTTPS 图像 URL,以及用于参考生视频示例的参考 URL。
Enable fal and deploy the models
启用 fal 并部署模型
An administrator first enables the Fal.EnableDeploy preview feature for the Azure subscription. In the Azure portal, open the subscription, select Preview features, search for Fal.EnableDeploy, review the terms and data-handling disclosure, and register the feature. Registration can take up to 30 minutes.
管理员首先为 Azure 订阅启用 Fal.EnableDeploy 预览功能。在 Azure 门户中,打开订阅,选择“预览功能”,搜索 Fal.EnableDeploy,审阅条款和数据使用披露,然后注册该功能。注册可能需要长达 30 分钟。
After registration, open the Foundry model catalog, select each required fal model, choose Deploy, configure the deployment name and supported deployment offering, and wait until the deployment status is Succeeded.
注册完成后,打开 Foundry 模型目录,选择每个所需的 fal 模型,选择“部署”,配置部署名称和支持的部署方案,并等待部署状态变为 Succeeded。
Data handling: fal services are operated outside Microsoft facilities. Review the fal terms, data-egress implications, privacy requirements, and your organization’s compliance obligations before sending prompts or assets.
数据处理:fal 服务在微软设施之外运行。在发送提示词或资产之前,请查阅 fal 条款、数据出口影响、隐私要求以及您所在组织的合规义务。
Note: All code samples in this walkthrough use Python and are intended to run in a Jupyter Notebook.
注意:本指南中的所有代码示例均使用 Python,并旨在在 Jupyter Notebook 中运行。
Set up the notebook environment
设置笔记本环境
The companion notebook can be organized around a shared client so each scenario changes only the endpoint suffix and request payload.
配套笔记本可以围绕共享客户端进行组织,这样每个场景仅更改端点后缀和请求负载。
%pip install -q requests import json import os import subprocess import time from pathlib import Path from typing import Any, Dict import requests
Configure the resource and model deployment names. The deployment names must match the deployments in your Foundry project.
配置资源和模型部署名称。部署名称必须与您在 Foundry 项目中的部署相匹配。
FOUNDRY_RESOURCE_NAME = os.environ.get( "FOUNDRY_RESOURCE_NAME", "your-foundry-resource" ) FOUNDRY_HOST = ( f"https://{FOUNDRY_RESOURCE_NAME}.services.ai.azure.com" ) DEPLOYMENTS = { "ltx_fast": os.environ.get("LTX_FAST_DEPLOYMENT", "ltx-2-5-fast"), "ltx_pro": os.environ.get("LTX_PRO_DEPLOYMENT", "ltx-2-5-pro"), "kling_pro": os.environ.get("KLING_PRO_DEPLOYMENT", "kling-v3-pro"), "minimax_h3": os.environ.get("MINIMAX_H3_DEPLOYMENT", "minimax-h3-max"), }
Authenticate for local development
为本地开发进行身份验证
This Python helper invokes Azure CLI as a subprocess. It is still Python, not a Bash sample.
此 Python 辅助程序将 Azure CLI 作为子进程调用。它仍然是 Python,而非 Bash 示例。
def get_bearer_token() -> str: command = [ "az", "account", "get-access-token", "--scope", "https://cognitiveservices.azure.com/.default", "--query", "accessToken", "--output", "tsv", ] token = subprocess.check_output(command, text=True).strip() if not token: raise RuntimeError("Azure CLI did not return an access token.") return token def auth_headers() -> Dict[str, str]: return { "Authorization": f"Bearer {get_bearer_token()}", "Content-Type": "application/json", }
Create the asynchronous generation client
创建异步生成客户端
Video generation is asynchronous. The client submits a job, polls its status, retrieves the result, and downloads the completed video.
视频生成是异步的。客户端提交作业,轮询其状态,检索结果,并下载完成的视频。
更进一步:量化金融体系
看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力