Creating a Transcoding Task
You can create a transcoding task by creating an MpcClient instance and setting related parameters.
Core Code
- Create MPC configuration items.
These configuration items are used for MPC to obtain authorization. Table 1 describes the parameters.
1 2 3 4 5
MpcConfig mpcConfig = new MpcConfig(); mpcConfig.setEndPoint(endPoint);// Set the endpoint. mpcConfig.setProjectId(projectId);// Set the project ID. mpcConfig.setSk(sk);// Set the SK. mpcConfig.setAk(ak);// Set the AK.
Table 1 MPC parameters Parameter
Type
Description
endPoint
String
Endpoint. For details, see Obtaining an Endpoint.
ProjectId
String
Project ID. For details, see Obtaining a Project ID and Account Name.
ak
String
Access key ID (AK). For details, see Obtaining the AK/SK Pair.
sk
String
Secret Access Key (SK) used together with the AK. For details, see Obtaining the AK/SK Pair.
- Create an MpcClient instance.
If no proxy server is configured, you can directly create an MpcClient instance.
1 2
// Create an MpcClient instance. MpcClient mpcClient = new MpcClient(mpcConfig);
If a proxy server needs to be configured, set proxy parameters and then transfer the proxy as a constructor to the MpcClient instance.1 2 3 4 5 6 7 8
// Configure the proxy. ClientConfig clientConfig = new ClientConfig(); clientConfig.setProxyHost(proxyHost);// Set the IP address of the proxy server. clientConfig.setProxyPort(Integer.parseInt(proxyPort));// Set the port number of the proxy server. clientConfig.setProxyUserName(proxyUserName);// Set the username for accessing the proxy server. clientConfig.setProxyPassword(proxyPassword);// Set the password for accessing the proxy server. // Use the constructor to initialize MpcClient. MpcClient mpcClient =new MpcClient(mpcConfig, clientConfig);
- Create a transcoding request.
A transcoding request includes information about an input file and output file, and transcoding template settings. For details about the parameters, see Creating a Transcoding Task.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
// Create a transcoding request. CreateTranscodingRequest createTranscodingRequest = new CreateTranscodingRequest(); // Set input file path parameters. You can view the path parameters on the HUAWEI CLOUD OBS console. ObsObjInfo input = new ObsObjInfo(); // Set the bucket name. input.setBucket("bucketName"); // Set the input file path. input.setObject("objectKey"); // Set the region where an input bucket is deployed. input.setLocation("cn-north-4"); createTranscodingRequest.setInput(input); // Set output file path parameters. You can view the path parameters on the HUAWEI CLOUD OBS console. ObsObjInfo output = new ObsObjInfo(); // Set the bucket name. output.setBucket("bucketName"); // Set the output file path. output.setObject("path"); // Set the region where an output bucket is deployed. output.setLocation("cn-north-4"); createTranscodingRequest.setOutput(output); // Set the transcoding template ID. // The video bitrate, video height, video width, and audio bitrate in transcoding templates can be changed, but other parameters remain the same. // A maximum of nine template IDs are supported. List<Long> transTempIds = new ArrayList<Long>(); transTempIds.add(203L); transTempIds.add(212L); transTempIds.add(210L); createTranscodingRequest.setTransTemplateId(transTempIds);
Parameter
Type
Description
bucketName
String
OBS bucket name
location
String
Location of the input OBS bucket
path
String
OBS object path, which complies with the OSS Object definition.
If this parameter is used for an input, a specific object must be specified.
If this parameter is used for an output, only the directory for storing the output needs to be specified.
- (Optional) Set transcoding parameters.
You can select either the transcoding parameters or transcoding template ID. If both the transcoding template ID and transcoding parameters are set, the transcoding parameters are used first.
- Create a transcoding parameter object.
1 2
List<AvParmeters> avParmetersList = new LinkedList<>(); AvParmeters transTemplate = new AvParmeters();
- Configure common parameters.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
BaseCommonBean common = new BaseCommonBean(); // Set the packaging type (DASH+MP4 or HLS+TS). // Describe the packaging format based on the bitmap. Each bit represents a packaging format. // 00000001: DASH+MP4 // 00000010: HLS+TS // 00000011: HLS+TS and DASH+MP4 // 00000100: DASH+MP4 (common) // 00000101: TS common.setPackType(2); // HLS segment interval, in seconds. The value ranges from 2 to 10. The default value is 5. common.setHlsInterval(5); transTemplate.setCommon(common);
- Set video parameters. If you want to disable video, set video to null.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
BaseVideoBean video = new BaseVideoBean(); // Set the average output bitrate, in kbit/s. The value ranges from 40 to 30,000 or is 0. The value 0 indicates adaptive bitrate. video.setBitrate(1000); // Video codec // 1: VIDEO_CODEC_H264 // 2: VIDEO_CODEC_H265 // 3: VIDEO_CODEC_AVS2 video.setCodec(1); // Set the frame rate (unit: FPS). The value ranges from 1 to 1,000. The value 1, 2, 3, 4, or 5 indicates the adaptive frame rate. video.setFrameRate(30); // Set the video width (unit: pixel). // H.264: The value is 0 (adaptive) or a multiple of 2 from 32 to 4,096. // H.265: The value is 0 (adaptive) or a multiple of 2 from 160 to 4,096. video.setWidth(270); // Set the video height (unit: pixel). // H.264: The value is 0 (adaptive) or a multiple of 2 from 32 to 2,880. // H.265: The value is 0 (adaptive) or a multiple of 2 from 96 to 2,880. video.setHeight(480); // Set whether to enable black bar removal. // 0: Disable black bar removal. // 1: Enable black bar removal and low-complexity algorithms for long videos (>5 minutes). // 2: Enable black bar removal and high-complexity algorithms for short videos (≤5 minutes). video.setBlackCut(0); transTemplate.setVideo(video);
- Set audio parameters. If you want to disable audio, set audio to null.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
BaseAudioBean audio = new BaseAudioBean(); // Audio codec // 1: AUDIO_CODECTYPE_AAC (default) // 2: AUDIO_CODECTYPE_HEAAC1 // 3: AUDIO_CODECTYPE_HEAAC2 // 4: AUDIO_CODECTYPE_MP3 audio.setCodec(4); // Audio bitrate, in kbit/s. The value is 0 (adaptive) or ranges from 8 to 1,000. audio.setBitrate(126); // Audio sampling rate // 1: AUDIO_SAMPLE_AUTO (default value), indicating that the sampling rate of an output audio is the same as that of an input audio. // 2: AUDIO_SAMPLE_22050 // 3: AUDIO_SAMPLE_32000 // 4: AUDIO_SAMPLE_44100 // 5: AUDIO_SAMPLE_48000 // 6: AUDIO_SAMPLE_96000 // If audio.setCodec is 4 (MP3), the value of audio.setSampleRate ranges from 1 to 5. audio.setSampleRate(5); // Number of audio channels // 1: AUDIO_CHANNELS_1 // 2: AUDIO_CHANNELS_2 (default) // 3: AUDIO_CHANNELS_4 // 4: AUDIO_CHANNELS_5 // 5: AUDIO_CHANNELS_6 // 6: AUDIO_CHANNELS_8 // If audio.setCodec is 4 (MP3), the value of audio.setChannels is 1 or 2. audio.setChannels(2); transTemplate.setAudio(audio);
- Add the transcoding parameters to the transcoding request.
1 2
avParmetersList.add(transTemplate); req.setAvParmeters(avParmetersList);
- Create a transcoding parameter object.
- Set transcoding-related parameters.
Set the following parameters based on your needs. If you do not need the parameters, skip them.
- Transcoding priority
1 2 3
// Set the transcoding priority. Currently, the value can only be 6 or 9. // 6: medium (default value ); 9: high createTranscodingRequest.setPriority(6);
- Video processing parameters
1 2 3 4 5 6 7
// Set video processing parameters if needed. VideoProcess videoProcess = new VideoProcess(); // Adaptive resolution. SHORT (default value): Adaptive width; LONG: Adaptive height; NONE: Do not adapt. videoProcess.setAdaptation(VideoProcess.AdaptationEnum.LONG); // Clockwise rotation angle of a video. 0: Do not rotate. 1: Rotate a video clockwise by 90 degrees. 2: Rotate a video clockwise by 180 degrees. 3: Rotate a video clockwise by 270 degrees. videoProcess.setRotate(1); createTranscodingRequest.setVideoProcess(videoProcess);
- Watermark
Before enabling watermarking, upload the watermark image to an OBS bucket and obtain the permission to access the OBS bucket. For details, see Authorizing Access to Cloud Resources.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
// Set the watermark function. CreateTranscodingRequest.Watermark watermark = new CreateTranscodingRequest.Watermark(); watermark.setTemplateId("watermark_template_id"); // Set the watermark image address. ObsObjInfo watermarkInput = new ObsObjInfo(); // Bucket that stores the watermark image watermarkInput.setBucket("bucketName"); // Path to the watermark image watermarkInput.setObject("objectKey"); // Region where the watermark image resides watermarkInput.setLocation("cn-north-4"); watermark.setInput(watermarkInput); // Watermark image parameters used for overwriting fields in the template ImageWatermark imageWatermark = new ImageWatermark(); // Overwrite the dx parameter and other parameters. imageWatermark.setDx("30"); watermark.setImageWatermark(imageWatermark); // Base64-coded image content // For example, if you want to add the text watermark "test text watermark", the value is 5rWL6K+V5paH5a2X5rC05Y2w. watermark.setTextContext("5rWL6K+V5paH5a2X5rC05Y2w"); TextWatermark textWatermark = new TextWatermark(); // Font color // Currently, black, blue, white, green, red, yellow, brown, gold, pink, orange, and purple are supported. // The default color is white. textWatermark.setFontColor("black"); // Font. Currently, fzyouh and msyh are supported. // The default font is msyh. textWatermark.setFontName("fzyouh"); // Font size. Its value ranges from 4 to 120. The default value is 16. textWatermark.setFontSize(16); watermark.setTextWatermark(textWatermark); List<CreateTranscodingRequest.Watermark> watermarks = new ArrayList<CreateTranscodingRequest.Watermark>(); watermarks.add(watermark); CreateTranscodingRequest.Watermark[] watermarkArray = new CreateTranscodingRequest.Watermark[watermarks.size()]; createTranscodingRequest.setWatermarks(watermarks.toArray(watermarkArray));
- Snapshot
Before enabling the snapshot function, set an OBS bucket for storing snapshots and obtain the permission to access the bucket. For details, see Authorizing Access to Cloud Resources.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
// Set snapshot parameters. CreateTranscodingRequest.Thumbnail thumbnail = new CreateTranscodingRequest.Thumbnail(); // Set which format snapshot files are compressed into. In this example, the .tar format is used. thumbnail.setTar(1); // Set the location for storing snapshot files. Ensure that MPC has been authorized to access the bucket that stores snapshot files. ObsObjInfo thumbOutput = new ObsObjInfo(); // OBS bucket name thumbOutput.setBucket("obs-bills"); // Region where the OBS bucket is located. The OBS bucket must be in the same region as MPC. thumbOutput.setLocation("cn-north-4"); // Storage path in the OBS bucket thumbOutput.setObject("output/thumbnail/"); thumbnail.setThumbOutput(thumbOutput); CreateThumbnailRequest.ThumbnailPara thumbnailPara = new CreateThumbnailRequest.ThumbnailPara(); // Sampling type. Three options are available: PERCENT, TIME, and DOTS. PERCENT indicates sampling based on a percentage of the video duration. Time indicates sampling by interval. DOTS indicating sampling based on a datetime array. Now only TIME and DOTS are supported. thumbnailPara.setType(CreateThumbnailRequest.ThumbnailPara.TypeEnum.TIME); // Interval for sampling thumbnailPara.setTime(12); // Start time if the sampling type is TIME, which is used together with time. The unit is second. Its value is a number. The default value is 0. thumbnailPara.setStartTime(0); // Duration if the sampling type is TIME, which is used together with time and start_time. The unit is second. Its value is a digit greater than or equal to 0. The default value is ToEND. ToEND indicates sampling lasts until the end of the video. thumbnailPara.setDuration(60); // Datetime array for capturing snapshots. This parameter is used only when the sampling type is DOTS. List<Integer> dots = new ArrayList<>(); dots.add(10); dots.add(20); thumbnailPara.setDots(dots); // Set the maximum length. thumbnailPara.setMaxLength(480); // Set the aspect ratio. thumbnailPara.setAspectRatio(0); // Set the snapshot file format. The value 0 indicates the default format, and the value 1 indicates the JPG format. thumbnailPara.setFormat(1); createTranscodingRequest.setThumbnail(thumbnail);
- Content review
1 2 3 4 5 6 7
// Set content review parameters. CreateTranscodingRequest.Audit audit = new CreateTranscodingRequest.Audit(); // 1: review the input file; 2: review the output file. audit.setPosition(1); // Set the parameter to the name of the channel to be reviewed (starting from 0). If you have six outputs and want to review the fourth file, set this to 3. If you want to review only the input file, you do not need to set this parameter. audit.setIndex(0); createTranscodingRequest.setAudit(audit);
- The resolution of input files and output files must be at least 1280x720.
- If you want to review an output file, its resolution must be the same as the resolution of the input file.
- Encryption
1 2 3 4 5 6 7 8 9 10 11 12 13 14
// Set encryption parameters. CreateTranscodingRequest.Encryption encryption = new CreateTranscodingRequest.Encryption(); CreateTranscodingRequest.Encryption.Multidrm multidrm = new CreateTranscodingRequest.Encryption.Multidrm(); // Set content_id. multidrm.setContentId("contentId"); // Define the data stream type. The value can be DASH or HLS. multidrm.setStreamingMode("HLS"); // Whether to enable audio encryption. The value 0 indicates that audio encryption is disabled and 1 indicates that audio encryption is enabled. The default value is 0. multidrm.setEncryptAudio(1); // Define the encryption method. The default value is 16420. multidrm.setEmi(16420); multidrm.setDrmList(new String[]{"PLAYREADY"}) encryption.setMultidrm(multidrm); createTranscodingRequest.setEncryption(encryption);
- Subtitle
Before enabling subtitling, upload a subtitle file to an OBS bucket and obtain the permission to access the bucket. For details, see Authorizing Access to Cloud Resources.
1 2 3 4 5 6 7 8 9 10 11
// Set subtitle parameters. CreateTranscodingRequest.Subtitle subtitle = new CreateTranscodingRequest.Subtitle(); // Set whether to add subtitles. 0: no. 1: yes. subtitle.setSubtitleType(1); // Set the subtitle file address. ObsObjInfo fileInput = new ObsObjInfo(); fileInput.setBucket("bucketName"); fileInput.setObject("objectKey"); fileInput.setLocation("cn-north-4"); subtitle.setSubtitleFile(fileInput); createTranscodingRequest.setSubtitle(subtitle);
- Image rotation
1 2 3 4
VideoProcess videoProcess = new VideoProcess(); // Clockwise rotation angle of a video. 0: Do not rotate. 1: Rotate a video clockwise by 90 degrees. 2: Rotate a video clockwise by 180 degrees. 3: Rotate a video clockwise by 270 degrees. videoProcess.setRotate(2); createTranscodingRequest.setVideoProcess(videoProcess);
- Image enhancement
1 2 3 4
QualityEnhance qualityEnhance = new QualityEnhance(); // For media files with no obvious problems, use technologies such as enhancement and sharpening to improve the subjective effect. The parameters such as the resolution and frame rate remain unchanged before and after this operation. qualityEnhance.setNormalEnhance(QualityEnhance.NormalEnhanceEnum.NORMAL); createTranscodingRequest.setQualityEnhance(qualityEnhance);
- Volume control
1 2 3 4 5 6
AudioProcess audioProcess = new AudioProcess(); // Volume adjustment method. auto indicates automatic volume adjustment. dynamic indicates manual volume adjustment. If the value is dynamic, the volume adjustment amplitude needs to be set. audioProcess.setVolume(AudioProcess.VolumeEnum.DYNAMIC); // Volume adjustment amplitude if you plan to adjust the volume manually. The value ranges from -15 to 15. The unit is dB. audioProcess.setVolumeExpr(15); createTranscodingRequest.setAudioProcess(audioProcess);
- Multi-audio
// Set multi-audio track parameters. MultiAudio multiAudio = new MultiAudio(); List<AudioFile> audioFiles = new LinkedList<>(); AudioFile audioFile = new AudioFile(); ObsObjInfo multiAudioInput = new ObsObjInfo(); // Set the input file path. multiAudioInput.setBucket("obs-syg01"); multiAudioInput.setLocation("cn-north-7"); multiAudioInput.setObject("1.mp3"); audioFile.setInput(multiAudioInput); audioFiles.add(audioFile); multiAudio.setAudioFiles(audioFiles); createTranscodingRequest.setMultiAudio(multiAudio);
- Transcoding priority
- Send a transcoding request.
1 2 3 4
// Send a transcoding request. CreateTranscodingResponse createTranscodingResponse = mpcClient.createTranscodingTask(createTranscodingRequest); // Return a message. System.out.println(new Gson().toJson(createTranscodingResponse));
Full Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
import com.google.gson.Gson;
import com.huawei.mpc.client.ClientConfig;
import com.huawei.mpc.client.MpcClient;
import com.huawei.mpc.client.MpcConfig;
import com.huawei.mpc.model.ObsObjInfo;
import com.huawei.mpc.model.transcoding.CreateTranscodingRequest;
import com.huawei.mpc.model.transcoding.CreateTranscodingResponse;
// Set the method for constructing MPC configuration items.
MpcConfig mpcConfig = new MpcConfig();
// Mandatory. Set the endpoint of MPC. For details, see section "Obtaining Key Parameters."
mpcConfig.setEndPoint(endPoint);
// Mandatory. Set the user's project ID. For details, see section "Obtaining Key Parameters."
mpcConfig.setProjectId(projectId);
// Mandatory. Set the SK. For details, see section "Obtaining Key Parameters."
mpcConfig.setSk(sk);
// Mandatory. Set the AK. For details, see section "Obtaining Key Parameters."
mpcConfig.setAk(ak);
/*if you need proxy*/
// Optional. Set the proxy if necessary.
/*
ClientConfig clientConfig = new ClientConfig();
// Set the IP address of the proxy server.
clientConfig.setProxyHost(proxyHost);
// Set the port number of the proxy server.
clientConfig.setProxyPort(Integer.parseInt(proxyPort));
// Set the username for accessing the proxy server.
clientConfig.setProxyUserName(proxyUserName);
// Set the password for accessing the proxy server.
clientConfig.setProxyPassword(proxyPassword);
*/
// MPC construction method
MpcClient mpcClient = new MpcClient(mpcConfig);
// Set request parameters.
CreateTranscodingRequest createTranscodingRequest = new CreateTranscodingRequest();
// Set the storage location of an input file.
ObsObjInfo input = new ObsObjInfo();
input.setBucket("bucketName");
input.setObject("objectKey");
input.setLocation("cn-north-4");
createTranscodingRequest.setInput(input);
// Set the storage location of an output file.
ObsObjInfo output = new ObsObjInfo();
output.setBucket("bucketName");
output.setObject("path");
output.setLocation("cn-north-4");
createTranscodingRequest.setOutput(output);
/*
// Optional. Set the watermark function if necessary.
CreateTranscodingRequest.Watermark watermark = new CreateTranscodingRequest.Watermark();
watermark.setTemplateId("watermark_template_id");
// Set the watermark image address.
ObsObjInfo watermarkInput = new ObsObjInfo();
watermarkInput.setBucket("bucketName");
watermarkInput.setObject("objectKey");
watermarkInput.setLocation("cn-north-4");
watermark.setInput(watermarkInput);
List<CreateTranscodingRequest.Watermark> watermarks = new ArrayList<CreateTranscodingRequest.Watermark>();
watermarks.add(watermark);
CreateTranscodingRequest.Watermark[] watermarkArray = new CreateTranscodingRequest.Watermark[watermarks.size()];
createTranscodingRequest.setWatermarks(watermarks.toArray(watermarkArray));
*/
// Set the transcoding template ID.
List<Long> transTempIds = new ArrayList<Long>();
transTempIds.add(203L);
transTempIds.add(212L);
transTempIds.add(210L);
createTranscodingRequest.setTransTemplateId(transTempIds);
/*
// Set snapshot parameters if the snapshot function is enabled.
CreateTranscodingRequest.Thumbnail thumbnail = new CreateTranscodingRequest.Thumbnail();
// Set which format snapshot files are compressed into. In this example, the .tar format is used.
thumbnail.setTar(1);
// Set the location for storing snapshot files. Ensure that MPC has been authorized to access the bucket that stores snapshot files.
ObsObjInfo thumbOutput = new ObsObjInfo();
// OBS bucket name
thumbOutput.setBucket("obs-bills");
// Region where an OBS bucket is deployed
thumbOutput.setLocation("cn-north-4");
// Storage path in the OBS bucket
thumbOutput.setObject("output/thumbnail/");
thumbnail.setThumbOutput(thumbOutput);
CreateThumbnailRequest.ThumbnailPara thumbnailPara = new CreateThumbnailRequest.ThumbnailPara();
// Sampling type. Three options are available: PERCENT, TIME, and DOTS. PERCENT indicates sampling based on a percentage of the video duration. Time indicates sampling by interval. DOTS indicating sampling based on a datetime array. Now only TIME and DOTS are supported.
thumbnailPara.setTime(12);
// Set the maximum length.
thumbnailPara.setMaxLength(480);
// Set the aspect ratio.
thumbnailPara.setAspectRatio(0);
// Set the snapshot file format. The value 0 indicates the default format, and the value 1 indicates the JPG format.
thumbnailPara.setFormat(1);
createTranscodingRequest.setThumbnail(thumbnail);
*/
/*
// Set the transcoding priority. 6: medium (default value ). 9: high.
createTranscodingRequest.setPriority(6);
*/
/*
// Set content review parameters.
CreateTranscodingRequest.Audit audit = new CreateTranscodingRequest.Audit();
// 1: review the input file; 2: review the output file.
audit.setPosition(1);
// Transcoding template index. For details, see the Audit structure in the Media Processing Center API Reference.
audit.setIndex(0);
createTranscodingRequest.setAudit(audit);
*/
/*
// Set subtitle parameters.
CreateTranscodingRequest.Subtitle subtitle = new CreateTranscodingRequest.Subtitle();
// Set whether to add subtitles. 0: no. 1: yes.
subtitle.setSubtitleType(1);
// Set the subtitle file address.
ObsObjInfo fileInput = new ObsObjInfo();
fileInput.setBucket("bucketName");
fileInput.setObject("objectKey");
fileInput.setLocation("cn-north-4");
subtitle.setSubtitleFile(fileInput);
createTranscodingRequest.setSubtitle(subtitle);
*/
// Set encryption parameters.
CreateTranscodingRequest.Encryption encryption = new CreateTranscodingRequest.Encryption();
CreateTranscodingRequest.Encryption.Multidrm multidrm = new CreateTranscodingRequest.Encryption.Multidrm();
// Set content_id.
multidrm.setContentId("contentId");
// Define the data stream type. The value can be DASH or HLS.
multidrm.setStreamingMode("HLS");
// Whether to enable audio encryption. The value 0 indicates that audio encryption is disabled and 1 indicates that audio encryption is enabled. The default value is 0.
multidrm.setEncryptAudio(1);
// Define the encryption method. The default value is 16420.
multidrm.setEmi(16420);
multidrm.setDrmList(new String[]{"PLAYREADY"})
encryption.setMultidrm(multidrm);
createTranscodingRequest.setEncryption(encryption);
// Set image rotation parameters.
VideoProcess videoProcess = new VideoProcess();
// Clockwise rotation angle of a video. 0: Do not rotate. 1: Rotate a video clockwise by 90 degrees. 2: Rotate a video clockwise by 180 degrees. 3: Rotate a video clockwise by 270 degrees.
videoProcess.setRotate(2);
createTranscodingRequest.setVideoProcess(videoProcess);
// Set image enhancement parameters.
QualityEnhance qualityEnhance = new QualityEnhance();
// For media files with no obvious problems, use technologies such as enhancement and sharpening to improve the subjective effect. The parameters such as the resolution and frame rate remain unchanged before and after this operation.
qualityEnhance.setNormalEnhance(QualityEnhance.NormalEnhanceEnum.NORMAL);
createTranscodingRequest.setQualityEnhance(qualityEnhance);
// Set volume adjustment parameters.
AudioProcess audioProcess = new AudioProcess();
// Volume adjustment method. auto indicates automatic volume adjustment. dynamic indicates manual volume adjustment. If the value is dynamic, the volume adjustment amplitude needs to be set.
audioProcess.setVolume(AudioProcess.VolumeEnum.DYNAMIC);
// Volume adjustment amplitude if you plan to adjust the volume manually. The value ranges from -15 to 15. The unit is dB.
audioProcess.setVolumeExpr(15);
createTranscodingRequest.setAudioProcess(audioProcess);
// Send a transcoding request.
CreateTranscodingResponse createTranscodingResponse = mpcClient.createTranscodingTask(createTranscodingRequest);
// Return a message.
System.out.println(new Gson().toJson(createTranscodingResponse));
|
Last Article: Transcoding
Next Article: Canceling a Transcoding Task
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.