Transcoder API๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋™์˜์ƒ ํŠธ๋žœ์Šค์ฝ”๋”ฉ

์ด ํŽ˜์ด์ง€์—์„œ๋Š” Transcoder API ๋ฐ curl, Windows PowerShell ๋˜๋Š” ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์˜ ๊ธฐ๋ณธ ์„ค์ •์„ ์‚ฌ์šฉํ•˜์—ฌ ๊ธฐ๋ณธ ๋™์˜์ƒ ํŠธ๋žœ์Šค์ฝ”๋”ฉ ์ž‘์—…์„ ๋งŒ๋“œ๋Š” ๋ฐฉ๋ฒ•์„ ์„ค๋ช…ํ•ฉ๋‹ˆ๋‹ค.

๋‹ค์Œ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด ์ค‘ ํ•˜๋‚˜๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ Google Cloud ์ฝ˜์†”์—์„œ ์ด ๋น ๋ฅธ ์‹œ์ž‘์„ ์ง์ ‘ ์ˆ˜ํ–‰ํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

์‹œ์ž‘ํ•˜๊ธฐ ์ „์—

  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. Install the Google Cloud CLI.

  3. ์™ธ๋ถ€ ID ๊ณต๊ธ‰์—…์ฒด(IdP)๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ ๋จผ์ € ์ œํœด ID๋กœ gcloud CLI์— ๋กœ๊ทธ์ธํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

  4. gcloud CLI๋ฅผ ์ดˆ๊ธฐํ™”ํ•˜๋ ค๋ฉด, ๋‹ค์Œ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.

    gcloud init
  5. Create or select a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM roleโ€”you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.
    • Create a Google Cloud project:

      gcloud projects create PROJECT_ID

      Replace PROJECT_ID with a name for the Google Cloud project you are creating.

    • Select the Google Cloud project that you created:

      gcloud config set project PROJECT_ID

      Replace PROJECT_ID with your Google Cloud project name.

  6. Verify that billing is enabled for your Google Cloud project.

  7. Enable the Transcoder API:

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    gcloud services enable transcoder.googleapis.com
  8. Create local authentication credentials for your user account:

    gcloud auth application-default login

    If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.

  9. Grant roles to your user account. Run the following command once for each of the following IAM roles: roles/transcoder.admin, roles/storage.admin

    gcloud projects add-iam-policy-binding PROJECT_ID --member="user:USER_IDENTIFIER" --role=ROLE

    Replace the following:

    • PROJECT_ID: your project ID.
    • USER_IDENTIFIER: the identifier for your user accountโ€”for example, myemail@example.com.
    • ROLE: the IAM role that you grant to your user account.
  10. Install the Google Cloud CLI.

  11. ์™ธ๋ถ€ ID ๊ณต๊ธ‰์—…์ฒด(IdP)๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ ๋จผ์ € ์ œํœด ID๋กœ gcloud CLI์— ๋กœ๊ทธ์ธํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

  12. gcloud CLI๋ฅผ ์ดˆ๊ธฐํ™”ํ•˜๋ ค๋ฉด, ๋‹ค์Œ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.

    gcloud init
  13. Create or select a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM roleโ€”you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.
    • Create a Google Cloud project:

      gcloud projects create PROJECT_ID

      Replace PROJECT_ID with a name for the Google Cloud project you are creating.

    • Select the Google Cloud project that you created:

      gcloud config set project PROJECT_ID

      Replace PROJECT_ID with your Google Cloud project name.

  14. Verify that billing is enabled for your Google Cloud project.

  15. Enable the Transcoder API:

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    gcloud services enable transcoder.googleapis.com
  16. Create local authentication credentials for your user account:

    gcloud auth application-default login

    If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.

  17. Grant roles to your user account. Run the following command once for each of the following IAM roles: roles/transcoder.admin, roles/storage.admin

    gcloud projects add-iam-policy-binding PROJECT_ID --member="user:USER_IDENTIFIER" --role=ROLE

    Replace the following:

    • PROJECT_ID: your project ID.
    • USER_IDENTIFIER: the identifier for your user accountโ€”for example, myemail@example.com.
    • ROLE: the IAM role that you grant to your user account.
  18. Cloud Storage ๋ฒ„ํ‚ท ๋งŒ๋“ค๊ธฐ

    1. Create a Cloud Storage bucket and configure it as follows:
      • Set the storage class to S (ํ‘œ์ค€).
      • ์Šคํ† ๋ฆฌ์ง€ ์œ„์น˜๋ฅผ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. US(๋ฏธ๊ตญ)
      • BUCKET_NAME์„ ๊ณ ์œ ํ•œ ๋ฒ„ํ‚ท ์ด๋ฆ„์œผ๋กœ ๋ฐ”๊ฟ‰๋‹ˆ๋‹ค. ๋ฒ„ํ‚ท ๋„ค์ž„์ŠคํŽ˜์ด์Šค๋Š” ์ „์—ญ์ ์ด๋ฉฐ ๊ณต๊ฐœ๋กœ ํ‘œ์‹œ๋˜๋ฏ€๋กœ ๋ฒ„ํ‚ท ์ด๋ฆ„์— ๋ฏผ๊ฐํ•œ ์ •๋ณด๋ฅผ ํฌํ•จํ•ด์„œ๋Š” ์•ˆ ๋ฉ๋‹ˆ๋‹ค.
      • gcloud storage buckets create gs://BUCKET_NAME --default-storage-class STANDARD --location US
      • ํด๋” ๋งŒ๋“ค๊ธฐ๋ฅผ ํด๋ฆญํ•˜๊ณ  ์ด๋ฆ„์„ ์ž…๋ ฅํ•˜์—ฌ ์ธ์ฝ”๋”ฉ๋œ ๋™์˜์ƒ ์ถœ๋ ฅ์„ ์ €์žฅํ•  ํด๋”๋ฅผ ๋งŒ๋“ญ๋‹ˆ๋‹ค.

    Transcoder API๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋™์˜์ƒ ํŠธ๋žœ์Šค์ฝ”๋”ฉ

    ๋‹ค์Œ ๋‹จ๊ณ„๋ฅผ ์ˆ˜ํ–‰ํ•˜๋ ค๋ฉด ๋กœ์ปฌ ๋จธ์‹ ์—์„œ ๊ธธ์ด๊ฐ€ 5์ดˆ ์ด์ƒ์ธ ๋™์˜์ƒ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค(์ƒ˜ํ”Œ ๋™์˜์ƒ). ์ง€์›๋˜๋Š” ์ž…๋ ฅ ๋ฐ ์ถœ๋ ฅ ํ˜•์‹ ๋ชฉ๋ก์„ ์ฐธ์กฐํ•˜์„ธ์š”.

    Cloud Storage ๋ฒ„ํ‚ท์— ๋™์˜์ƒ ์—…๋กœ๋“œ

    1. Google Cloud ์ฝ˜์†”์—์„œ Cloud Storage ๋ธŒ๋ผ์šฐ์ € ํŽ˜์ด์ง€๋กœ ์ด๋™ํ•ฉ๋‹ˆ๋‹ค.
      Cloud Storage ๋ธŒ๋ผ์šฐ์ € ํŽ˜์ด์ง€๋กœ ์ด๋™
    2. ๋ฒ„ํ‚ท ์ด๋ฆ„์„ ํด๋ฆญํ•˜์—ฌ ์—ฝ๋‹ˆ๋‹ค.
    3. ํŒŒ์ผ ์—…๋กœ๋“œ๋ฅผ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค.
    4. ๋กœ์ปฌ ๋จธ์‹ ์—์„œ ์—…๋กœ๋“œํ•  ๋™์˜์ƒ ํŒŒ์ผ์„ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.

    ๋™์˜์ƒ์ด ์ด์ œ Cloud Storage ๋ฒ„ํ‚ท์— ์ €์žฅ๋ฉ๋‹ˆ๋‹ค.

    ํŠธ๋žœ์Šค์ฝ”๋”ฉ ์ž‘์—… ๋งŒ๋“ค๊ธฐ

    ๊ธฐ๋ณธ์ ์œผ๋กœ Transcoder API๋Š” H.264 ์ธ์ฝ”๋”ฉ ๋ฐ MP4, HLS, MPEG-DASH ํŒจํ‚ค์ง•์„ ์‚ฌ์šฉํ•˜์—ฌ ๋™์˜์ƒ์„ ํŠธ๋žœ์Šค์ฝ”๋”ฉํ•ฉ๋‹ˆ๋‹ค. ์ž…๋ ฅ ๋™์˜์ƒ๋งˆ๋‹ค ๊ณ ํ™”์งˆ(1280x720ํ”ฝ์…€) ๋ฐ ํ‘œ์ค€ ํ™”์งˆ(640x360 ํ”ฝ์…€)๋กœ ๋ณ€ํ™˜๋œ ์ถœ๋ ฅ์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

    ์ž‘์—…์„ ๋งŒ๋“ค๋ ค๋ฉด projects.locations.jobs.create ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ๋‹ค์Œ ์ฝ”๋“œ ์ƒ˜ํ”Œ์€ ์‚ฌ์ „ ์„ค์ •์„ ์‚ฌ์šฉํ•˜์—ฌ ๊ธฐ๋ณธ ํŠธ๋žœ์Šค์ฝ”๋”ฉ ์ž‘์—…์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค.

    REST

    ์š”์ฒญ ๋ฐ์ดํ„ฐ๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์ „์— ๋‹ค์Œ์„ ๋ฐ”๊ฟ‰๋‹ˆ๋‹ค.

    • PROJECT_ID: IAM ์„ค์ •์— ๋‚˜์—ด๋œ Google Cloud ํ”„๋กœ์ ํŠธ ID์ž…๋‹ˆ๋‹ค.
    • LOCATION: ์ž‘์—…์ด ์‹คํ–‰๋  ์œ„์น˜์ž…๋‹ˆ๋‹ค. ์ง€์›๋˜๋Š” ๋ฆฌ์ „ ์ค‘ ํ•˜๋‚˜๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
      ์œ„์น˜ ํ‘œ์‹œ
      • us-central1
      • us-west1
      • us-west2
      • us-east1
      • us-east4
      • southamerica-east1
      • northamerica-northeast1
      • asia-east1
      • asia-northeast1
      • asia-northeast3
      • asia-south1
      • asia-southeast1
      • australia-southeast1
      • europe-west1
      • europe-west2
      • europe-west4
      • me-west1
      • me-central1
      • me-central2
    • STORAGE_BUCKET_NAME: ๋งŒ๋“  Cloud Storage ๋ฒ„ํ‚ท์˜ ์ด๋ฆ„์ž…๋‹ˆ๋‹ค.
    • STORAGE_INPUT_VIDEO: Cloud Storage ๋ฒ„ํ‚ท์— ์žˆ๋Š” ํŠธ๋žœ์Šค์ฝ”๋”ฉํ•˜๋Š” ๋™์˜์ƒ์˜ ์ด๋ฆ„์ž…๋‹ˆ๋‹ค(์˜ˆ: my-vid.mp4). ์ด ํ•„๋“œ๋Š” ๋ฒ„ํ‚ท์—์„œ ๋งŒ๋“  ํด๋”๋ฅผ ๊ณ ๋ คํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค(์˜ˆ: input/my-vid.mp4).
    • STORAGE_OUTPUT_FOLDER: ์ธ์ฝ”๋”ฉ๋œ ๋™์˜์ƒ ์ถœ๋ ฅ์„ ์ €์žฅํ•  Cloud Storage ํด๋” ์ด๋ฆ„์ž…๋‹ˆ๋‹ค.

    ์š”์ฒญ์„ ๋ณด๋‚ด๋ ค๋ฉด ๋‹ค์Œ ์˜ต์…˜ ์ค‘ ํ•˜๋‚˜๋ฅผ ํŽผ์นฉ๋‹ˆ๋‹ค.

    ์ด ํŠน์ • REST ์˜ˆ์‹œ์—์„œ๋Š” ์„ ํƒ์ ์ธ fields ์ฟผ๋ฆฌ ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ƒ์„ฑ๋œ ๋ฆฌ์†Œ์Šค ์ด๋ฆ„๋งŒ ์‘๋‹ต์— ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค.

    {
      "name": "projects/PROJECT_NUMBER/locations/LOCATION/jobs/JOB_ID"
    }
    

    gcloud

    1. gcloud ๋ช…๋ น์–ด๋ฅผ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋ฐ”๊ฟ‰๋‹ˆ๋‹ค.
      • STORAGE_BUCKET_NAME: ๋งŒ๋“  Cloud Storage ๋ฒ„ํ‚ท์˜ ์ด๋ฆ„์ž…๋‹ˆ๋‹ค.
      • STORAGE_INPUT_VIDEO: Cloud Storage ๋ฒ„ํ‚ท์— ์žˆ๋Š” ํŠธ๋žœ์Šค์ฝ”๋”ฉํ•˜๋Š” ๋™์˜์ƒ์˜ ์ด๋ฆ„์ž…๋‹ˆ๋‹ค(์˜ˆ: my-vid.mp4). ์ด ํ•„๋“œ๋Š” ๋ฒ„ํ‚ท์—์„œ ๋งŒ๋“  ํด๋”๋ฅผ ๊ณ ๋ คํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค(์˜ˆ: input/my-vid.mp4).
      • LOCATION: ์ž‘์—…์ด ์‹คํ–‰๋  ์œ„์น˜์ž…๋‹ˆ๋‹ค. ์ง€์›๋˜๋Š” ๋ฆฌ์ „ ์ค‘ ํ•˜๋‚˜๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
        ์œ„์น˜ ํ‘œ์‹œ
        • us-central1
        • us-west1
        • us-west2
        • us-east1
        • us-east4
        • southamerica-east1
        • northamerica-northeast1
        • asia-east1
        • asia-northeast1
        • asia-northeast3
        • asia-south1
        • asia-southeast1
        • australia-southeast1
        • europe-west1
        • europe-west2
        • europe-west4
        • me-west1
        • me-central1
        • me-central2
      • STORAGE_OUTPUT_FOLDER: ์ธ์ฝ”๋”ฉ๋œ ๋™์˜์ƒ ์ถœ๋ ฅ์„ ์ €์žฅํ•  Cloud Storage ํด๋” ์ด๋ฆ„์ž…๋‹ˆ๋‹ค.
    2. ๋‹ค์Œ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.
      gcloud transcoder jobs create \
        --input-uri="gs://STORAGE_BUCKET_NAME/STORAGE_INPUT_VIDEO" \
        --location=LOCATION \
        --output-uri="gs://STORAGE_BUCKET_NAME/STORAGE_OUTPUT_FOLDER/"
      ๋‹ค์Œ๊ณผ ๋น„์Šทํ•œ ์‘๋‹ต์ด ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค.
      {
        "config": {
         ...
        },
        "createTime": CREATE_TIME,
        "name": "projects/PROJECT_NUMBER/locations/LOCATION/jobs/JOB_ID",
        "state": "PENDING",
        "ttlAfterCompletionDays": 30
      }
      

    C#

    ์ด ์ƒ˜ํ”Œ์„ ์‚ฌ์šฉํ•ด ๋ณด๊ธฐ ์ „์— Transcoder API ๋น ๋ฅธ ์‹œ์ž‘: ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์‚ฌ์šฉ์˜ C# ์„ค์ • ์•ˆ๋‚ด๋ฅผ ๋”ฐ๋ฅด์„ธ์š”. ์ž์„ธํ•œ ๋‚ด์šฉ์€ Transcoder API C# API ์ฐธ๊ณ  ๋ฌธ์„œ๋ฅผ ํ™•์ธํ•˜์„ธ์š”.

    Transcoder API์— ์ธ์ฆํ•˜๋ ค๋ฉด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ธฐ๋ณธ ์‚ฌ์šฉ์ž ์ธ์ฆ ์ •๋ณด๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋กœ์ปฌ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์˜ ์ธ์ฆ ์„ค์ •์„ ์ฐธ์กฐํ•˜์„ธ์š”.

    
    using Google.Api.Gax.ResourceNames;
    using Google.Cloud.Video.Transcoder.V1;
    
    public class CreateJobFromPresetSample
    {
        public Job CreateJobFromPreset(
            string projectId, string location, string inputUri, string outputUri, string preset)
        {
            // Create the client.
            TranscoderServiceClient client = TranscoderServiceClient.Create();
    
            // Build the parent location name.
            LocationName parent = new LocationName(projectId, location);
    
            // Build the job.
            Job newJob = new Job
            {
                InputUri = inputUri,
                OutputUri = outputUri,
                TemplateId = preset
            };
    
            // Call the API.
            Job job = client.CreateJob(parent, newJob);
    
            // Return the result.
            return job;
        }
    }

    Go

    ์ด ์ƒ˜ํ”Œ์„ ์‚ฌ์šฉํ•ด ๋ณด๊ธฐ ์ „์— Transcoder API ๋น ๋ฅธ ์‹œ์ž‘: ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์‚ฌ์šฉ์˜ Go ์„ค์ • ์•ˆ๋‚ด๋ฅผ ๋”ฐ๋ฅด์„ธ์š”. ์ž์„ธํ•œ ๋‚ด์šฉ์€ Transcoder API Go API ์ฐธ๊ณ  ๋ฌธ์„œ๋ฅผ ํ™•์ธํ•˜์„ธ์š”.

    Transcoder API์— ์ธ์ฆํ•˜๋ ค๋ฉด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ธฐ๋ณธ ์‚ฌ์šฉ์ž ์ธ์ฆ ์ •๋ณด๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋กœ์ปฌ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์˜ ์ธ์ฆ ์„ค์ •์„ ์ฐธ์กฐํ•˜์„ธ์š”.

    import (
    	"context"
    	"fmt"
    	"io"
    
    	transcoder "cloud.google.com/go/video/transcoder/apiv1"
    	"cloud.google.com/go/video/transcoder/apiv1/transcoderpb"
    )
    
    // 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) 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: %w", 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: %w", err)
    	}
    
    	fmt.Fprintf(w, "Job: %v", response.GetName())
    	return nil
    }
    

    Java

    ์ด ์ƒ˜ํ”Œ์„ ์‚ฌ์šฉํ•ด ๋ณด๊ธฐ ์ „์— Transcoder API ๋น ๋ฅธ ์‹œ์ž‘: ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์‚ฌ์šฉ์˜ Java ์„ค์ • ์•ˆ๋‚ด๋ฅผ ๋”ฐ๋ฅด์„ธ์š”. ์ž์„ธํ•œ ๋‚ด์šฉ์€ Transcoder API Java API ์ฐธ๊ณ  ๋ฌธ์„œ๋ฅผ ํ™•์ธํ•˜์„ธ์š”.

    Transcoder API์— ์ธ์ฆํ•˜๋ ค๋ฉด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ธฐ๋ณธ ์‚ฌ์šฉ์ž ์ธ์ฆ ์ •๋ณด๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋กœ์ปฌ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์˜ ์ธ์ฆ ์„ค์ •์„ ์ฐธ์กฐํ•˜์„ธ์š”.

    
    import com.google.cloud.video.transcoder.v1.CreateJobRequest;
    import com.google.cloud.video.transcoder.v1.Job;
    import com.google.cloud.video.transcoder.v1.LocationName;
    import com.google.cloud.video.transcoder.v1.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/";
        // See https://cloud.google.com/transcoder/docs/concepts/overview#job_template
        // for information on this preset.
        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()) {
    
          CreateJobRequest 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

    ์ด ์ƒ˜ํ”Œ์„ ์‚ฌ์šฉํ•ด ๋ณด๊ธฐ ์ „์— Transcoder API ๋น ๋ฅธ ์‹œ์ž‘: ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์‚ฌ์šฉ์˜ Node.js ์„ค์ • ์•ˆ๋‚ด๋ฅผ ๋”ฐ๋ฅด์„ธ์š”. ์ž์„ธํ•œ ๋‚ด์šฉ์€ Transcoder API Node.js API ์ฐธ๊ณ  ๋ฌธ์„œ๋ฅผ ํ™•์ธํ•˜์„ธ์š”.

    Transcoder API์— ์ธ์ฆํ•˜๋ ค๋ฉด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ธฐ๋ณธ ์‚ฌ์šฉ์ž ์ธ์ฆ ์ •๋ณด๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋กœ์ปฌ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์˜ ์ธ์ฆ ์„ค์ •์„ ์ฐธ์กฐํ•˜์„ธ์š”.

    /**
     * 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').v1;
    
    // 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();

    PHP

    ์ด ์ƒ˜ํ”Œ์„ ์‚ฌ์šฉํ•ด ๋ณด๊ธฐ ์ „์— Transcoder API ๋น ๋ฅธ ์‹œ์ž‘: ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์‚ฌ์šฉ์˜ PHP ์„ค์ • ์•ˆ๋‚ด๋ฅผ ๋”ฐ๋ฅด์„ธ์š”. ์ž์„ธํ•œ ๋‚ด์šฉ์€ Transcoder API PHP API ์ฐธ๊ณ  ๋ฌธ์„œ๋ฅผ ํ™•์ธํ•˜์„ธ์š”.

    Transcoder API์— ์ธ์ฆํ•˜๋ ค๋ฉด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ธฐ๋ณธ ์‚ฌ์šฉ์ž ์ธ์ฆ ์ •๋ณด๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋กœ์ปฌ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์˜ ์ธ์ฆ ์„ค์ •์„ ์ฐธ์กฐํ•˜์„ธ์š”.

    use Google\Cloud\Video\Transcoder\V1\Client\TranscoderServiceClient;
    use Google\Cloud\Video\Transcoder\V1\CreateJobRequest;
    use Google\Cloud\Video\Transcoder\V1\Job;
    
    /**
     * Creates a job based on a job preset.
     *
     * @param string $projectId The ID of your Google Cloud Platform project.
     * @param string $location The location of the job.
     * @param string $inputUri Uri of the video in the Cloud Storage bucket.
     * @param string $outputUri Uri of the video output folder in the Cloud Storage bucket.
     * @param string $preset The preset template (for example, "preset/web-hd").
     */
    function create_job_from_preset($projectId, $location, $inputUri, $outputUri, $preset)
    {
        // Instantiate a client.
        $transcoderServiceClient = new TranscoderServiceClient();
    
        $formattedParent = $transcoderServiceClient->locationName($projectId, $location);
        $job = new Job();
        $job->setInputUri($inputUri);
        $job->setOutputUri($outputUri);
        $job->setTemplateId($preset);
        $request = (new CreateJobRequest())
            ->setParent($formattedParent)
            ->setJob($job);
    
        $response = $transcoderServiceClient->createJob($request);
    
        // Print job name.
        printf('Job: %s' . PHP_EOL, $response->getName());
    }

    Python

    ์ด ์ƒ˜ํ”Œ์„ ์‚ฌ์šฉํ•ด ๋ณด๊ธฐ ์ „์— Transcoder API ๋น ๋ฅธ ์‹œ์ž‘: ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์‚ฌ์šฉ์˜ Python ์„ค์ • ์•ˆ๋‚ด๋ฅผ ๋”ฐ๋ฅด์„ธ์š”. ์ž์„ธํ•œ ๋‚ด์šฉ์€ Transcoder API Python API ์ฐธ๊ณ  ๋ฌธ์„œ๋ฅผ ํ™•์ธํ•˜์„ธ์š”.

    Transcoder API์— ์ธ์ฆํ•˜๋ ค๋ฉด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ธฐ๋ณธ ์‚ฌ์šฉ์ž ์ธ์ฆ ์ •๋ณด๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋กœ์ปฌ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์˜ ์ธ์ฆ ์„ค์ •์„ ์ฐธ์กฐํ•˜์„ธ์š”.

    
    import argparse
    
    from google.cloud.video import transcoder_v1
    from google.cloud.video.transcoder_v1.services.transcoder_service import (
        TranscoderServiceClient,
    )
    
    
    def create_job_from_preset(
        project_id: str,
        location: str,
        input_uri: str,
        output_uri: str,
        preset: str,
    ) -> transcoder_v1.types.resources.Job:
        """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 (for example, 'preset/web-hd').
    
        Returns:
            The job resource.
        """
    
        client = TranscoderServiceClient()
    
        parent = f"projects/{project_id}/locations/{location}"
        job = transcoder_v1.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
    
    

    Ruby

    ์ด ์ƒ˜ํ”Œ์„ ์‚ฌ์šฉํ•ด ๋ณด๊ธฐ ์ „์— Transcoder API ๋น ๋ฅธ ์‹œ์ž‘: ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์‚ฌ์šฉ์˜ Ruby ์„ค์ • ์•ˆ๋‚ด๋ฅผ ๋”ฐ๋ฅด์„ธ์š”. ์ž์„ธํ•œ ๋‚ด์šฉ์€ Transcoder API Ruby API ์ฐธ๊ณ  ๋ฌธ์„œ๋ฅผ ํ™•์ธํ•˜์„ธ์š”.

    Transcoder API์— ์ธ์ฆํ•˜๋ ค๋ฉด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ธฐ๋ณธ ์‚ฌ์šฉ์ž ์ธ์ฆ ์ •๋ณด๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋กœ์ปฌ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์˜ ์ธ์ฆ ์„ค์ •์„ ์ฐธ์กฐํ•˜์„ธ์š”.

    # project_id  = "YOUR-GOOGLE-CLOUD-PROJECT"  # (e.g. "my-project")
    # location    = "YOUR-JOB-LOCATION"  # (e.g. "us-central1")
    # input_uri   = "YOUR-GCS-INPUT-VIDEO"  # (e.g. "gs://my-bucket/my-video-file")
    # output_uri  = "YOUR-GCS-OUTPUT-FOLDER/"  # (e.g. "gs://my-bucket/my-output-folder/")
    # preset      = "YOUR-JOB-PRESET"  # (e.g. "preset/web-hd")
    
    # Require the Transcoder client library.
    require "google/cloud/video/transcoder"
    
    # Create a Transcoder client.
    client = Google::Cloud::Video::Transcoder.transcoder_service
    
    # Build the resource name of the parent.
    parent = client.location_path project: project_id, location: location
    
    # Set the job fields.
    new_job = {
      input_uri: input_uri,
      output_uri: output_uri,
      template_id: preset
    }
    
    job = client.create_job parent: parent, job: new_job
    
    # Print the job name.
    puts "Job: #{job.name}"

    ๋ฐ˜ํ™˜๋œ JOB_ID๋ฅผ ๋ณต์‚ฌํ•ฉ๋‹ˆ๋‹ค. ์ž‘์—… ์ƒํƒœ๋ฅผ ๊ฐ€์ ธ์˜ค๋Š” ๋ฐ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

    ํŠธ๋žœ์Šค์ฝ”๋”ฉ ์ž‘์—… ์ƒํƒœ ํ™•์ธ

    ์ž‘์—… ์ƒํƒœ๋ฅผ ํ™•์ธํ•˜๋ ค๋ฉด projects.locations.jobs.get ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ๋‹ค์Œ ์ฝ”๋“œ ์ƒ˜ํ”Œ์€ ์ž‘์—… ์„ธ๋ถ€์ •๋ณด๋ฅผ ๊ฐ€์ ธ์˜จ ํ›„ ์ž‘์—… ์ƒํƒœ๋ฅผ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค.

    REST

    ์š”์ฒญ ๋ฐ์ดํ„ฐ๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์ „์— ๋‹ค์Œ์„ ๋ฐ”๊ฟ‰๋‹ˆ๋‹ค.

  19. JOB_ID: ๋งŒ๋“  ์ž‘์—…์˜ ID์ž…๋‹ˆ๋‹ค.
  20. PROJECT_ID: Google Cloud ํ”„๋กœ์ ํŠธ ID์ž…๋‹ˆ๋‹ค.
  21. LOCATION: ์ž‘์—… ์œ„์น˜์ž…๋‹ˆ๋‹ค. ์ง€์›๋˜๋Š” ๋ฆฌ์ „ ์ค‘ ํ•˜๋‚˜๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
    ์œ„์น˜ ํ‘œ์‹œ
    • us-central1
    • us-west1
    • us-west2
    • us-east1
    • us-east4
    • southamerica-east1
    • northamerica-northeast1
    • asia-east1
    • asia-northeast1
    • asia-northeast3
    • asia-south1
    • asia-southeast1
    • australia-southeast1
    • europe-west1
    • europe-west2
    • europe-west4
    • me-west1
    • me-central1
    • me-central2
  22. ์š”์ฒญ์„ ๋ณด๋‚ด๋ ค๋ฉด ๋‹ค์Œ ์˜ต์…˜ ์ค‘ ํ•˜๋‚˜๋ฅผ ํŽผ์นฉ๋‹ˆ๋‹ค.

    ๋‹ค์Œ๊ณผ ๋น„์Šทํ•œ JSON ์‘๋‹ต์ด ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค.

    {
      "name": "projects/PROJECT_NUMBER/locations/LOCATION/jobs/JOB_ID",
      "config": {
        "inputs": [
          {
            "key": "input0",
            "uri": "gs://STORAGE_BUCKET_NAME/STORAGE_INPUT_VIDEO"
          }
        ],
        "editList": [
          {
            "key": "atom0",
            "inputs": [
              "input0"
            ],
            "startTimeOffset": "0s"
          }
        ],
        "elementaryStreams": [
          {
            "videoStream": {
              "h264": {
                "widthPixels": 640,
                "heightPixels": 360,
                "frameRate": 30,
                "bitrateBps": 550000,
                "pixelFormat": "yuv420p",
                "rateControlMode": "vbr",
                "crfLevel": 21,
                "gopDuration": "3s",
                "vbvSizeBits": 550000,
                "vbvFullnessBits": 495000,
                "entropyCoder": "cabac",
                "bFrameCount": 3,
                "aqStrength": 1,
                "profile": "high",
                "preset": "veryfast"
              }
            },
            "key": "video-stream0"
          },
          {
            "videoStream": {
              "h264": {
                "widthPixels": 1280,
                "heightPixels": 720,
                "frameRate": 30,
                "bitrateBps": 2500000,
                "pixelFormat": "yuv420p",
                "rateControlMode": "vbr",
                "crfLevel": 21,
                "gopDuration": "3s",
                "vbvSizeBits": 2500000,
                "vbvFullnessBits": 2250000,
                "entropyCoder": "cabac",
                "bFrameCount": 3,
                "aqStrength": 1,
                "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"
            ]
          },
          {
            "key": "media-sd",
            "fileName": "media-sd.ts",
            "container": "ts",
            "elementaryStreams": [
              "video-stream0",
              "audio-stream0"
            ]
          },
          {
            "key": "media-hd",
            "fileName": "media-hd.ts",
            "container": "ts",
            "elementaryStreams": [
              "video-stream1",
              "audio-stream0"
            ]
          },
          {
            "key": "video-only-sd",
            "fileName": "video-only-sd.m4s",
            "container": "fmp4",
            "elementaryStreams": [
              "video-stream0"
            ]
          },
          {
            "key": "video-only-hd",
            "fileName": "video-only-hd.m4s",
            "container": "fmp4",
            "elementaryStreams": [
              "video-stream1"
            ]
          },
          {
            "key": "audio-only",
            "fileName": "audio-only.m4s",
            "container": "fmp4",
            "elementaryStreams": [
              "audio-stream0"
            ]
          }
        ],
        "manifests": [
          {
            "fileName": "manifest.m3u8",
            "type": "HLS",
            "muxStreams": [
              "media-sd",
              "media-hd"
            ]
          },
          {
            "fileName": "manifest.mpd",
            "type": "DASH",
            "muxStreams": [
              "video-only-sd",
              "video-only-hd",
              "audio-only"
            ]
          }
        ],
        "output": {
          "uri": "gs://STORAGE_BUCKET_NAME/STORAGE_OUTPUT_FOLDER/"
        }
      },
      "state": "PENDING",
      "createTime": CREATE_TIME,
      "ttlAfterCompletionDays": 30
    }
    

    gcloud

    1. gcloud ๋ช…๋ น์–ด๋ฅผ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋ฐ”๊ฟ‰๋‹ˆ๋‹ค.
      • JOB_ID: ๋งŒ๋“  ์ž‘์—…์˜ ID์ž…๋‹ˆ๋‹ค.
      • LOCATION: ์ž‘์—… ์œ„์น˜์ž…๋‹ˆ๋‹ค. ์ง€์›๋˜๋Š” ๋ฆฌ์ „ ์ค‘ ํ•˜๋‚˜๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
        ์œ„์น˜ ํ‘œ์‹œ
        • us-central1
        • us-west1
        • us-west2
        • us-east1
        • us-east4
        • southamerica-east1
        • northamerica-northeast1
        • asia-east1
        • asia-northeast1
        • asia-northeast3
        • asia-south1
        • asia-southeast1
        • australia-southeast1
        • europe-west1
        • europe-west2
        • europe-west4
        • me-west1
        • me-central1
        • me-central2
    2. ๋‹ค์Œ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.
      gcloud transcoder jobs describe JOB_ID --location=LOCATION
      ๋‹ค์Œ๊ณผ ๋น„์Šทํ•œ ์‘๋‹ต์ด ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค.
      {
        "name": "projects/PROJECT_NUMBER/locations/LOCATION/jobs/JOB_ID",
        "config": {
          "inputs": [
            {
              "key": "input0",
              "uri": "gs://STORAGE_BUCKET_NAME/STORAGE_INPUT_VIDEO"
            }
          ],
          "editList": [
            {
              "key": "atom0",
              "inputs": [
                "input0"
              ],
              "startTimeOffset": "0s"
            }
          ],
          "elementaryStreams": [
            {
              "videoStream": {
                "h264": {
                  "widthPixels": 640,
                  "heightPixels": 360,
                  "frameRate": 30,
                  "bitrateBps": 550000,
                  "pixelFormat": "yuv420p",
                  "rateControlMode": "vbr",
                  "crfLevel": 21,
                  "gopDuration": "3s",
                  "vbvSizeBits": 550000,
                  "vbvFullnessBits": 495000,
                  "entropyCoder": "cabac",
                  "bFrameCount": 3,
                  "aqStrength": 1,
                  "profile": "high",
                  "preset": "veryfast"
                }
              },
              "key": "video-stream0"
            },
            {
              "videoStream": {
                "h264": {
                  "widthPixels": 1280,
                  "heightPixels": 720,
                  "frameRate": 30,
                  "bitrateBps": 2500000,
                  "pixelFormat": "yuv420p",
                  "rateControlMode": "vbr",
                  "crfLevel": 21,
                  "gopDuration": "3s",
                  "vbvSizeBits": 2500000,
                  "vbvFullnessBits": 2250000,
                  "entropyCoder": "cabac",
                  "bFrameCount": 3,
                  "aqStrength": 1,
                  "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"
              ]
            },
            {
              "key": "media-sd",
              "fileName": "media-sd.ts",
              "container": "ts",
              "elementaryStreams": [
                "video-stream0",
                "audio-stream0"
              ]
            },
            {
              "key": "media-hd",
              "fileName": "media-hd.ts",
              "container": "ts",
              "elementaryStreams": [
                "video-stream1",
                "audio-stream0"
              ]
            },
            {
              "key": "video-only-sd",
              "fileName": "video-only-sd.m4s",
              "container": "fmp4",
              "elementaryStreams": [
                "video-stream0"
              ]
            },
            {
              "key": "video-only-hd",
              "fileName": "video-only-hd.m4s",
              "container": "fmp4",
              "elementaryStreams": [
                "video-stream1"
              ]
            },
            {
              "key": "audio-only",
              "fileName": "audio-only.m4s",
              "container": "fmp4",
              "elementaryStreams": [
                "audio-stream0"
              ]
            }
          ],
          "manifests": [
            {
              "fileName": "manifest.m3u8",
              "type": "HLS",
              "muxStreams": [
                "media-sd",
                "media-hd"
              ]
            },
            {
              "fileName": "manifest.mpd",
              "type": "DASH",
              "muxStreams": [
                "video-only-sd",
                "video-only-hd",
                "audio-only"
              ]
            }
          ],
          "output": {
            "uri": "gs://STORAGE_BUCKET_NAME/STORAGE_OUTPUT_FOLDER/"
          }
        },
        "state": "PENDING",
        "createTime": CREATE_TIME,
        "ttlAfterCompletionDays": 30
      }
      

    C#

    ์ด ์ƒ˜ํ”Œ์„ ์‚ฌ์šฉํ•ด ๋ณด๊ธฐ ์ „์— Transcoder API ๋น ๋ฅธ ์‹œ์ž‘: ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์‚ฌ์šฉ์˜ C# ์„ค์ • ์•ˆ๋‚ด๋ฅผ ๋”ฐ๋ฅด์„ธ์š”. ์ž์„ธํ•œ ๋‚ด์šฉ์€ Transcoder API C# API ์ฐธ๊ณ  ๋ฌธ์„œ๋ฅผ ํ™•์ธํ•˜์„ธ์š”.

    Transcoder API์— ์ธ์ฆํ•˜๋ ค๋ฉด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ธฐ๋ณธ ์‚ฌ์šฉ์ž ์ธ์ฆ ์ •๋ณด๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋กœ์ปฌ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์˜ ์ธ์ฆ ์„ค์ •์„ ์ฐธ์กฐํ•˜์„ธ์š”.

    
    using Google.Cloud.Video.Transcoder.V1;
    
    public class GetJobStateSample
    {
        public Job.Types.ProcessingState GetJobState(string projectId, string location, string jobId)
        {
            // Create the client.
            TranscoderServiceClient client = TranscoderServiceClient.Create();
    
            // Build the job name.
            JobName jobName = JobName.FromProjectLocationJob(projectId, location, jobId);
    
            // Call the API.
            Job job = client.GetJob(jobName);
    
            // Return the result.
            return job.State;
        }
    }

    Go

    ์ด ์ƒ˜ํ”Œ์„ ์‚ฌ์šฉํ•ด ๋ณด๊ธฐ ์ „์— Transcoder API ๋น ๋ฅธ ์‹œ์ž‘: ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์‚ฌ์šฉ์˜ Go ์„ค์ • ์•ˆ๋‚ด๋ฅผ ๋”ฐ๋ฅด์„ธ์š”. ์ž์„ธํ•œ ๋‚ด์šฉ์€ Transcoder API Go API ์ฐธ๊ณ  ๋ฌธ์„œ๋ฅผ ํ™•์ธํ•˜์„ธ์š”.

    Transcoder API์— ์ธ์ฆํ•˜๋ ค๋ฉด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ธฐ๋ณธ ์‚ฌ์šฉ์ž ์ธ์ฆ ์ •๋ณด๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋กœ์ปฌ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์˜ ์ธ์ฆ ์„ค์ •์„ ์ฐธ์กฐํ•˜์„ธ์š”.

    import (
    	"context"
    	"fmt"
    	"io"
    
    	transcoder "cloud.google.com/go/video/transcoder/apiv1"
    	"cloud.google.com/go/video/transcoder/apiv1/transcoderpb"
    )
    
    // getJobState gets the state for a previously-created job. See
    // https://cloud.google.com/transcoder/docs/how-to/jobs#check_job_status for
    // more information.
    func getJobState(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: %w", 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: %w", err)
    	}
    	fmt.Fprintf(w, "Job state: %v\n----\nJob failure reason:%v\n", response.State, response.Error)
    	return nil
    }
    

    Java

    ์ด ์ƒ˜ํ”Œ์„ ์‚ฌ์šฉํ•ด ๋ณด๊ธฐ ์ „์— Transcoder API ๋น ๋ฅธ ์‹œ์ž‘: ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์‚ฌ์šฉ์˜ Java ์„ค์ • ์•ˆ๋‚ด๋ฅผ ๋”ฐ๋ฅด์„ธ์š”. ์ž์„ธํ•œ ๋‚ด์šฉ์€ Transcoder API Java API ์ฐธ๊ณ  ๋ฌธ์„œ๋ฅผ ํ™•์ธํ•˜์„ธ์š”.

    Transcoder API์— ์ธ์ฆํ•˜๋ ค๋ฉด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ธฐ๋ณธ ์‚ฌ์šฉ์ž ์ธ์ฆ ์ •๋ณด๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋กœ์ปฌ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์˜ ์ธ์ฆ ์„ค์ •์„ ์ฐธ์กฐํ•˜์„ธ์š”.

    
    import com.google.cloud.video.transcoder.v1.GetJobRequest;
    import com.google.cloud.video.transcoder.v1.Job;
    import com.google.cloud.video.transcoder.v1.JobName;
    import com.google.cloud.video.transcoder.v1.TranscoderServiceClient;
    import java.io.IOException;
    
    public class GetJobState {
    
      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";
    
        getJobState(projectId, location, jobId);
      }
    
      // Gets the state of a job.
      public static void getJobState(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();
          GetJobRequest 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 state: " + job.getState());
        }
      }
    }

    Node.js

    ์ด ์ƒ˜ํ”Œ์„ ์‚ฌ์šฉํ•ด ๋ณด๊ธฐ ์ „์— Transcoder API ๋น ๋ฅธ ์‹œ์ž‘: ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์‚ฌ์šฉ์˜ Node.js ์„ค์ • ์•ˆ๋‚ด๋ฅผ ๋”ฐ๋ฅด์„ธ์š”. ์ž์„ธํ•œ ๋‚ด์šฉ์€ Transcoder API Node.js API ์ฐธ๊ณ  ๋ฌธ์„œ๋ฅผ ํ™•์ธํ•˜์„ธ์š”.

    Transcoder API์— ์ธ์ฆํ•˜๋ ค๋ฉด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ธฐ๋ณธ ์‚ฌ์šฉ์ž ์ธ์ฆ ์ •๋ณด๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋กœ์ปฌ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์˜ ์ธ์ฆ ์„ค์ •์„ ์ฐธ์กฐํ•˜์„ธ์š”.

    /**
     * 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').v1;
    
    // 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 state: ${response.state}`);
    }
    
    getJob();

    PHP

    ์ด ์ƒ˜ํ”Œ์„ ์‚ฌ์šฉํ•ด ๋ณด๊ธฐ ์ „์— Transcoder API ๋น ๋ฅธ ์‹œ์ž‘: ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์‚ฌ์šฉ์˜ PHP ์„ค์ • ์•ˆ๋‚ด๋ฅผ ๋”ฐ๋ฅด์„ธ์š”. ์ž์„ธํ•œ ๋‚ด์šฉ์€ Transcoder API PHP API ์ฐธ๊ณ  ๋ฌธ์„œ๋ฅผ ํ™•์ธํ•˜์„ธ์š”.

    Transcoder API์— ์ธ์ฆํ•˜๋ ค๋ฉด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ธฐ๋ณธ ์‚ฌ์šฉ์ž ์ธ์ฆ ์ •๋ณด๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋กœ์ปฌ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์˜ ์ธ์ฆ ์„ค์ •์„ ์ฐธ์กฐํ•˜์„ธ์š”.

    use Google\Cloud\Video\Transcoder\V1\Client\TranscoderServiceClient;
    use Google\Cloud\Video\Transcoder\V1\GetJobRequest;
    use Google\Cloud\Video\Transcoder\V1\Job;
    
    /**
     * Gets a Transcoder job's state.
     *
     * @param string $projectId The ID of your Google Cloud Platform project.
     * @param string $location The location of the job.
     * @param string $jobId The job ID.
     */
    function get_job_state($projectId, $location, $jobId)
    {
        // Instantiate a client.
        $transcoderServiceClient = new TranscoderServiceClient();
    
        $formattedName = $transcoderServiceClient->jobName($projectId, $location, $jobId);
        $request = (new GetJobRequest())
            ->setName($formattedName);
        $job = $transcoderServiceClient->getJob($request);
    
        // Print job state.
        printf('Job state: %s' . PHP_EOL, Job\ProcessingState::name($job->getState()));
    }

    Python

    ์ด ์ƒ˜ํ”Œ์„ ์‚ฌ์šฉํ•ด ๋ณด๊ธฐ ์ „์— Transcoder API ๋น ๋ฅธ ์‹œ์ž‘: ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์‚ฌ์šฉ์˜ Python ์„ค์ • ์•ˆ๋‚ด๋ฅผ ๋”ฐ๋ฅด์„ธ์š”. ์ž์„ธํ•œ ๋‚ด์šฉ์€ Transcoder API Python API ์ฐธ๊ณ  ๋ฌธ์„œ๋ฅผ ํ™•์ธํ•˜์„ธ์š”.

    Transcoder API์— ์ธ์ฆํ•˜๋ ค๋ฉด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ธฐ๋ณธ ์‚ฌ์šฉ์ž ์ธ์ฆ ์ •๋ณด๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋กœ์ปฌ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์˜ ์ธ์ฆ ์„ค์ •์„ ์ฐธ์กฐํ•˜์„ธ์š”.

    
    import argparse
    
    from google.cloud.video import transcoder_v1
    from google.cloud.video.transcoder_v1.services.transcoder_service import (
        TranscoderServiceClient,
    )
    
    
    def get_job_state(
        project_id: str,
        location: str,
        job_id: str,
    ) -> transcoder_v1.types.resources.Job:
        """Gets a job's state.
    
        Args:
            project_id: The GCP project ID.
            location: The location this job is in.
            job_id: The job ID.
    
        Returns:
            The job resource.
        """
    
        client = TranscoderServiceClient()
    
        name = f"projects/{project_id}/locations/{location}/jobs/{job_id}"
        response = client.get_job(name=name)
    
        print(f"Job state: {str(response.state.name)}")
        return response
    
    

    Ruby

    ์ด ์ƒ˜ํ”Œ์„ ์‚ฌ์šฉํ•ด ๋ณด๊ธฐ ์ „์— Transcoder API ๋น ๋ฅธ ์‹œ์ž‘: ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์‚ฌ์šฉ์˜ Ruby ์„ค์ • ์•ˆ๋‚ด๋ฅผ ๋”ฐ๋ฅด์„ธ์š”. ์ž์„ธํ•œ ๋‚ด์šฉ์€ Transcoder API Ruby API ์ฐธ๊ณ  ๋ฌธ์„œ๋ฅผ ํ™•์ธํ•˜์„ธ์š”.

    Transcoder API์— ์ธ์ฆํ•˜๋ ค๋ฉด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ธฐ๋ณธ ์‚ฌ์šฉ์ž ์ธ์ฆ ์ •๋ณด๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋กœ์ปฌ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์˜ ์ธ์ฆ ์„ค์ •์„ ์ฐธ์กฐํ•˜์„ธ์š”.

    # project_id = "YOUR-GOOGLE-CLOUD-PROJECT"  # (e.g. "my-project")
    # location   = "YOUR-JOB-LOCATION"  # (e.g. "us-central1")
    # job_id     = "YOUR-JOB-ID"  # (e.g. "c82c295b-3f5a-47df-8562-938a89d40fd0")
    
    # Require the Transcoder client library.
    require "google/cloud/video/transcoder"
    
    # Create a Transcoder client.
    client = Google::Cloud::Video::Transcoder.transcoder_service
    
    # Build the resource name of the job.
    name = client.job_path project: project_id, location: location, job: job_id
    
    # Get the job.
    job = client.get_job name: name
    
    # Print the job state.
    puts "Job state: #{job.state}"

    state๊ฐ€ SUCCEEDED์ด๋ฉด ์ž‘์—…์ด ์™„๋ฃŒ๋˜๊ณ  ์ด์ œ Cloud Storage ๋ฒ„ํ‚ท์˜ ์ธ์ฝ”๋”ฉ๋œ ํŒŒ์ผ ๋ชฉ๋ก์— ๋™์˜์ƒ ์ถœ๋ ฅ์ด ์ œ๊ณต๋ฉ๋‹ˆ๋‹ค.

    ๋™์˜์ƒ ์žฌ์ƒ

    ์ƒ์„ฑ๋œ ๋ฏธ๋””์–ด ํŒŒ์ผ์„ Shaka Player์—์„œ ์žฌ์ƒํ•˜๋ ค๋ฉด ๋‹ค์Œ ๋‹จ๊ณ„๋ฅผ ์™„๋ฃŒํ•ฉ๋‹ˆ๋‹ค.

    1. ๋งŒ๋“  Cloud Storage ๋ฒ„ํ‚ท์„ ๊ณต๊ฐœ์ ์œผ๋กœ ์ฝ์„ ์ˆ˜ ์žˆ๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.
    2. Cloud Storage ๋ฒ„ํ‚ท์—์„œ ๊ต์ฐจ ์ถœ์ฒ˜ ๋ฆฌ์†Œ์Šค ๊ณต์œ (CORS)๋ฅผ ์‚ฌ์šฉ ์„ค์ •ํ•˜๋ ค๋ฉด ๋‹ค์Œ์„ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค.
      1. ๋‹ค์Œ์„ ํฌํ•จํ•˜๋Š” JSON ํŒŒ์ผ์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค.
        [
          {
            "origin": ["https://shaka-player-demo.appspot.com/"],
            "responseHeader": ["Content-Type", "Range"],
            "method": ["GET", "HEAD"],
            "maxAgeSeconds": 3600
          }
        ]
      2. JSON_FILE_NAME์„ ์ด์ „ ๋‹จ๊ณ„์—์„œ ๋งŒ๋“  JSON ํŒŒ์ผ ์ด๋ฆ„์œผ๋กœ ๋ฐ”๊พผ ํ›„ ๋‹ค์Œ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.
        gcloud storage buckets update gs://STORAGE_BUCKET_NAME --cors-file=JSON_FILE_NAME.json
    3. Cloud Storage ๋ฒ„ํ‚ท์—์„œ ํŠธ๋žœ์Šค์ฝ”๋”ฉ ์ž‘์—…์œผ๋กœ ์ƒ์„ฑ๋œ MP4 ๋˜๋Š” ๋งค๋‹ˆํŽ˜์ŠคํŠธ ํŒŒ์ผ ์ค‘ ํ•˜๋‚˜๋ฅผ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค. ํŒŒ์ผ์˜ ๊ณต๊ฐœ ์•ก์„ธ์Šค ์—ด์—์„œ URL ๋ณต์‚ฌ๋ฅผ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค.
    4. ์˜จ๋ผ์ธ ์‹ค์‹œ๊ฐ„ ์ŠคํŠธ๋ฆผ ํ”Œ๋ ˆ์ด์–ด์ธ Shaka Player๋กœ ์ด๋™ํ•ฉ๋‹ˆ๋‹ค.
    5. ์ƒ๋‹จ ํƒ์ƒ‰ ๋ฉ”๋‰ด์—์„œ ์ปค์Šคํ…€ ์ฝ˜ํ…์ธ ๋ฅผ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค.
    6. + ๋ฒ„ํŠผ์„ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค.
    7. ํŒŒ์ผ์˜ ๊ณต๊ฐœ URL์„ ๋งค๋‹ˆํŽ˜์ŠคํŠธ URL ์ƒ์ž์— ๋ถ™์—ฌ๋„ฃ์Šต๋‹ˆ๋‹ค.

      Shaka Player์˜ ํŒŒ์ผ URL์„ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค.

    8. ์ด๋ฆ„ ์ƒ์ž์— ์ด๋ฆ„์„ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค.

    9. ์ €์žฅ์„ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค.

    10. ์žฌ์ƒ์„ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค.

    ์‚ญ์ œ

    ์ด ํŽ˜์ด์ง€์—์„œ ์‚ฌ์šฉํ•œ ๋ฆฌ์†Œ์Šค ๋น„์šฉ์ด Google Cloud ๊ณ„์ •์— ์ฒญ๊ตฌ๋˜์ง€ ์•Š๋„๋ก ํ•˜๋ ค๋ฉด ๋ฆฌ์†Œ์Šค๊ฐ€ ํฌํ•จ๋œ Google Cloud ํ”„๋กœ์ ํŠธ๋ฅผ ์‚ญ์ œํ•ฉ๋‹ˆ๋‹ค.

    ๋ฒ„ํ‚ท ์‚ญ์ œ

    1. Google Cloud ์ฝ˜์†”์—์„œ Cloud Storage ๋ธŒ๋ผ์šฐ์ € ํŽ˜์ด์ง€๋กœ ์ด๋™ํ•ฉ๋‹ˆ๋‹ค.

      Cloud Storage ๋ธŒ๋ผ์šฐ์ € ํŽ˜์ด์ง€๋กœ ์ด๋™

    2. ๋งŒ๋“  ๋ฒ„ํ‚ท ์˜†์— ์žˆ๋Š” ํ™•์ธ๋ž€์„ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.

    3. ์‚ญ์ œ๋ฅผ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค.

    4. ๋‚˜ํƒ€๋‚˜๋Š” ํŒ์—… ์ฐฝ์—์„œ ์‚ญ์ œ๋ฅผ ํด๋ฆญํ•˜์—ฌ ๋ฒ„ํ‚ท๊ณผ ์ฝ˜ํ…์ธ ๋ฅผ ์˜๊ตฌ ์‚ญ์ œํ•ฉ๋‹ˆ๋‹ค.

    ์ž‘์—… ์‚ญ์ œ

    REST

    ์š”์ฒญ ๋ฐ์ดํ„ฐ๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์ „์— ๋‹ค์Œ์„ ๋ฐ”๊ฟ‰๋‹ˆ๋‹ค.

  23. JOB_ID: ๋งŒ๋“  ์ž‘์—…์˜ ID์ž…๋‹ˆ๋‹ค.
  24. PROJECT_ID: Google Cloud ํ”„๋กœ์ ํŠธ ID์ž…๋‹ˆ๋‹ค.
  25. LOCATION: ์ž‘์—… ์œ„์น˜์ž…๋‹ˆ๋‹ค. ์ง€์›๋˜๋Š” ๋ฆฌ์ „ ์ค‘ ํ•˜๋‚˜๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
    ์œ„์น˜ ํ‘œ์‹œ
    • us-central1
    • us-west1
    • us-west2
    • us-east1
    • us-east4
    • southamerica-east1
    • northamerica-northeast1
    • asia-east1
    • asia-northeast1
    • asia-northeast3
    • asia-south1
    • asia-southeast1
    • australia-southeast1
    • europe-west1
    • europe-west2
    • europe-west4
    • me-west1
    • me-central1
    • me-central2
  26. ์š”์ฒญ์„ ๋ณด๋‚ด๋ ค๋ฉด ๋‹ค์Œ ์˜ต์…˜ ์ค‘ ํ•˜๋‚˜๋ฅผ ํŽผ์นฉ๋‹ˆ๋‹ค.

    ๋‹ค์Œ๊ณผ ๋น„์Šทํ•œ JSON ์‘๋‹ต์ด ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค.

    {}
    

    gcloud

    1. gcloud ๋ช…๋ น์–ด๋ฅผ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋ฐ”๊ฟ‰๋‹ˆ๋‹ค.
      • JOB_ID: ๋งŒ๋“  ์ž‘์—…์˜ ID์ž…๋‹ˆ๋‹ค.
      • LOCATION: ์ž‘์—… ์œ„์น˜์ž…๋‹ˆ๋‹ค. ์ง€์›๋˜๋Š” ๋ฆฌ์ „ ์ค‘ ํ•˜๋‚˜๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
        ์œ„์น˜ ํ‘œ์‹œ
        • us-central1
        • us-west1
        • us-west2
        • us-east1
        • us-east4
        • southamerica-east1
        • northamerica-northeast1
        • asia-east1
        • asia-northeast1
        • asia-northeast3
        • asia-south1
        • asia-southeast1
        • australia-southeast1
        • europe-west1
        • europe-west2
        • europe-west4
        • me-west1
        • me-central1
        • me-central2
    2. ๋‹ค์Œ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.
      gcloud transcoder jobs delete JOB_ID --location=LOCATION
      ๋‹ค์Œ๊ณผ ๋น„์Šทํ•œ ์‘๋‹ต์ด ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค.
      Deleted job [projects/PROJECT_ID/locations/LOCATION/jobs/JOB_ID].
      

    C#

    ์ด ์ƒ˜ํ”Œ์„ ์‚ฌ์šฉํ•ด ๋ณด๊ธฐ ์ „์— Transcoder API ๋น ๋ฅธ ์‹œ์ž‘: ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์‚ฌ์šฉ์˜ C# ์„ค์ • ์•ˆ๋‚ด๋ฅผ ๋”ฐ๋ฅด์„ธ์š”. ์ž์„ธํ•œ ๋‚ด์šฉ์€ Transcoder API C# API ์ฐธ๊ณ  ๋ฌธ์„œ๋ฅผ ํ™•์ธํ•˜์„ธ์š”.

    Transcoder API์— ์ธ์ฆํ•˜๋ ค๋ฉด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ธฐ๋ณธ ์‚ฌ์šฉ์ž ์ธ์ฆ ์ •๋ณด๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋กœ์ปฌ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์˜ ์ธ์ฆ ์„ค์ •์„ ์ฐธ์กฐํ•˜์„ธ์š”.

    
    using Google.Cloud.Video.Transcoder.V1;
    
    public class DeleteJobSample
    {
        public void DeleteJob(string projectId, string location, string jobId)
        {
            // Create the client.
            TranscoderServiceClient client = TranscoderServiceClient.Create();
    
            // Build the job name.
            JobName jobName = JobName.FromProjectLocationJob(projectId, location, jobId);
    
            // Call the API.
            client.DeleteJob(jobName);
        }
    }

    Go

    ์ด ์ƒ˜ํ”Œ์„ ์‚ฌ์šฉํ•ด ๋ณด๊ธฐ ์ „์— Transcoder API ๋น ๋ฅธ ์‹œ์ž‘: ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์‚ฌ์šฉ์˜ Go ์„ค์ • ์•ˆ๋‚ด๋ฅผ ๋”ฐ๋ฅด์„ธ์š”. ์ž์„ธํ•œ ๋‚ด์šฉ์€ Transcoder API Go API ์ฐธ๊ณ  ๋ฌธ์„œ๋ฅผ ํ™•์ธํ•˜์„ธ์š”.

    Transcoder API์— ์ธ์ฆํ•˜๋ ค๋ฉด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ธฐ๋ณธ ์‚ฌ์šฉ์ž ์ธ์ฆ ์ •๋ณด๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋กœ์ปฌ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์˜ ์ธ์ฆ ์„ค์ •์„ ์ฐธ์กฐํ•˜์„ธ์š”.

    import (
    	"context"
    	"fmt"
    	"io"
    
    	transcoder "cloud.google.com/go/video/transcoder/apiv1"
    	"cloud.google.com/go/video/transcoder/apiv1/transcoderpb"
    )
    
    // 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: %w", 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: %w", err)
    	}
    
    	fmt.Fprintf(w, "Deleted job")
    	return nil
    }
    

    Java

    ์ด ์ƒ˜ํ”Œ์„ ์‚ฌ์šฉํ•ด ๋ณด๊ธฐ ์ „์— Transcoder API ๋น ๋ฅธ ์‹œ์ž‘: ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์‚ฌ์šฉ์˜ Java ์„ค์ • ์•ˆ๋‚ด๋ฅผ ๋”ฐ๋ฅด์„ธ์š”. ์ž์„ธํ•œ ๋‚ด์šฉ์€ Transcoder API Java API ์ฐธ๊ณ  ๋ฌธ์„œ๋ฅผ ํ™•์ธํ•˜์„ธ์š”.

    Transcoder API์— ์ธ์ฆํ•˜๋ ค๋ฉด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ธฐ๋ณธ ์‚ฌ์šฉ์ž ์ธ์ฆ ์ •๋ณด๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋กœ์ปฌ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์˜ ์ธ์ฆ ์„ค์ •์„ ์ฐธ์กฐํ•˜์„ธ์š”.

    
    import com.google.cloud.video.transcoder.v1.DeleteJobRequest;
    import com.google.cloud.video.transcoder.v1.JobName;
    import com.google.cloud.video.transcoder.v1.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();
          DeleteJobRequest 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

    ์ด ์ƒ˜ํ”Œ์„ ์‚ฌ์šฉํ•ด ๋ณด๊ธฐ ์ „์— Transcoder API ๋น ๋ฅธ ์‹œ์ž‘: ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์‚ฌ์šฉ์˜ Node.js ์„ค์ • ์•ˆ๋‚ด๋ฅผ ๋”ฐ๋ฅด์„ธ์š”. ์ž์„ธํ•œ ๋‚ด์šฉ์€ Transcoder API Node.js API ์ฐธ๊ณ  ๋ฌธ์„œ๋ฅผ ํ™•์ธํ•˜์„ธ์š”.

    Transcoder API์— ์ธ์ฆํ•˜๋ ค๋ฉด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ธฐ๋ณธ ์‚ฌ์šฉ์ž ์ธ์ฆ ์ •๋ณด๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋กœ์ปฌ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์˜ ์ธ์ฆ ์„ค์ •์„ ์ฐธ์กฐํ•˜์„ธ์š”.

    /**
     * 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').v1;
    
    // 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();

    PHP

    ์ด ์ƒ˜ํ”Œ์„ ์‚ฌ์šฉํ•ด ๋ณด๊ธฐ ์ „์— Transcoder API ๋น ๋ฅธ ์‹œ์ž‘: ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์‚ฌ์šฉ์˜ PHP ์„ค์ • ์•ˆ๋‚ด๋ฅผ ๋”ฐ๋ฅด์„ธ์š”. ์ž์„ธํ•œ ๋‚ด์šฉ์€ Transcoder API PHP API ์ฐธ๊ณ  ๋ฌธ์„œ๋ฅผ ํ™•์ธํ•˜์„ธ์š”.

    Transcoder API์— ์ธ์ฆํ•˜๋ ค๋ฉด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ธฐ๋ณธ ์‚ฌ์šฉ์ž ์ธ์ฆ ์ •๋ณด๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋กœ์ปฌ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์˜ ์ธ์ฆ ์„ค์ •์„ ์ฐธ์กฐํ•˜์„ธ์š”.

    use Google\Cloud\Video\Transcoder\V1\Client\TranscoderServiceClient;
    use Google\Cloud\Video\Transcoder\V1\DeleteJobRequest;
    
    /**
     * Deletes a Transcoder job.
     *
     * @param string $projectId The ID of your Google Cloud Platform project.
     * @param string $location The location of the job.
     * @param string $jobId The job ID.
     */
    function delete_job($projectId, $location, $jobId)
    {
        // Instantiate a client.
        $transcoderServiceClient = new TranscoderServiceClient();
    
        $formattedName = $transcoderServiceClient->jobName($projectId, $location, $jobId);
        $request = (new DeleteJobRequest())
            ->setName($formattedName);
        $transcoderServiceClient->deleteJob($request);
    
        print('Deleted job' . PHP_EOL);
    }

    Python

    ์ด ์ƒ˜ํ”Œ์„ ์‚ฌ์šฉํ•ด ๋ณด๊ธฐ ์ „์— Transcoder API ๋น ๋ฅธ ์‹œ์ž‘: ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์‚ฌ์šฉ์˜ Python ์„ค์ • ์•ˆ๋‚ด๋ฅผ ๋”ฐ๋ฅด์„ธ์š”. ์ž์„ธํ•œ ๋‚ด์šฉ์€ Transcoder API Python API ์ฐธ๊ณ  ๋ฌธ์„œ๋ฅผ ํ™•์ธํ•˜์„ธ์š”.

    Transcoder API์— ์ธ์ฆํ•˜๋ ค๋ฉด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ธฐ๋ณธ ์‚ฌ์šฉ์ž ์ธ์ฆ ์ •๋ณด๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋กœ์ปฌ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์˜ ์ธ์ฆ ์„ค์ •์„ ์ฐธ์กฐํ•˜์„ธ์š”.

    
    import argparse
    
    from google.cloud.video.transcoder_v1.services.transcoder_service import (
        TranscoderServiceClient,
    )
    
    
    def delete_job(
        project_id: str,
        location: str,
        job_id: str,
    ) -> None:
        """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
    
    

    Ruby

    ์ด ์ƒ˜ํ”Œ์„ ์‚ฌ์šฉํ•ด ๋ณด๊ธฐ ์ „์— Transcoder API ๋น ๋ฅธ ์‹œ์ž‘: ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์‚ฌ์šฉ์˜ Ruby ์„ค์ • ์•ˆ๋‚ด๋ฅผ ๋”ฐ๋ฅด์„ธ์š”. ์ž์„ธํ•œ ๋‚ด์šฉ์€ Transcoder API Ruby API ์ฐธ๊ณ  ๋ฌธ์„œ๋ฅผ ํ™•์ธํ•˜์„ธ์š”.

    Transcoder API์— ์ธ์ฆํ•˜๋ ค๋ฉด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ธฐ๋ณธ ์‚ฌ์šฉ์ž ์ธ์ฆ ์ •๋ณด๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋กœ์ปฌ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์˜ ์ธ์ฆ ์„ค์ •์„ ์ฐธ์กฐํ•˜์„ธ์š”.

    # project_id = "YOUR-GOOGLE-CLOUD-PROJECT"  # (e.g. "my-project")
    # location   = "YOUR-JOB-LOCATION"  # (e.g. "us-central1")
    # job_id     = "YOUR-JOB-ID"  # (e.g. "c82c295b-3f5a-47df-8562-938a89d40fd0")
    
    # Require the Transcoder client library.
    require "google/cloud/video/transcoder"
    
    # Create a Transcoder client.
    client = Google::Cloud::Video::Transcoder.transcoder_service
    
    # Build the resource name of the job.
    name = client.job_path project: project_id, location: location, job: job_id
    
    # Delete the job.
    client.delete_job name: name
    
    # Print a success message.
    puts "Deleted job"

    ์‚ฌ์šฉ์ž ์ธ์ฆ ์ •๋ณด ์ทจ์†Œ

    1. Optional: Revoke the authentication credentials that you created, and delete the local credential file.

      gcloud auth application-default revoke
    2. Optional: Revoke credentials from the gcloud CLI.

      gcloud auth revoke

    ๋‹ค์Œ ๋‹จ๊ณ„