package org.example.CreateVideoConvertJob;
import com.volcengine.tos.TOSV2;
import com.volcengine.tos.TOSV2ClientBuilder;
import com.volcengine.tos.TosClientException;
import com.volcengine.tos.TosServerException;
import com.volcengine.tos.comm.common.*;
import com.volcengine.tos.model.bucket.*;
import com.volcengine.tos.model.object.*;
public class CreateVideoConvertJobExample2 {
public static void main(String[] args) {
String endpoint = System.getenv("TOS_ENDPOINT");
String region = System.getenv("TOS_REGION");
String accessKey = System.getenv("TOS_ACCESS_KEY");
String secretKey = System.getenv("TOS_SECRET_KEY");
String bucketName = System.getenv("TOS_BUCKET");
TOSV2 tos = new TOSV2ClientBuilder().build(region, endpoint, accessKey, secretKey);
Container container = Container.builder()
.format(ContainerFormatType.MP4)
Video video = Video.builder()
Audio audio = Audio.builder()
TimeInterval timeInterval = TimeInterval.builder()
Transcode transcode = Transcode.builder()
.timeInterval(timeInterval)
TranscodeConfig transcodeConfig = TranscodeConfig.builder()
ConvertJobInput jobInput = ConvertJobInput.builder()
.object("example-input.mp4")
ConvertJobOutput jobOutput = ConvertJobOutput.builder()
.object("example-output.mp4")
CreateVideoConvertJobInput input = CreateVideoConvertJobInput.builder()
.transcodeConfig(transcodeConfig)
.callback("http://example.com/callback")
CreateVideoConvertJobOutput output = tos.createVideoConvertJob(input);
System.out.println("Video transcoding task created successfully");
System.out.println("RequestID: " + output.getRequestInfo().getRequestId());
System.out.println("StatusCode: " + output.getRequestInfo().getStatusCode());
System.out.println("JobID: " + output.getJobId());
} catch (TosClientException e) {
# The operation failed and a client exception was caught. This is usually due to invalid request parameters or a network exception. The request was not sent in this case.
System.out.println("Operation failed");
System.out.println("Message: " + e.getMessage());
if (e.getCause() != null) {
e.getCause().printStackTrace();
} catch (TosServerException e) {
# The operation failed and a server exception occurred. See the response for the error details.
System.out.println("Operation failed");
System.out.println("StatusCode: " + e.getStatusCode());
System.out.println("Code: " + e.getCode());
System.out.println("Message: " + e.getMessage());
System.out.println("RequestID: " + e.getRequestID());
System.out.println("Operation failed");
System.out.println("Unexpected exception, message: " + t.getMessage());