Quickstart

This page shows you how to create a basic video transcoding job using the default settings of the Transcoder API and curl, Windows PowerShell, or the client libraries.

Before you begin

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud Console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  3. Make sure that billing is enabled for your Cloud project. Learn how to confirm that billing is enabled for your project.

  4. Enable the Transcoder API.

    Enable the API

  5. Create a service account:

    1. In the Cloud Console, go to the Create service account page.

      Go to Create service account
    2. Select a project.
    3. In the Service account name field, enter a name. The Cloud Console fills in the Service account ID field based on this name.

      In the Service account description field, enter a description. For example, Service account for quickstart.

    4. Click Create.
    5. Click the Select a role field, then click Transcoder > Transcoder Admin.

    6. Click Continue.
    7. Click Done to finish creating the service account.

      Do not close your browser window. You will use it in the next step.

  6. Create a service account key:

    1. In the Cloud Console, click the email address for the service account that you created.
    2. Click Keys.
    3. Click Add key, then click Create new key.
    4. Click Create. A JSON key file is downloaded to your computer.
    5. Click Close.
  7. Set the environment variable GOOGLE_APPLICATION_CREDENTIALS to the path of the JSON file that contains your service account key. This variable only applies to your current shell session, so if you open a new session, set the variable again.

  8. Install and initialize the Cloud SDK.
  9. Use the gcloud tool to test your authentication environment. Check that the following command outputs a text string without errors:
    gcloud auth application-default print-access-token

Create a Cloud Storage bucket

  1. In the Cloud Console, go to the Cloud Storage Browser page.

    Go to Browser

  2. Click Create bucket.
  3. On the Create a bucket page, enter your bucket information. To go to the next step, click Continue.
    • For Name your bucket, enter a unique bucket name. Don't include sensitive information in the bucket name, because the bucket namespace is global and publicly visible.
    • For Choose where to store your data, do the following:
      • Select a Location type option.
      • Select a Location option.
    • For Choose a default storage class for your data, select the following: Standard.
    • For Choose how to control access to objects, select an Access control option.
    • For Advanced settings (optional), specify an encryption method, a retention policy, or bucket labels.
  4. Click Create.
  5. Click Create Folder and enter a name to create a folder in which to save the encoded video outputs.

Transcode a video using the Transcoder API

You need a video at least 5 seconds in duration from your local machine for the following steps (sample video). See the list of supported input and output formats.

Upload a video to your Cloud Storage bucket

  1. In the Cloud Console, go to the Cloud Storage Browser page.
    Go to the Cloud Storage Browser page
  2. Click the name of your bucket to open it.
  3. Click Upload files.
  4. Select a video file to upload from your local machine.

Your video is now saved to the Cloud Storage bucket.

Create a transcoding job

By default, the Transcoder API transcodes video using H.264 encoding and MP4, HLS, and MPEG-DASH packaging. For each input video, it delivers output renditions in high definition (1280x720 pixels) and standard definition (640x360 pixels).

To create a job, use the projects.locations.jobs.create method.

REST & CMD LINE

Before using any of the request data below, make the following replacements:

  • PROJECT_ID: Your Google Cloud project ID listed in the IAM Settings.
  • LOCATION: The location where your job will run. Use a location from the following list:
    • us-central1
    • us-west1
    • us-east1
    • southamerica-east1
    • asia-east1
    • europe-west1
  • GCS_BUCKET_NAME: The name of the Cloud Storage bucket you created.
  • GCS_INPUT_VIDEO: The name of the video in your Cloud Storage bucket that you are transcoding, such as my-vid.mp4. This field should take into account any folders that you created in the bucket (for example, input/my-vid.mp4).
  • GCS_OUTPUT_FOLDER: The Cloud Storage folder name where you want to save the encoded video outputs.

Request JSON body:

{
  "inputUri": "gs://GCS_BUCKET_NAME/GCS_INPUT_VIDEO",
  "outputUri": "gs://GCS_BUCKET_NAME/GCS_OUTPUT_FOLDER/"
}

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/jobs/JOB_ID",
  "config": {
   ...
  },
  "createTime": CREATE_TIME,
  "ttlAfterCompletionDays": 30
}

gcloud

  1. Make the following replacements for the gcloud command:
    • GCS_BUCKET_NAME: The name of the Cloud Storage bucket you created.
    • GCS_INPUT_VIDEO: The name of the video in your Cloud Storage bucket that you are transcoding, such as my-vid.mp4. This field should take into account any folders that you created in the bucket (for example, input/my-vid.mp4).
    • LOCATION: The location where your job will run. Use a location from the following list:
      • us-central1
      • us-west1
      • us-east1
      • southamerica-east1
      • asia-east1
      • europe-west1
    • GCS_OUTPUT_FOLDER: The Cloud Storage folder name where you want to save the encoded video outputs.
  2. Run the following command:
    gcloud beta transcoder jobs create \
        --input-uri="gs://GCS_BUCKET_NAME/GCS_INPUT_VIDEO" \
        --location=LOCATION \
        --output-uri="gs://GCS_BUCKET_NAME/GCS_OUTPUT_FOLDER/"
    You should see a response similar to the following:
    {
      "name": "projects/PROJECT_NUMBER/locations/LOCATION/jobs/JOB_ID",
      "config": {
       ...
      },
      "createTime": CREATE_TIME,
      "ttlAfterCompletionDays": 30
    }
    

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.

import (
	"context"
	"fmt"
	"io"

	transcoder "cloud.google.com/go/video/transcoder/apiv1beta1"
	transcoderpb "google.golang.org/genproto/googleapis/cloud/video/transcoder/v1beta1"
)

// createJobFromPreset creates a job based on a given preset template. See
// https://cloud.google.com/transcoder/docs/how-to/jobs#create_jobs_presets
// for more information.
func createJobFromPreset(w io.Writer, projectID string, location string, inputURI string, outputURI string, preset string) error {
	// projectID := "my-project-id"
	// location := "us-central1"
	// inputURI := "gs://my-bucket/my-video-file"
	// outputURI := "gs://my-bucket/my-output-folder/"
	// preset := "preset/web-hd"
	ctx := context.Background()
	client, err := transcoder.NewClient(ctx)
	if err != nil {
		return fmt.Errorf("NewClient: %v", err)
	}
	defer client.Close()

	req := &transcoderpb.CreateJobRequest{
		Parent: fmt.Sprintf("projects/%s/locations/%s", projectID, location),
		Job: &transcoderpb.Job{
			InputUri:  inputURI,
			OutputUri: outputURI,
			JobConfig: &transcoderpb.Job_TemplateId{
				TemplateId: preset,
			},
		},
	}
	// Creates the job, Jobs take a variable amount of time to run.
	// You can query for the job state.
	response, err := client.CreateJob(ctx, req)
	if err != nil {
		return fmt.Errorf("createJobFromPreset: %v", err)
	}

	fmt.Fprintf(w, "Job: %v", response.GetName())
	return nil
}

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.


import com.google.cloud.video.transcoder.v1beta1.CreateJobRequest;
import com.google.cloud.video.transcoder.v1beta1.Job;
import com.google.cloud.video.transcoder.v1beta1.LocationName;
import com.google.cloud.video.transcoder.v1beta1.TranscoderServiceClient;
import java.io.IOException;

public class CreateJobFromPreset {

  public static void main(String[] args) throws Exception {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "my-project-id";
    String location = "us-central1";
    String inputUri = "gs://my-bucket/my-video-file";
    String outputUri = "gs://my-bucket/my-output-folder/";
    String preset = "preset/web-hd";

    createJobFromPreset(projectId, location, inputUri, outputUri, preset);
  }

  // Creates a job from a preset.
  public static void createJobFromPreset(
      String projectId, String location, String inputUri, String outputUri, String preset)
      throws IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests.
    try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {

      var createJobRequest =
          CreateJobRequest.newBuilder()
              .setJob(
                  Job.newBuilder()
                      .setInputUri(inputUri)
                      .setOutputUri(outputUri)
                      .setTemplateId(preset)
                      .build())
              .setParent(LocationName.of(projectId, location).toString())
              .build();

      // Send the job creation request and process the response.
      Job job = transcoderServiceClient.createJob(createJobRequest);
      System.out.println("Job: " + job.getName());
    }
  }
}

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.

/**
 * TODO(developer): Uncomment these variables before running the sample.
 */
// projectId = 'my-project-id';
// location = 'us-central1';
// inputUri = 'gs://my-bucket/my-video-file';
// outputUri = 'gs://my-bucket/my-output-folder/';
// preset = 'preset/web-hd';

// Imports the Transcoder library
const {TranscoderServiceClient} = require('@google-cloud/video-transcoder');

// Instantiates a client
const transcoderServiceClient = new TranscoderServiceClient();

async function createJobFromPreset() {
  // Construct request
  const request = {
    parent: transcoderServiceClient.locationPath(projectId, location),
    job: {
      inputUri: inputUri,
      outputUri: outputUri,
      templateId: preset,
    },
  };

  // Run request
  const [response] = await transcoderServiceClient.createJob(request);
  console.log(`Job: ${response.name}`);
}

createJobFromPreset();

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.


import argparse

from google.cloud.video import transcoder_v1beta1
from google.cloud.video.transcoder_v1beta1.services.transcoder_service import (
    TranscoderServiceClient,
)


def create_job_from_preset(project_id, location, input_uri, output_uri, preset):
    """Creates a job based on a job preset.

    Args:
        project_id: The GCP project ID.
        location: The location to start the job in.
        input_uri: Uri of the video in the Cloud Storage bucket.
        output_uri: Uri of the video output folder in the Cloud Storage bucket.
        preset: The preset template."""

    client = TranscoderServiceClient()

    parent = f"projects/{project_id}/locations/{location}"
    job = transcoder_v1beta1.types.Job()
    job.input_uri = input_uri
    job.output_uri = output_uri
    job.template_id = preset

    response = client.create_job(parent=parent, job=job)
    print(f"Job: {response.name}")
    return response

Copy the returned JOB_ID. You need it to get the status of the job.

Check the status of your transcoding job

To check the status of a job, use the projects.locations.jobs.get method.

REST & CMD LINE

Before using any of the request data below, make the following replacements:

  • JOB_ID: The ID of the job you created.
  • PROJECT_ID: Your Google Cloud project ID.
  • LOCATION: The location of your job. Use a location from the following list:
    • us-central1
    • us-west1
    • us-east1
    • southamerica-east1
    • asia-east1
    • europe-west1
  • 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/jobs/JOB_ID",
      "config": {
        "inputs": [
          {
            "key": "input0",
            "uri": "gs://GCS_BUCKET_NAME/GCS_INPUT_VIDEO"
          }
        ],
        "editList": [
          {
            "key": "atom0",
            "inputs": [
              "input0"
            ],
            "startTimeOffset": "0s"
          }
        ],
        "elementaryStreams": [
          {
            "videoStream": {
              "codec": "h264",
              "profile": "high",
              "preset": "veryfast",
              "heightPixels": 360,
              "widthPixels": 640,
              "pixelFormat": "yuv420p",
              "bitrateBps": 550000,
              "rateControlMode": "vbr",
              "crfLevel": 21,
              "vbvSizeBits": 550000,
              "vbvFullnessBits": 495000,
              "gopDuration": "3s",
              "entropyCoder": "cabac",
              "frameRate": 60
            },
            "key": "video-stream0"
          },
          {
            "videoStream": {
              "codec": "h264",
              "profile": "high",
              "preset": "veryfast",
              "heightPixels": 720,
              "widthPixels": 1280,
              "pixelFormat": "yuv420p",
              "bitrateBps": 2500000,
              "rateControlMode": "vbr",
              "crfLevel": 21,
              "vbvSizeBits": 2500000,
              "vbvFullnessBits": 2250000,
              "gopDuration": "3s",
              "entropyCoder": "cabac",
              "frameRate": 60
            },
            "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": {
          "uri": "gs://GCS_BUCKET_NAME/GCS_OUTPUT_FOLDER/"
        }
      },
      "state": "SUCCEEDED"
      "createTime": CREATE_TIME,
      "startTime": START_TIME,
      "endTime": END_TIME,
      "ttlAfterCompletionDays": 30
    }
    

    gcloud

    1. Make the following replacements for the gcloud command:
      • JOB_ID: The ID of the job you created.
      • LOCATION: The location of your job. Use a location from the following list:
        • us-central1
        • us-west1
        • us-east1
        • southamerica-east1
        • asia-east1
        • europe-west1
    2. Run the following command:
      gcloud beta transcoder jobs describe JOB_ID --location=LOCATION
      You should see a response similar to the following:
      {
        "name": "projects/PROJECT_NUMBER/locations/LOCATION/jobs/JOB_ID",
        "config": {
          "inputs": [
            {
              "key": "input0",
              "uri": "gs://GCS_BUCKET_NAME/GCS_INPUT_VIDEO"
            }
          ],
          "editList": [
            {
              "key": "atom0",
              "inputs": [
                "input0"
              ],
              "startTimeOffset": "0s"
            }
          ],
          "elementaryStreams": [
            {
              "videoStream": {
                "codec": "h264",
                "profile": "high",
                "preset": "veryfast",
                "heightPixels": 360,
                "widthPixels": 640,
                "pixelFormat": "yuv420p",
                "bitrateBps": 550000,
                "rateControlMode": "vbr",
                "crfLevel": 21,
                "vbvSizeBits": 550000,
                "vbvFullnessBits": 495000,
                "gopDuration": "3s",
                "entropyCoder": "cabac",
                "frameRate": 60
              },
              "key": "video-stream0"
            },
            {
              "videoStream": {
                "codec": "h264",
                "profile": "high",
                "preset": "veryfast",
                "heightPixels": 720,
                "widthPixels": 1280,
                "pixelFormat": "yuv420p",
                "bitrateBps": 2500000,
                "rateControlMode": "vbr",
                "crfLevel": 21,
                "vbvSizeBits": 2500000,
                "vbvFullnessBits": 2250000,
                "gopDuration": "3s",
                "entropyCoder": "cabac",
                "frameRate": 60
              },
              "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": {
            "uri": "gs://GCS_BUCKET_NAME/GCS_OUTPUT_FOLDER/"
          }
        },
        "state": "SUCCEEDED"
        "createTime": CREATE_TIME,
        "startTime": START_TIME,
        "endTime": END_TIME,
        "ttlAfterCompletionDays": 30
      }
      

    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.

    import (
    	"context"
    	"fmt"
    	"io"
    
    	transcoder "cloud.google.com/go/video/transcoder/apiv1beta1"
    	transcoderpb "google.golang.org/genproto/googleapis/cloud/video/transcoder/v1beta1"
    )
    
    // getJob gets a previously-created job. See https://cloud.google.com/transcoder/docs/how-to/jobs#check_job_status
    // for more information.
    func getJob(w io.Writer, projectID string, location string, jobID string) error {
    	// projectID := "my-project-id"
    	// location := "us-central1"
    	// jobID := "my-job-id"
    	ctx := context.Background()
    	client, err := transcoder.NewClient(ctx)
    	if err != nil {
    		return fmt.Errorf("NewClient: %v", err)
    	}
    	defer client.Close()
    
    	req := &transcoderpb.GetJobRequest{
    		Name: fmt.Sprintf("projects/%s/locations/%s/jobs/%s", projectID, location, jobID),
    	}
    
    	response, err := client.GetJob(ctx, req)
    	if err != nil {
    		return fmt.Errorf("GetJob: %v", err)
    	}
    
    	fmt.Fprintf(w, "Job: %v", response)
    	return nil
    }
    

    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.

    
    import com.google.cloud.video.transcoder.v1beta1.GetJobRequest;
    import com.google.cloud.video.transcoder.v1beta1.Job;
    import com.google.cloud.video.transcoder.v1beta1.JobName;
    import com.google.cloud.video.transcoder.v1beta1.TranscoderServiceClient;
    import java.io.IOException;
    
    public class GetJob {
    
      public static void main(String[] args) throws Exception {
        // TODO(developer): Replace these variables before running the sample.
        String projectId = "my-project-id";
        String location = "us-central1";
        String jobId = "my-job-id";
    
        getJob(projectId, location, jobId);
      }
    
      // Gets a job.
      public static void getJob(String projectId, String location, String jobId) throws IOException {
        // Initialize client that will be used to send requests. This client only needs to be created
        // once, and can be reused for multiple requests.
        try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
          JobName jobName =
              JobName.newBuilder().setProject(projectId).setLocation(location).setJob(jobId).build();
          var getJobRequest = GetJobRequest.newBuilder().setName(jobName.toString()).build();
    
          // Send the get job request and process the response.
          Job job = transcoderServiceClient.getJob(getJobRequest);
          System.out.println("Job: " + job.getName());
        }
      }
    }

    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.

    /**
     * TODO(developer): Uncomment these variables before running the sample.
     */
    // projectId = 'my-project-id';
    // location = 'us-central1';
    // jobId = 'my-job-id';
    
    // Imports the Transcoder library
    const {TranscoderServiceClient} = require('@google-cloud/video-transcoder');
    
    // Instantiates a client
    const transcoderServiceClient = new TranscoderServiceClient();
    
    async function getJob() {
      // Construct request
      const request = {
        name: transcoderServiceClient.jobPath(projectId, location, jobId),
      };
      const [response] = await transcoderServiceClient.getJob(request);
      console.log(`Job: ${response.name}`);
    }
    
    getJob();

    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.

    
    import argparse
    
    from google.cloud.video.transcoder_v1beta1.services.transcoder_service import (
        TranscoderServiceClient,
    )
    
    
    def get_job(project_id, location, job_id):
        """Gets a job.
    
        Args:
            project_id: The GCP project ID.
            location: The location this job is in.
            job_id: The job ID."""
    
        client = TranscoderServiceClient()
    
        name = f"projects/{project_id}/locations/{location}/jobs/{job_id}"
        response = client.get_job(name=name)
        print(f"Job: {response.name}")
        return response
    
    

    If the state is SUCCEEDED, the job is complete and your video outputs are now available in your Cloud Storage bucket's list of encoded files.

    Play your video

    To play the generated media file in Shaka Player, complete the following steps:

    1. Make the Cloud Storage bucket you created publicly readable.
    2. To enable cross-origin resource sharing (CORS) on a Cloud Storage bucket, do the following:
      1. Create a JSON file that contains the following:
        [
          {
            "origin": ["https://shaka-player-demo.appspot.com/"],
            "responseHeader": ["Content-Type", "Range"],
            "method": ["GET", "HEAD"],
            "maxAgeSeconds": 3600
          }
        ]
      2. Run the following command after replacing JSON_FILE_NAME with the name of the JSON file you created in the previous step:
        gsutil cors set JSON_FILE_NAME.json gs://GCS_BUCKET_NAME
    3. Pick one of the generated MP4 files in the bucket.
    4. Click Copy URL next to the file (in the Public access column).
    5. Navigate to Shaka Player, an online live stream player.
    6. Click Custom Content in the top navigation bar.
    7. Click the + button.
    8. Paste the public URL of the file into the Manifest URL box.

    9. Type a name in the Name box.

    10. Optionally, type a URL to an icon image in the Icon URL box.

    11. Click Save.

    12. Click Play.

    Clean up

    To avoid incurring charges to your Google Cloud account for the resources used in this quickstart, follow these steps.

    1. In the Google Cloud Console, go to the Cloud Storage Browser page.

      Go to the Cloud Storage Browser page

    2. Select the checkbox next to the bucket that you created.

    3. Click Delete.

    4. In the pop-up window that appears, click Delete to permanently delete the bucket and its contents.

    You should also delete the job after it completes.

    REST & CMD LINE

    Before using any of the request data below, make the following replacements:

  • JOB_ID: The ID of the job you created.
  • PROJECT_ID: Your Google Cloud project ID.
  • LOCATION: The location of your job. Use a location from the following list:
    • us-central1
    • us-west1
    • us-east1
    • southamerica-east1
    • asia-east1
    • europe-west1
  • To send your request, expand one of these options:

    You should receive a JSON response similar to the following:

    {}
    

    gcloud

    1. Make the following replacements for the gcloud command:
      • JOB_ID: The ID of the job you created.
      • LOCATION: The location of your job. Use a location from the following list:
        • us-central1
        • us-west1
        • us-east1
        • southamerica-east1
        • asia-east1
        • europe-west1
    2. Run the following command:
      gcloud beta transcoder jobs delete JOB_ID --location=LOCATION
      You should see a response similar to the following:
      Deleted job [projects/PROJECT_ID/locations/LOCATION/jobs/JOB_ID].
      

    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.

    import (
    	"context"
    	"fmt"
    	"io"
    
    	transcoder "cloud.google.com/go/video/transcoder/apiv1beta1"
    	transcoderpb "google.golang.org/genproto/googleapis/cloud/video/transcoder/v1beta1"
    )
    
    // deleteJob deletes a previously-created job. See
    // https://cloud.google.com/transcoder/docs/how-to/jobs#delete_jobs for more
    // information.
    func deleteJob(w io.Writer, projectID string, location string, jobID string) error {
    	// projectID := "my-project-id"
    	// location := "us-central1"
    	// jobID := "my-job-id"
    	ctx := context.Background()
    	client, err := transcoder.NewClient(ctx)
    	if err != nil {
    		return fmt.Errorf("NewClient: %v", err)
    	}
    	defer client.Close()
    
    	req := &transcoderpb.DeleteJobRequest{
    		Name: fmt.Sprintf("projects/%s/locations/%s/jobs/%s", projectID, location, jobID),
    	}
    
    	err = client.DeleteJob(ctx, req)
    	if err != nil {
    		return fmt.Errorf("DeleteJob: %v", err)
    	}
    
    	fmt.Fprintf(w, "Deleted job")
    	return nil
    }
    

    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.

    
    import com.google.cloud.video.transcoder.v1beta1.DeleteJobRequest;
    import com.google.cloud.video.transcoder.v1beta1.JobName;
    import com.google.cloud.video.transcoder.v1beta1.TranscoderServiceClient;
    import java.io.IOException;
    
    public class DeleteJob {
    
      public static void main(String[] args) throws Exception {
        // TODO(developer): Replace these variables before running the sample.
        String projectId = "my-project-id";
        String location = "us-central1";
        String jobId = "my-job-id";
    
        deleteJob(projectId, location, jobId);
      }
    
      // Deletes a job.
      public static void deleteJob(String projectId, String location, String jobId) throws IOException {
        // Initialize client that will be used to send requests. This client only needs to be created
        // once, and can be reused for multiple requests.
        try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
          JobName jobName =
              JobName.newBuilder().setProject(projectId).setLocation(location).setJob(jobId).build();
          var deleteJobRequest = DeleteJobRequest.newBuilder().setName(jobName.toString()).build();
    
          // Send the delete job request and process the response.
          transcoderServiceClient.deleteJob(deleteJobRequest);
          System.out.println("Deleted job");
        }
      }
    }

    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.

    /**
     * TODO(developer): Uncomment these variables before running the sample.
     */
    // projectId = 'my-project-id';
    // location = 'us-central1';
    // jobId = 'my-job-id';
    
    // Imports the Transcoder library
    const {TranscoderServiceClient} = require('@google-cloud/video-transcoder');
    
    // Instantiates a client
    const transcoderServiceClient = new TranscoderServiceClient();
    
    async function deleteJob() {
      // Construct request
      const request = {
        name: transcoderServiceClient.jobPath(projectId, location, jobId),
      };
      await transcoderServiceClient.deleteJob(request);
      console.log('Deleted job');
    }
    
    deleteJob();

    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.

    
    import argparse
    
    from google.cloud.video.transcoder_v1beta1.services.transcoder_service import (
        TranscoderServiceClient,
    )
    
    
    def delete_job(project_id, location, job_id):
        """Gets a job.
    
        Args:
            project_id: The GCP project ID.
            location: The location this job is in.
            job_id: The job ID."""
    
        client = TranscoderServiceClient()
    
        name = f"projects/{project_id}/locations/{location}/jobs/{job_id}"
        response = client.delete_job(name=name)
        print("Deleted job")
        return response
    
    

    What's next