Transcoding jobs
Initiate and query transcoding jobs in Intelligent Media Services by calling API operations with a server-side SDK.
Usage notes
To initiate a transcoding job, submit the job with the regionId, Inputs, and OutputGroups parameters. After the job is processed, you can use the returned JobId to query the job information.
Note the following about transcoding job parameters:
regionId is the region where the service is provided.
Inputs and OutputGroups files corresponding to OutputGroups must be in the same region regionId.
Obtain templateId from the transcoding template management page.
For complete parameter structure see MediaConvertJobConfig.
For a list of supported regionId, please refer Service regions.
Sample code
Debug this API operation in the Alibaba Cloud OpenAPI Portal.
package main
import (
"encoding/json"
"strings"
"fmt"
"os"
ice20201109 "github.com/alibabacloud-go/ice-20201109/v7/client"
openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
util "github.com/alibabacloud-go/tea-utils/v2/service"
credential "github.com/aliyun/credentials-go/credentials"
"github.com/alibabacloud-go/tea/tea"
)
func CreateClient () (_result *ice20201109.Client, _err error) {
credential, _err := credential.NewCredential(nil)
if _err != nil {
return _result, _err
}
config := &openapi.Config{
Credential: credential,
}
config.Endpoint = tea.String("ice.cn-shanghai.aliyuncs.com")
_result = &ice20201109.Client{}
_result, _err = ice20201109.NewClient(config)
return _result, _err
}
func _main (args []*string) (_err error) {
client, _err := CreateClient()
if _err != nil {
return _err
}
submitMediaConvertJobRequest := &ice20201109.SubmitMediaConvertJobRequest{
Config: tea.String("{\"Inputs\":[{\"InputFile\":{\"Type\":\"OSS\",\"Media\":\"http://<bucket name>.oss-cn-shanghai.aliyuncs.com/input/**/60min.mp4\"}}],\"OutputGroups\":[{\"GroupConfig\":{\"Type\":\"File\",\"OutputFileBase\":{\"Type\":\"OSS\",\"Media\":\"http://<bucket name>.oss-cn-shanghai.aliyuncs.com/output/**/\"}},\"Outputs\":[{\"OutputFileName\":\"hd.mp4\",\"TemplateId\":\"<TemplateId>\"},{\"OutputFileName\":\"sd.mp4\",\"TemplateId\":\"<TemplateId>\"}]}]}"),
UserData: tea.String("{\"videoId\":\"abcd\"}"),
}
runtime := &util.RuntimeOptions{}
tryErr := func()(_e error) {
defer func() {
if r := tea.Recover(recover()); r != nil {
_e = r
}
}()
resp, _err := client.SubmitMediaConvertJobWithOptions(submitMediaConvertJobRequest, runtime)
if _err != nil {
return _err
}
fmt.Printf("[LOG] %v\n", resp)
return nil
}()
if tryErr != nil {
var error = &tea.SDKError{}
if _t, ok := tryErr.(*tea.SDKError); ok {
error = _t
} else {
error.Message = tea.String(tryErr.Error())
}
fmt.Println(tea.StringValue(error.Message))
var data interface{}
d := json.NewDecoder(strings.NewReader(tea.StringValue(error.Data)))
d.Decode(&data)
if m, ok := data.(map[string]interface{}); ok {
recommend, _ := m["Recommend"]
fmt.Println(recommend)
}
}
return _err
}
func main() {
err := _main(tea.StringSlice(os.Args[1:]))
if err != nil {
panic(err)
}
}