All Products
Search
Document Center

Transcoding template

Last Updated: Jul 11, 2019

Initialize a client

Initialize a client before using the SDK. For more information, see initVodClient.

Add a transcoding template group

For more information about the request and response parameters, see AddTranscodeTemplateGroup.

#include <stdio.h>
#include <string>
#include <map>
#include <jsoncpp/json/json.h>
#include "vod_sdk/openApiUtil.h"

/**
 * Method for constructing the transcoding template configuration
 */
Json::Value buildTranscodeTemplateList() {
    Json::Value transcodeTemplateList;
    Json::Value transcodeTemplate;
    // Specifies the video stream transcoding configuration.
    Json::Value video;
    video["Width"] = 640;
    video["Bitrate"] = 400;
    video["Fps"] = 25;
    video["Remove"] = false;
    video["Codec"] = "H. 264";
    video["Gop"] = "250";
    transcodeTemplate["Video"] = video;

    // Specifies the audio stream transcoding configuration.
    Json::Value audio;
    audio["Codec"] = "AAC";
    audio["Bitrate"] = "64";
    audio["Channels"] = "2";
    audio["Samplerate"] = "32000";
    transcodeTemplate["Audio"] = audio;

    // Specifies the encapsulation container.
    Json::Value container;
    container["Format"] = "mp4";
    transcodeTemplate["Container"] = container;

    // Specifies the conditional transcoding configuration.
    Json::Value transconfig;
    transconfig["IsCheckReso"] = false;
    transconfig["IsCheckResoFail"] = false;
    transconfig["IsCheckVideoBitrate"] = false;
    transconfig["IsCheckVideoBitrateFail"] = false;
    transconfig["IsCheckAudioBitrate"] = false;
    transconfig["IsCheckAudioBitrateFail"] = false;
    transcodeTemplate["TransConfig"] = transconfig;

    // Specifies the encryption configuration, which supports only the M3U8 format.
    //Json::Value encryptSetting;
    //encryptSetting["EncryptType"] = "Private";
    //transcodeTemplate["EncryptSetting"] = encryptSetting;

    // Sets the definition.
    transcodeTemplate["Definition"] = "LD";

    // Sets the template name.
    transcodeTemplate["TemplateName"] = "testtemplate";

    // Associates watermark IDs with transcoding template IDs.
    Json::Value watermarkIdList;
    watermarkIdList.append("263261bdc1ff65782f8995c6dd22a16a");
    // USER_DEFAULT_WATERMARK indicates the default watermark ID.
    watermarkIdList.append("USER_DEFAULT_WATERMARK");
    transcodeTemplate["WatermarkIds"] = watermarkIdList;
    transcodeTemplateList.append(transcodeTemplate);
    return transcodeTemplateList;
}

/**
 * Method for adding a transcoding template group
 */
VodApiResponse addTranscodeTemplateGroup(VodCredential authInfo) {
    string apiName = "AddTranscodeTemplateGroup";
    map<string, string> args; 
    args["Name"] = "grouptest";
    args["TranscodeTemplateList"] = buildTranscodeTemplateList().toStyledString();
    return getAcsResponse(authInfo, apiName, args);
}

// Call example
void main() {
    VodCredential authInfo = initVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
    VodApiResponse response = addTranscodeTemplateGroup(authInfo);
    printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}

Modify a transcoding template group

For more information about the request and response parameters, see UpdateTranscodeTemplateGroup.

#include <stdio.h> 
#include <string>
#include <map>
#include <jsoncpp/json/json.h>
#include "vod_sdk/openApiUtil.h"

/**
 * Method for modifying the transcoding template configuration
 */
Json::Value buildTranscodeTemplateList() {
    Json::Value transcodeTemplateList;
    Json::Value transcodeTemplate;
    // Specifies the video stream transcoding configuration.
    Json::Value video;
    video["Width"] = 640;
    video["Bitrate"] = 400;
    video["Fps"] = 25;
    video["Remove"] = false;
    video["Codec"] = "H. 264";
    video["Gop"] = "250";
    transcodeTemplate["Video"] = video;

    // Specifies the audio stream transcoding configuration.
    Json::Value audio;
    audio["Codec"] = "AAC";
    audio["Bitrate"] = "64";
    audio["Channels"] = "2";
    audio["Samplerate"] = "32000";
    transcodeTemplate["Audio"] = audio;

    // Specifies the encapsulation container.
    Json::Value container;
    container["Format"] = "mp4";
    transcodeTemplate["Container"] = container;

    // Specifies the conditional transcoding configuration.
    Json::Value transconfig;
    transconfig["IsCheckReso"] = false;
    transconfig["IsCheckResoFail"] = false;
    transconfig["IsCheckVideoBitrate"] = false;
    transconfig["IsCheckVideoBitrateFail"] = false;
    transconfig["IsCheckAudioBitrate"] = false;
    transconfig["IsCheckAudioBitrateFail"] = false;
    transcodeTemplate["TransConfig"] = transconfig;

    // Specifies the encryption configuration, which supports only the M3U8 format.
    //Json::Value encryptSetting;
    //encryptSetting["EncryptType"] = "Private";
    //transcodeTemplate["EncryptSetting"] = encryptSetting;

    // Sets the template name.
    transcodeTemplate["TemplateName"] = "testtemplate";

    // Sets the ID of the transcoding template to be modified.
    transcodeTemplate["TranscodeTemplateId"] = "85c2b18ac08fda33e8f6d9c56242f";

    // Associates watermark IDs with transcoding template IDs.
    Json::Value watermarkIdList;
    watermarkIdList.append("263261bdc1ff65782f8995c6dd22a16a");
    // USER_DEFAULT_WATERMARK indicates the default watermark ID.
    watermarkIdList.append("USER_DEFAULT_WATERMARK");
    transcodeTemplate["WatermarkIds"] = watermarkIdList;
    transcodeTemplateList.append(transcodeTemplate);
    return transcodeTemplateList;
}

/**
 * Method for modifying a transcoding template group
 */
VodApiResponse updateTranscodeTemplateGroup(VodCredential authInfo) {
    string apiName = "UpdateTranscodeTemplateGroup";
    map<string, string> args;
    // Sets the ID of the transcoding template group.
    args["TranscodeTemplateGroupId"] = "4c71a339fecec0152b4fa6f4527xxx";
    args["Name"] = "grouptest";
    args["TranscodeTemplateList"] = buildTranscodeTemplateList().toStyledString();
    return getAcsResponse(authInfo, apiName, args);
}

// Call example
void main() {
    VodCredential authInfo = initVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
    VodApiResponse response = updateTranscodeTemplateGroup(authInfo);
    printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}

Query a list of transcoding template groups

For more information about the request and response parameters, see ListTranscodeTemplateGroup.

#include <stdio.h>
#include <string>
#include <map>
#include <jsoncpp/json/json.h>
#include "vod_sdk/openApiUtil.h"

/**
 * Method for querying a list of transcoding template groups
 */
VodApiResponse listTranscodeTemplateGroup(VodCredential authInfo) {
    string apiName = "ListTranscodeTemplateGroup";
    map<string, string> args;
    return getAcsResponse(authInfo, apiName, args);
}

// Call example
void main() {
    VodCredential authInfo = initVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
    VodApiResponse response = listTranscodeTemplateGroup(authInfo);
    printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}

Query a transcoding template group

For more information about the request and response parameters, see GetTranscodeTemplateGroup.

#include <stdio.h> 
#include <string>
#include <map>
#include <jsoncpp/json/json.h>
#include "vod_sdk/openApiUtil.h"

/**
 * Method for querying a transcoding template group
 */
VodApiResponse getTranscodeTemplateGroup(VodCredential authInfo) {
    string apiName = "GetTranscodeTemplateGroup";
    map<string, string> args;
    args["TranscodeTemplateGroupId"] = "a0fa0fda545e50e7a3eb75491f9f4";
    return getAcsResponse(authInfo, apiName, args);
}

// Call example
void main() {
    VodCredential authInfo = initVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
    VodApiResponse response = getTranscodeTemplateGroup(authInfo);
    printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}

Set the default transcoding template group

For more information about the request and response parameters, see SetDefaultTranscodeTemplateGroup.

#include <stdio.h> 
#include <string>
#include <map>
#include <jsoncpp/json/json.h> 
#include "vod_sdk/openApiUtil.h"

/**
 * Method for setting the default transcoding template group
 */
VodApiResponse setDefaultTranscodeTemplateGroup(VodCredential authInfo) {
    string apiName = "SetDefaultTranscodeTemplateGroup";
    map<string, string> args;
    args["TranscodeTemplateGroupId"] = "a0fa0fda545e50e7a3eb75491f9f4";
    return getAcsResponse(authInfo, apiName, args);
}

// Call example
void main() {
    VodCredential authInfo = initVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
    VodApiResponse response = setDefaultTranscodeTemplateGroup(authInfo);
    printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}

Delete a transcoding template group

For more information about the request and response parameters, see DeleteTranscodeTemplateGroup.

#include <stdio.h>
#include <string>
#include <map>
#include <jsoncpp/json/json.h> 
#include "vod_sdk/openApiUtil.h"


/**
 * Method for deleting a transcoding template group
 */
VodApiResponse deleteTranscodeTemplateGroup(VodCredential authInfo) {
    string apiName = "DeleteTranscodeTemplateGroup";
    map<string, string> args;
    args["TranscodeTemplateGroupId"] = "a0fa0fda545e50e7a3eb75491f9f4";
    return getAcsResponse(authInfo, apiName, args);
}

// Call example
void main() {
    VodCredential authInfo = initVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
    VodApiResponse response = deleteTranscodeTemplateGroup(authInfo);
    printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}