CLI 示例:创建转换CLI example: Create a Transform

本文中的 Azure CLI 脚本演示如何创建转换。The Azure CLI script in this article shows how to create a transform. 转换描述了处理视频或音频文件的任务的简单工作流(通常称为“工作程序”)。Transforms describe a simple workflow of tasks for processing your video or audio files (often referred to as a "recipe"). 应始终检查具有所需名称和“工作程序”的转换是否已存在。You should always check if a Transform with desired name and "recipe" already exist. 如果已存在,应再次使用该转换。If it does, you should reuse it.


创建媒体服务帐户Create a Media Services account.


可以在本地安装 CLI。You can install the CLI locally. 有关适用于你的平台的说明,请参阅安装 Azure CLISee Install the Azure CLI for instructions for your platform.

登录Sign in

使用本地安装的 CLI 需要登录到 Azure。Using a local install of the CLI requires signing in to Azure. 使用 az login 命令登录。Sign in with the az login command.

如果 CLI 可以打开默认的浏览器,则它会打开该浏览器并加载登录页。If the CLI can open your default browser, it will do so and load a sign-in page. 否则,你需要打开一个浏览器页面,在浏览器中导航到 后,按照有关命令行的说明输入授权代码。Otherwise, you need to open a browser page and follow the instructions on the command line to enter an authorization code after navigating to in your browser.

指定文件位置Specify location of files

许多媒体服务 CLI 命令允许你通过文件名来传递参数。Many Media Services CLI commands allow you to pass a parameter with a file name.

需要根据所用的 OS 或 Shell(Bash 或 PowerShell)指定文件路径。You need to specify the file path according to the OS or Shell (Bash or PowerShell) that you are using. 下面是一些示例:Below are some examples:

文件(所有 OS)的相对路径Relative path to the file (all OS)

  • @"mytestfile.json"
  • @"../mytestfile.json"

Linux/Mac 和 Windows OS 上的绝对文件路径Absolute file path on Linux/Mac and Windows OS

  • @ "/usr/home/mytestfile.json"
  • @"c:\tmp\user\mytestfile.json"

如果命令要求提供文件路径,请使用 {file}Use {file} if the command is asking for a path to the file. 例如,az ams transform create -a amsaccount -g resourceGroup -n custom --preset .\customPreset.jsonFor example, az ams transform create -a amsaccount -g resourceGroup -n custom --preset .\customPreset.json.
如果命令将加载指定的文件,请使用 @{file}Use @{file} if the command is going to load the specified file. 例如,az ams account-filter create -a amsaccount -g resourceGroup -n filterName --tracks @tracks.jsonFor example, az ams account-filter create -a amsaccount -g resourceGroup -n filterName --tracks @tracks.json.


只能为 StandardEncoderPreset 指定自定义标准编码器预设 JSON 文件的路径,请参阅使用自定义转换进行编码示例。You can only specify a path to a custom Standard Encoder preset JSON file for StandardEncoderPreset, see the encode with a custom transform example.

使用 BuiltInStandardEncoderPreset 时,不能传递文件名。You cannot pass a file name when using BuiltInStandardEncoderPreset.

示例脚本Example script


# Update the following variables for your own settings:

# Create a simple Transform for Adaptive Bitrate Encoding
az ams transform create \
 --name myFirstTransform \
 --preset AdaptiveStreaming \
 --description 'a simple Transform for Adaptive Bitrate Encoding' \
 -g $resourceGroup \
 -a $amsAccountName

# List all the Transforms in an account
az ams transform list -a $amsAccountName -g $resourceGroup

echo "press  [ENTER]  to continue."
read continue

后续步骤Next steps

az ams transform (CLI)az ams transform (CLI)