選取您的 Cookie 偏好設定

我們使用提供自身網站和服務所需的基本 Cookie 和類似工具。我們使用效能 Cookie 收集匿名統計資料,以便了解客戶如何使用我們的網站並進行改進。基本 Cookie 無法停用,但可以按一下「自訂」或「拒絕」以拒絕效能 Cookie。

如果您同意,AWS 與經核准的第三方也會使用 Cookie 提供實用的網站功能、記住您的偏好設定,並顯示相關內容,包括相關廣告。若要接受或拒絕所有非必要 Cookie,請按一下「接受」或「拒絕」。若要進行更詳細的選擇,請按一下「自訂」。

GetJob 搭配 AWS SDK 或 CLI 使用 - AWS SDK 程式碼範例

文件 AWS 開發套件範例 GitHub 儲存庫中有更多可用的 AWS SDK 範例

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

文件 AWS 開發套件範例 GitHub 儲存庫中有更多可用的 AWS SDK 範例

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

GetJob 搭配 AWS SDK 或 CLI 使用

下列程式碼範例示範如何使用 GetJob

.NET
AWS SDK for .NET
注意

GitHub 上提供更多範例。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫中設定和執行。

設定檔案位置、用戶端和包裝函式。

// MediaConvert role Amazon Resource Name (ARN). // For information on creating this role, see // https://docs.aws.amazon.com/mediaconvert/latest/ug/creating-the-iam-role-in-mediaconvert-configured.html. var mediaConvertRole = _configuration["mediaConvertRoleARN"]; // Include the file input and output locations in settings.json or settings.local.json. var fileInput = _configuration["fileInput"]; var fileOutput = _configuration["fileOutput"]; AmazonMediaConvertClient mcClient = new AmazonMediaConvertClient(); var wrapper = new MediaConvertWrapper(mcClient);

依任務的 ID 取得任務。

Console.WriteLine(new string('-', 80)); Console.WriteLine($"Getting job information for Job ID {jobId}"); var job = await wrapper.GetJobById(jobId); Console.WriteLine($"Job {job.Id} created on {job.CreatedAt:d} has status {job.Status}."); Console.WriteLine(new string('-', 80));
/// <summary> /// Get the job information for a job by its ID. /// </summary> /// <param name="jobId">The ID of the job.</param> /// <returns>The Job object.</returns> public async Task<Job> GetJobById(string jobId) { var jobResponse = await _amazonMediaConvert.GetJobAsync( new GetJobRequest { Id = jobId }); return jobResponse.Job; }
  • 如需 API 詳細資訊,請參閱《AWS SDK for .NET API 參考》中的 GetJob

C++
SDK for C++
注意

GitHub 上提供更多範例。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫中設定和執行。

//! Retrieve the information for a specific completed transcoding job. /*! \param jobID: A job ID. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::MediaConvert::getJob(const Aws::String &jobID, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::MediaConvert::MediaConvertClient client(clientConfiguration); Aws::MediaConvert::Model::GetJobRequest request; request.SetId(jobID); const Aws::MediaConvert::Model::GetJobOutcome outcome = client.GetJob( request); if (outcome.IsSuccess()) { std::cout << outcome.GetResult().GetJob().Jsonize().View().WriteReadable() << std::endl; } else { std::cerr << "DescribeEndpoints error - " << outcome.GetError().GetMessage() << std::endl; } return outcome.IsSuccess(); }
  • 如需 API 詳細資訊,請參閱《AWS SDK for C++ API 參考》中的 GetJob

CLI
AWS CLI

取得特定任務的詳細資訊

下列範例會請求 ID 為 的任務資訊1234567890987-1ab2c3,在此範例中, ID 為 結束的錯誤。

aws mediaconvert get-job \ --endpoint-url https://abcd1234.mediaconvert.region-name-1.amazonaws.com \ --region region-name-1 \ --id 1234567890987-1ab2c3

若要取得您的帳戶特定端點,請使用 describe-endpoints,或傳送不含端點的 命令。服務會傳回錯誤和您的端點。

如果您的請求成功,服務會傳回包含任務資訊的 JSON 檔案,包括任務設定、任何傳回的錯誤,以及其他任務資料,如下所示:

{ "Job": { "Status": "ERROR", "Queue": "arn:aws:mediaconvert:region-name-1:012345678998:queues/Queue1", "Settings": { ...<truncated for brevity>... }, "ErrorMessage": "Unable to open input file [s3://my-input-bucket/file-name.mp4]: [Failed probe/open: [Failed to read data: AssumeRole failed]]", "ErrorCode": 1434, "Role": "arn:aws:iam::012345678998:role/MediaConvertServiceRole", "Arn": "arn:aws:mediaconvert:us-west-1:012345678998:jobs/1234567890987-1ab2c3", "UserMetadata": {}, "Timing": { "FinishTime": 1517442131, "SubmitTime": 1517442103, "StartTime": 1517442104 }, "Id": "1234567890987-1ab2c3", "CreatedAt": 1517442103 } }

如需詳細資訊,請參閱《AWS Elemental MediaConvert 使用者指南》中的使用 Elemental MediaConvert 任務AWS MediaConvert

  • 如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 GetJob

Java
SDK for Java 2.x
注意

GitHub 上提供更多範例。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫中設定和執行。

import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.mediaconvert.model.DescribeEndpointsResponse; import software.amazon.awssdk.services.mediaconvert.model.GetJobRequest; import software.amazon.awssdk.services.mediaconvert.model.DescribeEndpointsRequest; import software.amazon.awssdk.services.mediaconvert.model.GetJobResponse; import software.amazon.awssdk.services.mediaconvert.model.MediaConvertException; import software.amazon.awssdk.services.mediaconvert.MediaConvertClient; import java.net.URI; /** * Before running this Java V2 code example, set up your development * environment, including your credentials. * * For more information, see the following documentation topic: * * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html */ public class GetJob { public static void main(String[] args) { final String usage = "\n" + " <jobId> \n\n" + "Where:\n" + " jobId - The job id value.\n\n"; if (args.length != 1) { System.out.println(usage); System.exit(1); } String jobId = args[0]; Region region = Region.US_WEST_2; MediaConvertClient mc = MediaConvertClient.builder() .region(region) .build(); getSpecificJob(mc, jobId); mc.close(); } public static void getSpecificJob(MediaConvertClient mc, String jobId) { try { DescribeEndpointsResponse res = mc.describeEndpoints(DescribeEndpointsRequest.builder() .maxResults(20) .build()); if (res.endpoints().size() <= 0) { System.out.println("Cannot find MediaConvert service endpoint URL!"); System.exit(1); } String endpointURL = res.endpoints().get(0).url(); MediaConvertClient emc = MediaConvertClient.builder() .region(Region.US_WEST_2) .endpointOverride(URI.create(endpointURL)) .build(); GetJobRequest jobRequest = GetJobRequest.builder() .id(jobId) .build(); GetJobResponse response = emc.getJob(jobRequest); System.out.println("The ARN of the job is " + response.job().arn()); } catch (MediaConvertException e) { System.out.println(e.toString()); System.exit(0); } } }
  • 如需 API 詳細資訊,請參閱《AWS SDK for Java 2.x API 參考》中的 GetJob

Kotlin
SDK for Kotlin
注意

GitHub 上提供更多範例。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫中設定和執行。

suspend fun getSpecificJob( mcClient: MediaConvertClient, jobId: String?, ) { val describeEndpoints = DescribeEndpointsRequest { maxResults = 20 } val res = mcClient.describeEndpoints(describeEndpoints) if (res.endpoints?.size!! <= 0) { println("Cannot find MediaConvert service endpoint URL!") exitProcess(0) } val endpointURL = res.endpoints!!.get(0).url!! val mediaConvert = MediaConvertClient.fromEnvironment { region = "us-west-2" endpointProvider = MediaConvertEndpointProvider { Endpoint(endpointURL) } } val jobRequest = GetJobRequest { id = jobId } val response: GetJobResponse = mediaConvert.getJob(jobRequest) println("The ARN of the job is ${response.job?.arn}.") }
  • 如需 API 詳細資訊,請參閱 AWS SDK for Kotlin API 參考中的 GetJob

AWS SDK for .NET
注意

GitHub 上提供更多範例。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫中設定和執行。

設定檔案位置、用戶端和包裝函式。

// MediaConvert role Amazon Resource Name (ARN). // For information on creating this role, see // https://docs.aws.amazon.com/mediaconvert/latest/ug/creating-the-iam-role-in-mediaconvert-configured.html. var mediaConvertRole = _configuration["mediaConvertRoleARN"]; // Include the file input and output locations in settings.json or settings.local.json. var fileInput = _configuration["fileInput"]; var fileOutput = _configuration["fileOutput"]; AmazonMediaConvertClient mcClient = new AmazonMediaConvertClient(); var wrapper = new MediaConvertWrapper(mcClient);

依任務的 ID 取得任務。

Console.WriteLine(new string('-', 80)); Console.WriteLine($"Getting job information for Job ID {jobId}"); var job = await wrapper.GetJobById(jobId); Console.WriteLine($"Job {job.Id} created on {job.CreatedAt:d} has status {job.Status}."); Console.WriteLine(new string('-', 80));
/// <summary> /// Get the job information for a job by its ID. /// </summary> /// <param name="jobId">The ID of the job.</param> /// <returns>The Job object.</returns> public async Task<Job> GetJobById(string jobId) { var jobResponse = await _amazonMediaConvert.GetJobAsync( new GetJobRequest { Id = jobId }); return jobResponse.Job; }
  • 如需 API 詳細資訊,請參閱《AWS SDK for .NET API 參考》中的 GetJob

下一個主題:

ListJobs

上一個主題:

CreateJob
隱私權網站條款Cookie 偏好設定
© 2025, Amazon Web Services, Inc.或其附屬公司。保留所有權利。