You need to enable JavaScript to run this app.
导航

媒体处理任务

最近更新时间2022.04.08 18:59:59

首次发布时间2022.03.11 10:53:49

初始化

使用前请前完成初始化,请参考初始化

提交媒体处理任务

接口请求参数和返回参数详见 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 vid",
                },
                TemplateId:   "your template id",
                CallbackArgs: "your callback args",
        }

        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)
}