本文为您提供了服务端 Go SDK 的媒体处理任务相关的 API 调用示例。
使用前请先完成初始化,请参考初始化
接口请求参数和返回参数详见 OpenAPI:提交媒体处理任务
package main import ( "log" "net/http" "testing" "github.com/stretchr/testify/assert" "github.com/volcengine/volc-sdk-golang/service/imp" "github.com/volcengine/volc-sdk-golang/service/imp/models/business" "github.com/volcengine/volc-sdk-golang/service/imp/models/request" ) func TestImp_SubmitJob(t *testing.T) { impService := imp.NewInstance() // call below method if you don't set ak and sk in $HOME/.vcloud/config impService.SetAccessKey("your AK") impService.SetSecretKey("your SK") // SubmitJob req := &request.ImpSubmitJobRequest{ InputPath: &business.InputPath{ Type: "VOD", // 素材库:VODMaterial 视频库:VOD VodSpaceName: "your vod space", FileId: "your file id", }, TemplateId: "your template id", CallbackArgs: "your callback args", EnableLowPriority: "false", // true开启 false 不开启 闲时转码模式 Params: &business.Params{ OverrideParams: &business.OverrideParams{ SmartErase: []*business.SmartEraseOverrideParams{ { ActivityId: []string{"*"}, Watermark: &business.Watermark{ DetectRect: []*business.DetectRect{ { X1: 0, X2: 1, Y1: 0, Y2: 1, }, }, }, OCR: &business.OCR{ DetectRect: []*business.DetectRect{ { X1: 0, X2: 1, Y1: 0, Y2: 1, }, }, }, }, }, Output: []*business.OutputOverrideParams{ { ActivityId: []string{"*"}, OutputPath: &business.OutputPath{ Type: "our storage type", VodSpaceName: "your vod spaceName", TosBucket: "your tos bucketName", FileName: "output FileName", }, }, }, }, }, } resp, status, err := impService.SubmitJob(req) assert.NoError(t, err) assert.Equal(t, status, http.StatusOK) assert.NotNil(t, resp) assert.NotZero(t, len(resp.Result)) log.Println(resp.Result) }
接口请求参数和返回参数详见 OpenAPI:查询媒体处理任务
package main import ( "log" "net/http" "testing" "github.com/stretchr/testify/assert" "github.com/volcengine/volc-sdk-golang/service/imp" "github.com/volcengine/volc-sdk-golang/service/imp/models/business" "github.com/volcengine/volc-sdk-golang/service/imp/models/request" ) func TestImp_RetrieveJob(t *testing.T) { impService := imp.NewInstance() // call below method if you don't set ak and sk in $HOME/.vcloud/config impService.SetAccessKey("your AK") impService.SetSecretKey("your SK") // RetrieveJob req := &request.ImpRetrieveJobRequest{ JobIds: []string{ "your job 1", "your job 2", }, } resp, status, err := impService.RetrieveJob(req) assert.NoError(t, err) assert.Equal(t, status, http.StatusOK) assert.NotNil(t, resp) assert.Equal(t, 2, len(resp.Result)) log.Println(resp.Result) }
接口请求参数和返回参数详见 OpenAPI:取消媒体处理任务
package main import ( "log" "net/http" "testing" "github.com/stretchr/testify/assert" "github.com/volcengine/volc-sdk-golang/service/imp" "github.com/volcengine/volc-sdk-golang/service/imp/models/business" "github.com/volcengine/volc-sdk-golang/service/imp/models/request" ) func TestImp_KillJob(t *testing.T) { impService := imp.NewInstance() // call below method if you don't set ak and sk in $HOME/.vcloud/config impService.SetAccessKey("your AK") impService.SetSecretKey("your SK") // KillJob req := &request.ImpKillJobRequest{ JobId: "your job id", } resp, status, err := impService.KillJob(req) assert.NoError(t, err) assert.Equal(t, status, http.StatusOK) assert.NotNil(t, resp) }