媒体服务中的转换和作业Transforms and Jobs in Media Services

本主题提供有关转换作业的详细信息,并解释这些实体之间的关系。This topic gives details about Transforms and Jobs and explains the relationship between these entities.


转换/作业工作流Transforms/Jobs workflow

下面的关系图展示了转换/作业工作流:The following diagram shows transforms/jobs workflow:

Azure 媒体服务中的转换和作业工作流

典型工作流Typical workflow

  1. 创建转换。Create a Transform.
  2. 在该转换下提交作业。Submit Jobs under that Transform.
  3. 列出转换。List Transforms.
  4. 请删除将来不打算使用的转换。Delete a Transform, if you aren't planning to use it in the future.


假设希望提取所有视频的第一帧作为缩略图,应采取的步骤如下:Suppose you wanted to extract the first frame of all your videos as a thumbnail image–the steps you would take are:

  1. 定义脚本或者用于处理视频的规则:“使用视频的第一帧作为缩略图”。Define the recipe, or the rule for processing your videos: "use the first frame of the video as the thumbnail".
  2. 对于每个视频,请告知服务:For each video, you would tell the service:
    1. 在何处查找该视频。Where to find that video.
    2. 在何处写入输出缩略图。Where to write the output thumbnail image.

转换可帮助你一次性创建脚本(步骤 1),然后使用该脚本提交作业(步骤 2)。A Transform helps you create the recipe once (Step 1), and submit Jobs using that recipe (Step 2).


属于日期/时间类型的转换和作业的属性始终采用 UTC 格式。Properties of Transform and Job of the Datetime type are always in UTC format.


转换可用来配置对视频进行编码的常见任务。Use Transforms to configure common tasks for encoding videos. 每个转换描述了用于处理视频或音频文件的脚本或任务工作流。Each Transform describes a recipe or a workflow of tasks for processing your video or audio files. 单个转换可以应用多个规则。A single Transform can apply more than one rule. 例如,转换可以指定以给定的比特率将每个视频编码成 MP4 文件,并从该视频的第一帧生成缩略图。For example, a Transform could specify that each video be encoded into an MP4 file at a given bitrate, and that a thumbnail image be generated from the first frame of the video. 针对要包含在转换中的每个规则,请添加一个 TransformOutput 条目。You would add one TransformOutput entry for each rule that you want to include in your Transform. 使用预设来告知转换要如何处理输入媒体文件。You use presets to tell the Transform how the input media files should be processed.

查看架构Viewing schema

在媒体服务 v3 中,预设是 API 本身中的强类型化实体。In Media Services v3, presets are strongly typed entities in the API itself. 可以在开放 API 规范(或 Swagger)中找到这些对象的“架构”定义。You can find the "schema" definition for these objects in Open API Specification (or Swagger). 也可以在 REST API.NET SDK 或其他媒体服务 v3 SDK 参考文档中查看预设定义(例如 StandardEncoderPreset)。You can also view the preset definitions (like StandardEncoderPreset) in the REST API, .NET SDK, or other Media Services v3 SDK reference documentation.

创建转换Creating Transforms

可以使用 REST、CLI 或任何已发布的 SDK 来创建转换。You can create Transforms using REST, CLI, or any of the published SDKs. 媒体服务 v3 API 由 Azure 资源管理器驱动,因此,也可以使用资源管理器模板在媒体服务帐户中创建和部署转换。The Media Services v3 API is driven by Azure Resource Manager, so you can also use Resource Manager templates to create and deploy Transforms in your Media Services account. 可以使用基于角色的访问控制来锁定对转换的访问。Role-based access control can be used to lock down access to Transforms.

更新转换Updating Transforms

如果需要更新转换,请使用“更新”操作。If you need to update your Transform, use the Update operation. 此操作旨在对底层 TransformOutputs 的说明或优先级进行更改。It's intended for making changes to the description, or the priorities of the underlying TransformOutputs. 建议在所有正在进行的作业都完成后执行这类更新。It's recommended that such updates be done when all in-progress jobs have completed. 如果你想要重写脚本,则需要创建新的转换。If you intend to rewrite the recipe, you need to create a new Transform.

转换对象关系图Transform object diagram

下图显示了转换对象及其引用的对象,包括派生关系。The following diagram shows the Transform object and the objects it references, including the derivation relationships. 灰色箭头显示作业引用的类型,绿色箭头显示类派生关系。The gray arrows show a type that the Job references and the green arrows show class derivation relationships.

选择图像查看其完整大小。Select the image to view it full size.

图显示了 Transform 对象及其引用的对象,包括对象之间的类派生关系。Diagram showing the Transform object and the objects it references, including the class derivation relationships between the objects.


作业是针对媒体服务的实际请求,目的是将转换应用到给定的输入视频或音频内容。A Job is the actual request to Media Services to apply the Transform to a given input video or audio content. 创建转换后,可以使用媒体服务 API 或任何已发布的 SDK 来提交作业。Once the Transform has been created, you can submit jobs using Media Services APIs, or any of the published SDKs. Job 指定输入视频位置和输出位置等信息。The Job specifies information like the location of the input video and the location for the output. 可以使用以下各项指定输入视频的位置:HTTPS URL、SAS URL 或资产You can specify the location of your input video using: HTTPS URLs, SAS URLs, or Assets.

来自 HTTPS 的作业输入Job input from HTTPS

如果内容已经可以通过 URL 进行访问,并且你不需要将源文件存储在 Azure 中(例如,从 S3 导入),请使用来自 HTTPS 的作业输入Use job input from HTTPS if your content is already accessible via a URL and you don't need to store the source file in Azure (for example, import from S3). 如果你的内容已存储在 Azure Blob 存储中,但不需要将文件存储在资产中,则此方法也适用。This method is also suitable if you have the content in Azure Blob storage but have no need for the file to be in an Asset. 目前,此方法仅支持使用单个文件作为输入。Currently, this method only supports a single file for input.

资产作为作业输入Asset as Job input

如果输入内容已在资产中,或者内容已存储在本地文件中,请使用资产作为作业输入Use Asset as job input if the input content is already in an Asset or the content is stored in local file. 如果你打算发布输入资产以供流式传输或下载(例如,要发布 MP4 文件以供下载,同时想要执行语音转文本或人脸检测),这也是一个不错的选择。It's also a good option if you plan to publish the input asset for streaming or download (say you want to publish the mp4 for download but also want to do speech to text or face detection). 此方法支持多文件资产(例如,在本地编码的 MBR 流集)。This method supports multi-file assets (for example, MBR streaming sets that were encoded locally).

检查作业进度Checking Job progress

使用事件网格监视事件可以获取作业的进度和状态。The progress and state of jobs can be obtained by monitoring events with Event Grid. 有关详细信息,请参阅使用事件网格监视事件For more information, see Monitor events using EventGrid.

更新作业Updating Jobs

作业实体进行的更新操作可以用于在作业提交之后修改说明或优先级。The Update operation on the Job entity can be used to modify the description and the priority properties after the job has been submitted. 仅当作业仍处于排队状态时,对优先级属性所做的更改才有效。A change to the priority property is effective only if the job is still in a queued state. 如果作业已开始处理或已完成,则更改优先级不起作用。If the job has begun processing, or has finished, changing priority has no effect.

作业对象关系图Job object diagram

下图显示了作业对象及其引用的对象,包括派生关系。The following diagram shows the Job object and the objects it references including the derivation relationships.

单击图像查看其完整大小。Click the image to view it full size.

图显示了 Job 对象及其引用的对象,包括对象之间的类派生关系。Diagram showing the Job object and the objects it references, including the class derivation relationships between the objects.

配置媒体预留单位Configure Media Reserved Units

有关详细信息,请参阅使用 CLI 调整媒体处理的规模For details, see Scale media processing with CLI.

另请参阅See also

后续步骤Next steps