Preset
A template is a preset set of definitions required for a video resource to perform transcoding calculations. Users can more easily apply a template to one or more video transcoding tasks, so that these tasks output target video resources of the same specifications.
MCT provides the users with rich and complete system templates to meet the user's common requirements for format, code rate, resolution, encryption and decryption, watermark and others in terms of target specifications, and it is the best choice for the users who do not want to know too much about the complex technological background of audios and videos. Baidu has abundant accumulated users in AV technology, providing customized transcoding templates to satisfy the transcoding requirements under complicated business conditions of them.
When you only have to modify the container format of audio and video, Baidu provides Transmux templates to help you quickly convert the container format in a second-level delay, such as converting from MP4 to HLS, while keeping the original audio and video property unchanged.
Query the Presets of Current User and All System Presets
You can query all the Presets via the following code.
public void listPresets(MediaClient client) {
ListPresetsResponse resp = mediaClient.listPresets();
for (GetPresetResponse preset : resp.getPresets()) {
System.out.println("presetName: " + preset.getPresetName());
System.out.println("description: " + preset.getDescription());
System.out.println("container: " + preset.getContainer());
System.out.println("transmux: " + preset.getTransmux());
}
}
Query ssigned Preset Information
The user can assign certain Preset through the following code
public void getPreset(MediaClient client, String presetName) {
GetPresetResponse preset = client.getPreset(presetName);
System.out.println("presetName: " + preset.getPresetName());
System.out.println("description: " + preset.getDescription());
System.out.println("container: " + preset.getContainer());
System.out.println("transmux: " + preset.getTransmux());
}
Create Preset
If the Preset in the system cannot meet the user's requirements, the user can custom their own Preset. Use different interfaces to create Preset according to different coding requirements.
Create the preset that only supports container format conversion
Only the container format conversion Preset is executed for the creation of the following codes
public void createPreset(MediaClient client, String presetName, String description, String container) {
client.createPreset(presetName, description, container);
}
To create the transcoding Preset of audio file, you do not need to make an episode and encryption
If you create an audio file transcoding Preset without clip interception and encryption, you can refer to the following code
public void createPreset(MediaClient client, String presetName, String description, String container,
Audio audio) {
client.createPreset(presetName, description, container, audio);
}
Create audio file transcoding Preset, the clip interception attribute and encryption attribute should be set
If you create a video file transcoding Preset supporting clip interception and encryption, you can refer to the following code
public void createPreset(MediaClient client, String presetName, String description, String container,
Clip clip, Audio audio, Encryption encryption) {
client.createPreset(presetName, description, container, clip, audio, encryption);
}
To create the transcoding Preset of video file, you do not need to make an episode, encryption and watermark properties
If you want to create a video file transcoding Preset without clips, encryption and watermarks, you can refer to the following code
public void createPreset(MediaClient client, String presetName, String description, String container,
Audio audio, Video video) {
client.createPreset(presetName, description, container, audio, video);
}
When creating video file transcoding Preset, you should set clip capture, encryption and watermark attributes
If you create a video file transcoding Preset needing clip capture, encryption and watermark adding, you can refer to the following code
public void createPreset(MediaClient client, String presetName, String description, String container,
Clip clip,Audio audio, Video video, Encryption encryption, String watermarkId) {
client.createPreset(presetName, description, container, clip, audio, video, encryption, watermarkId);
}
Create Preset and assign all the parameters
If you need to customize all the configuration parameters, you can refer to the following code
public void createPreset(MediaClient client, String presetName, String description, String container,
boolean transmux, Clip clip,Audio audio, Video video, Encryption encryption,
Watermarks watermarks, TransCfg transCfg, ExtraCfg extraCfg) {
client.createPreset(presetName, description, container, transmux, clip, audio, video, encryption,
watermarks, transCfg, extraCfg);
}
Note
- The watermarks, transCfg and extraCfg and others can be set as null, indicating this feature is not used.
- The watermarks and watermarkId should not be set simultaneously. It is recommended to set watermarks, which support multiple watermark settings and more watermark control features can be applied.
Update Preset
You can update the templates you created based on the template name:
public void updatePreset(MediaClient client, String presetName, String description, String container) {
GetPresetResponse preset = client.getPreset(presetName);
preset.setDescription(description);
preset.setContainer(container);
client.updatePreset(new UpdatePresetRequest().withPreset(preset));
}
Similar to updating the other parameters