You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Transcoder API中创建预设?预设列表在哪查询?

使用Google Cloud Transcoder API创建自定义预设及查看内置预设指南

查看内置预设列表

Google Transcoder API提供了一系列官方内置预设,你可以通过以下两种方式查看完整列表:

  • gcloud CLI命令:
    gcloud transcoder presets list --location=[LOCATION]
    
    替换[LOCATION]为你的目标区域(如us-central1),执行后会返回所有内置预设的ID、描述、配置摘要等信息。
  • API调用:
    发送GET请求到预设列表接口:
    curl -H "Authorization: Bearer $(gcloud auth print-access-token)" \
    "https://transcoder.googleapis.com/v1/projects/[PROJECT_ID]/locations/[LOCATION]/presets"
    
    替换[PROJECT_ID]和[LOCATION]为你的项目ID和目标区域。

创建自定义预设的具体步骤

如果内置预设不符合需求,你可以创建自定义预设,以下是两种常用方式:

方式一:使用gcloud CLI创建

  1. 编写预设配置文件
    创建一个JSON格式的配置文件(比如custom-preset.json),定义视频、音频和容器的参数,示例如下:
    {
      "name": "my-720p-h264",
      "config": {
        "video": {
          "codec": "h264",
          "bitrateBps": 2000000,
          "frameRate": 30,
          "heightPixels": 720,
          "widthPixels": 1280,
          "profile": "high"
        },
        "audio": {
          "codec": "aac",
          "bitrateBps": 128000,
          "channelCount": 2,
          "sampleRateHertz": 48000
        },
        "container": {
          "format": "mp4"
        }
      }
    }
    
  2. 执行创建命令
    运行以下命令完成预设创建:
    gcloud transcoder presets create my-720p-h264 --config=custom-preset.json --location=us-central1
    
    替换my-720p-h264为你的预设名称,us-central1为目标区域。

方式二:直接调用API创建

发送POST请求到预设创建接口,示例curl命令如下:

curl -X POST \
  -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  -H "Content-Type: application/json" \
  "https://transcoder.googleapis.com/v1/projects/[PROJECT_ID]/locations/[LOCATION]/presets" \
  -d '{
    "name": "my-720p-h264",
    "config": {
      "video": {
        "codec": "h264",
        "bitrateBps": 2000000,
        "frameRate": 30,
        "heightPixels": 720,
        "widthPixels": 1280,
        "profile": "high"
      },
      "audio": {
        "codec": "aac",
        "bitrateBps": 128000,
        "channelCount": 2,
        "sampleRateHertz": 48000
      },
      "container": {
        "format": "mp4"
      }
    }
  }'

替换[PROJECT_ID]和[LOCATION]为你的实际项目和区域信息。

验证自定义预设

创建完成后,你可以通过以下命令查看预设详情,确认配置正确:

gcloud transcoder presets describe my-720p-h264 --location=us-central1

注意事项

  • 自定义预设名称在指定区域内必须唯一,不能与内置预设或其他自定义预设重名。
  • 配置参数需符合API支持范围:视频编码支持H.264、H.265等;音频编码支持AAC、MP3等;容器格式支持MP4、TS等。
  • 创建转码任务时,直接使用自定义预设的名称(或内置预设的ID)即可调用该预设配置。

内容的提问来源于stack exchange,提问作者Rodrigo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 19:23:14