All Products
Search
Document Center

ApsaraVideo VOD:Media fingerprinting

Last Updated:Sep 06, 2022

This topic provides examples on how to call the API operations of the media fingerprinting module. The API operations are encapsulated in ApsaraVideo VOD SDK for C/C++. You can call the API operations to submit media fingerprinting jobs, query media fingerprinting jobs, and query media fingerprinting results. 

Usage notes

The media fingerprinting feature is supported only in the Singapore (Singapore) region. 

Initialize a client

Before you can use the SDK, initialize a client. For more information, see Initialization

Submit a media fingerprinting job 

You can call the SubmitAIJob operation to submit a media fingerprinting job. 

 Sample code:

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

/**
 * Submit a job.
 */
VodApiResponse submitAIJob(VodCredential authInfo) {
    string apiName = "SubmitAIJob";
    map<string, string> args;
    // The video ID.
    args["MediaId"] = "3eb19a4585bc475e995bdd78fd****";
    // The AI type. Set the value to AIMediaDNA.
    args["Types"] = "AIMediaDNA";
    return getAcsResponse(authInfo, apiName, args);
}

// Sample requests
void main() {
    VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
    VodApiResponse response = submitAIJob(authInfo);
    printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}

Query media fingerprinting jobs 

You can call the ListAIJob operation to query media fingerprinting jobs. 

 Sample code:

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

/**
 * Query media fingerprinting jobs.
 */
VodApiResponse listAIJob(VodCredential authInfo) {
    string apiName = "ListAIJob";
    map<string, string> args;
    // The job ID.
    args["JobIds"] = "979d4d7a36ae41b1a945a288****,3eb19a4585bc475e995bddea65****";
    return getAcsResponse(authInfo, apiName, args);
}

// Sample requests
void main() {
    VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
    VodApiResponse response = listAIJob(authInfo);
    printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}

Query media fingerprinting results 

You can call the GetMediaDNAResult operation to query the results of media fingerprinting jobs. 

 Sample code:

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

/**
 * Query media fingerprinting results.
 */
VodApiResponse getMediaDNAResult(VodCredential authInfo) {
    string apiName = "GetMediaDNAResult";
    map<string, string> args;
    // The video ID.
    args["MediaId"] = "3eb19a4585bc475e995bdd78****";
    return getAcsResponse(authInfo, apiName, args);
}

// Sample requests
void main() {
    VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
    VodApiResponse response = getMediaDNAResult(authInfo);
    printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}