This page shows you how to create and manage Transcoder API job templates.
By default, the Transcoder API applies a preset template called
preset/web-hd to populate a job configuration. You can specify your own custom
job templates when creating transcoding jobs. A job configuration represents
many of the settings you can customize when creating a job.
Set up your Google Cloud project and authentication
If you have not created a Google Cloud project and credentials, see Before you begin.Creating job templates
You can specify a wide variety of settings in a job template. For an introduction to some of the terminology and concepts of job configurations, see the Transcoder API overview.
To create a job template, use the
projects.locations.jobTemplates.create
method. The following example uses a simple configuration to create standard
definition and high definition .mp4 output files. For more information on a
job configuration, see the
JobConfig reference.
REST
Before using any of the request data, make the following replacements:
PROJECT_ID: Your Google Cloud project ID listed in the IAM Settings.LOCATION: The location where your job template will be stored. Use one of the supported regions.Show locationsus-central1us-west1us-west2us-east1us-east4southamerica-east1northamerica-northeast1asia-east1asia-northeast1asia-northeast3asia-south1asia-southeast1australia-southeast1europe-west1europe-west2europe-west4me-west1me-central1me-central2
TEMPLATE_ID: A user-defined identifier for the new job template to create. This value should be 4-63 characters and valid characters are in the regular expression[a-zA-Z][a-zA-Z0-9_-]*.
To send your request, expand one of these options:
You should receive a JSON response similar to the following:
{
"name": "projects/PROJECT_NUMBER/locations/LOCATION/jobTemplates/TEMPLATE_ID",
"config": {
"inputs": [
{
"key": "input0"
}
],
"editList": [
{
"key": "atom0",
"inputs": [
"input0"
],
"startTimeOffset": "0s"
}
],
"elementaryStreams": [
{
"videoStream": {
"h264": {
"widthPixels": 640,
"heightPixels": 360,
"frameRate": 60,
"bitrateBps": 550000,
"pixelFormat": "yuv420p",
"rateControlMode": "vbr",
"crfLevel": 21,
"gopDuration": "3s",
"vbvSizeBits": 550000,
"vbvFullnessBits": 495000,
"entropyCoder": "cabac",
"profile": "high",
"preset": "veryfast"
}
},
"key": "video-stream0"
},
{
"videoStream": {
"h264": {
"widthPixels": 1280,
"heightPixels": 720,
"frameRate": 60,
"bitrateBps": 2500000,
"pixelFormat": "yuv420p",
"rateControlMode": "vbr",
"crfLevel": 21,
"gopDuration": "3s",
"vbvSizeBits": 2500000,
"vbvFullnessBits": 2250000,
"entropyCoder": "cabac",
"profile": "high",
"preset": "veryfast"
}
},
"key": "video-stream1"
},
{
"audioStream": {
"codec": "aac",
"bitrateBps": 64000,
"channelCount": 2,
"channelLayout": [
"fl",
"fr"
],
"sampleRateHertz": 48000
},
"key": "audio-stream0"
}
],
"muxStreams": [
{
"key": "sd",
"fileName": "sd.mp4",
"container": "mp4",
"elementaryStreams": [
"video-stream0",
"audio-stream0"
]
},
{
"key": "hd",
"fileName": "hd.mp4",
"container": "mp4",
"elementaryStreams": [
"video-stream1",
"audio-stream0"
]
}
],
"output": {}
}
}
gcloud
- Create a
request.jsonfile that defines the job template fields. The following is an example job template:{ "config": { "elementaryStreams": [ { "key": "video-stream0", "videoStream": { "h264": { "heightPixels": 360, "widthPixels": 640, "bitrateBps": 550000, "frameRate": 60 } } }, { "key": "video-stream1", "videoStream": { "h264": { "heightPixels": 720, "widthPixels": 1280, "bitrateBps": 2500000, "frameRate": 60 } } }, { "key": "audio-stream0", "audioStream": { "codec": "aac", "bitrateBps": 64000 } } ], "muxStreams": [ { "key": "sd", "container": "mp4", "elementaryStreams": [ "video-stream0", "audio-stream0" ] }, { "key": "hd", "container": "mp4", "elementaryStreams": [ "video-stream1", "audio-stream0" ] } ] } }
- Make the following replacements for the
gcloudcommand: - TEMPLATE_ID: A user-defined
identifier for the new job template to create. This value should be 4-63
characters and valid characters are in the regular expression
[a-zA-Z][a-zA-Z0-9_-]*. - LOCATION: The location where
your job template will be stored. Use one of the supported regions.
Show locations
us-central1us-west1us-west2us-east1us-east4southamerica-east1northamerica-northeast1asia-east1asia-northeast1asia-northeast3asia-south1asia-southeast1australia-southeast1europe-west1europe-west2europe-west4me-west1me-central1me-central2
- Run the following command:
You should see a response similar to the following:gcloud transcoder templates create TEMPLATE_ID --file="request.json" --location=LOCATION
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION/jobTemplates/TEMPLATE_ID", "config": { "inputs": [ { "key": "input0" } ], "editList": [ { "key": "atom0", "inputs": [ "input0" ], "startTimeOffset": "0s" } ], "elementaryStreams": [ { "videoStream": { "h264": { "widthPixels": 640, "heightPixels": 360, "frameRate": 60, "bitrateBps": 550000, "pixelFormat": "yuv420p", "rateControlMode": "vbr", "crfLevel": 21, "gopDuration": "3s", "vbvSizeBits": 550000, "vbvFullnessBits": 495000, "entropyCoder": "cabac", "profile": "high", "preset": "veryfast" } }, "key": "video-stream0" }, { "videoStream": { "h264": { "widthPixels": 1280, "heightPixels": 720, "frameRate": 60, "bitrateBps": 2500000, "pixelFormat": "yuv420p", "rateControlMode": "vbr", "crfLevel": 21, "gopDuration": "3s", "vbvSizeBits": 2500000, "vbvFullnessBits": 2250000, "entropyCoder": "cabac", "profile": "high", "preset": "veryfast" } }, "key": "video-stream1" }, { "audioStream": { "codec": "aac", "bitrateBps": 64000, "channelCount": 2, "channelLayout": [ "fl", "fr" ], "sampleRateHertz": 48000 }, "key": "audio-stream0" } ], "muxStreams": [ { "key": "sd", "fileName": "sd.mp4", "container": "mp4", "elementaryStreams": [ "video-stream0", "audio-stream0" ] }, { "key": "hd", "fileName": "hd.mp4", "container": "mp4", "elementaryStreams": [ "video-stream1", "audio-stream0" ] } ], "output": {} } }
C#
Before trying this sample, follow the C# setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API C# API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Go
Before trying this sample, follow the Go setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API Go API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Java
Before trying this sample, follow the Java setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API Java API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Node.js
Before trying this sample, follow the Node.js setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API Node.js API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
PHP
Before trying this sample, follow the PHP setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API PHP API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Python
Before trying this sample, follow the Python setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API Python API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Ruby
Before trying this sample, follow the Ruby setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API Ruby API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Getting job template details
To get the details for a job template, use the
projects.locations.jobTemplates.get
method.
REST
Before using any of the request data, make the following replacements:
TEMPLATE_ID: The ID of the job template you created.PROJECT_ID: Your Google Cloud project ID.LOCATION: The location of your job template. Use one
of the supported regions.
us-central1us-west1us-west2us-east1us-east4southamerica-east1northamerica-northeast1asia-east1asia-northeast1asia-northeast3asia-south1asia-southeast1australia-southeast1europe-west1europe-west2europe-west4me-west1me-central1me-central2
To send your request, expand one of these options:
You should receive a JSON response similar to the following:
{
"name": "projects/PROJECT_NUMBER/locations/LOCATION/jobTemplates/TEMPLATE_ID",
"config": {
"inputs": [
{
"key": "input0"
}
],
"editList": [
{
"key": "atom0",
"inputs": [
"input0"
],
"startTimeOffset": "0s"
}
],
"elementaryStreams": [
{
"videoStream": {
"h264": {
"widthPixels": 640,
"heightPixels": 360,
"frameRate": 60,
"bitrateBps": 550000,
"pixelFormat": "yuv420p",
"rateControlMode": "vbr",
"crfLevel": 21,
"gopDuration": "3s",
"vbvSizeBits": 550000,
"vbvFullnessBits": 495000,
"entropyCoder": "cabac",
"profile": "high",
"preset": "veryfast"
}
},
"key": "video-stream0"
},
{
"videoStream": {
"h264": {
"widthPixels": 1280,
"heightPixels": 720,
"frameRate": 60,
"bitrateBps": 2500000,
"pixelFormat": "yuv420p",
"rateControlMode": "vbr",
"crfLevel": 21,
"gopDuration": "3s",
"vbvSizeBits": 2500000,
"vbvFullnessBits": 2250000,
"entropyCoder": "cabac",
"profile": "high",
"preset": "veryfast"
}
},
"key": "video-stream1"
},
{
"audioStream": {
"codec": "aac",
"bitrateBps": 64000,
"channelCount": 2,
"channelLayout": [
"fl",
"fr"
],
"sampleRateHertz": 48000
},
"key": "audio-stream0"
}
],
"muxStreams": [
{
"key": "sd",
"fileName": "sd.mp4",
"container": "mp4",
"elementaryStreams": [
"video-stream0",
"audio-stream0"
]
},
{
"key": "hd",
"fileName": "hd.mp4",
"container": "mp4",
"elementaryStreams": [
"video-stream1",
"audio-stream0"
]
}
],
"output": {}
}
}
gcloud
- Make the following replacements for the
gcloudcommand: - TEMPLATE_ID: The ID of the job template you created.
- LOCATION: The location of your
job template. Use one of the supported regions.
Show locations
us-central1us-west1us-west2us-east1us-east4southamerica-east1northamerica-northeast1asia-east1asia-northeast1asia-northeast3asia-south1asia-southeast1australia-southeast1europe-west1europe-west2europe-west4me-west1me-central1me-central2
- Run the following command:
You should see a response similar to the following:gcloud transcoder templates describe TEMPLATE_ID --location=LOCATION
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION/jobTemplates/TEMPLATE_ID", "config": { "inputs": [ { "key": "input0" } ], "editList": [ { "key": "atom0", "inputs": [ "input0" ], "startTimeOffset": "0s" } ], "elementaryStreams": [ { "videoStream": { "h264": { "widthPixels": 640, "heightPixels": 360, "frameRate": 60, "bitrateBps": 550000, "pixelFormat": "yuv420p", "rateControlMode": "vbr", "crfLevel": 21, "gopDuration": "3s", "vbvSizeBits": 550000, "vbvFullnessBits": 495000, "entropyCoder": "cabac", "profile": "high", "preset": "veryfast" } }, "key": "video-stream0" }, { "videoStream": { "h264": { "widthPixels": 1280, "heightPixels": 720, "frameRate": 60, "bitrateBps": 2500000, "pixelFormat": "yuv420p", "rateControlMode": "vbr", "crfLevel": 21, "gopDuration": "3s", "vbvSizeBits": 2500000, "vbvFullnessBits": 2250000, "entropyCoder": "cabac", "profile": "high", "preset": "veryfast" } }, "key": "video-stream1" }, { "audioStream": { "codec": "aac", "bitrateBps": 64000, "channelCount": 2, "channelLayout": [ "fl", "fr" ], "sampleRateHertz": 48000 }, "key": "audio-stream0" } ], "muxStreams": [ { "key": "sd", "fileName": "sd.mp4", "container": "mp4", "elementaryStreams": [ "video-stream0", "audio-stream0" ] }, { "key": "hd", "fileName": "hd.mp4", "container": "mp4", "elementaryStreams": [ "video-stream1", "audio-stream0" ] } ], "output": {} } }
C#
Before trying this sample, follow the C# setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API C# API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Go
Before trying this sample, follow the Go setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API Go API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Java
Before trying this sample, follow the Java setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API Java API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Node.js
Before trying this sample, follow the Node.js setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API Node.js API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
PHP
Before trying this sample, follow the PHP setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API PHP API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Python
Before trying this sample, follow the Python setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API Python API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Ruby
Before trying this sample, follow the Ruby setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API Ruby API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Listing job templates
If you want to review all the job templates you created in a location, use the
projects.locations.jobTemplates.list
method.
REST
Before using any of the request data, make the following replacements:
PROJECT_ID: Your Google Cloud project ID.LOCATION: The location of your job template. Use one
of the supported regions.
us-central1us-west1us-west2us-east1us-east4southamerica-east1northamerica-northeast1asia-east1asia-northeast1asia-northeast3asia-south1asia-southeast1australia-southeast1europe-west1europe-west2europe-west4me-west1me-central1me-central2
To send your request, expand one of these options:
You should receive a JSON response similar to the following:
{
"jobTemplates": [
{
"name": "projects/PROJECT_NUMBER/locations/LOCATION/jobTemplates/TEMPLATE_ID",
"config": {
...
}
},
{
"name": "projects/PROJECT_NUMBER/locations/LOCATION/jobTemplates/my-other-template",
"config": {
...
}
}
]
}
gcloud
- Make the following replacements for the
gcloudcommand: - LOCATION: The location of your
job template(s). Use one of the supported regions.
Show locations
us-central1us-west1us-west2us-east1us-east4southamerica-east1northamerica-northeast1asia-east1asia-northeast1asia-northeast3asia-south1asia-southeast1australia-southeast1europe-west1europe-west2europe-west4me-west1me-central1me-central2
- Run the following command:
You should see a response similar to the following:gcloud transcoder templates list --location=LOCATION
NAME projects/PROJECT_NUMBER/locations/LOCATION/jobTemplates/TEMPLATE_ID projects/PROJECT_NUMBER/locations/LOCATION/jobTemplates/my-other-template
C#
Before trying this sample, follow the C# setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API C# API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Go
Before trying this sample, follow the Go setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API Go API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Java
Before trying this sample, follow the Java setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API Java API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Node.js
Before trying this sample, follow the Node.js setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API Node.js API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
PHP
Before trying this sample, follow the PHP setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API PHP API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Python
Before trying this sample, follow the Python setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API Python API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Ruby
Before trying this sample, follow the Ruby setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API Ruby API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
This response may include a nextPageToken, which you can use to retrieve
additional results:
{
"jobTemplates": [
...
],
"nextPageToken": "NEXT_PAGE_TOKEN"
}
In the following curl example, you can then send another request, and include
the value of NEXT_PAGE_TOKEN to list additional job templates,
similar to the following:
curl -X GET \ -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \ https://transcoder.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/jobTemplates?pageToken=NEXT_PAGE_TOKEN
See the relevant client library for more information on using this token.
Deleting job templates
To delete a job template, use the
projects.locations.jobTemplates.delete
method.
REST
Before using any of the request data, make the following replacements:
TEMPLATE_ID: The ID of the job template you created.PROJECT_ID: Your Google Cloud project ID.LOCATION: The location of your job template. Use one
of the supported regions.
us-central1us-west1us-west2us-east1us-east4southamerica-east1northamerica-northeast1asia-east1asia-northeast1asia-northeast3asia-south1asia-southeast1australia-southeast1europe-west1europe-west2europe-west4me-west1me-central1me-central2
To send your request, expand one of these options:
You should receive a JSON response similar to the following:
{}
gcloud
- Make the following replacements for the
gcloudcommand: - TEMPLATE_ID: The ID of the job template you created.
- LOCATION: The location of your
job template. Use one of the supported regions.
Show locations
us-central1us-west1us-west2us-east1us-east4southamerica-east1northamerica-northeast1asia-east1asia-northeast1asia-northeast3asia-south1asia-southeast1australia-southeast1europe-west1europe-west2europe-west4me-west1me-central1me-central2
- Run the following command:
You should see a response similar to the following:gcloud transcoder templates delete TEMPLATE_ID --location=LOCATION
Deleted template [projects/PROJECT_ID/locations/LOCATION/jobTemplates/TEMPLATE_ID].
C#
Before trying this sample, follow the C# setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API C# API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Go
Before trying this sample, follow the Go setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API Go API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Java
Before trying this sample, follow the Java setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API Java API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Node.js
Before trying this sample, follow the Node.js setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API Node.js API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
PHP
Before trying this sample, follow the PHP setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API PHP API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Python
Before trying this sample, follow the Python setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API Python API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Ruby
Before trying this sample, follow the Ruby setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API Ruby API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
What's next
Learn about Creating and managing jobs.