add:支持拼接任务
This commit is contained in:
18
ci_media.go
18
ci_media.go
@@ -25,7 +25,7 @@ type Video struct {
|
||||
Width string `xml:"Width"`
|
||||
Height string `xml:"Height"`
|
||||
Fps string `xml:"Fps"`
|
||||
Remove string `xml:"Remove"`
|
||||
Remove string `xml:"Remove,omitempty"`
|
||||
Profile string `xml:"Profile"`
|
||||
Bitrate string `xml:"Bitrate"`
|
||||
Crf string `xml:"Crf"`
|
||||
@@ -48,7 +48,7 @@ type Audio struct {
|
||||
Samplerate string `xml:"Samplerate"`
|
||||
Bitrate string `xml:"Bitrate"`
|
||||
Channels string `xml:"Channels"`
|
||||
Remove string `xml:"Remove"`
|
||||
Remove string `xml:"Remove,omitempty"`
|
||||
}
|
||||
|
||||
type TransConfig struct {
|
||||
@@ -97,13 +97,25 @@ type Watermark struct {
|
||||
Image *Image `xml:"Image,omitempty"`
|
||||
Text *Text `xml:"Text,omitempty"`
|
||||
}
|
||||
|
||||
type ConcatFragment struct {
|
||||
Url string `xml:"Url,omitempty"`
|
||||
StartTime string `xml:"StartTime,omitempty"`
|
||||
EndTime string `xml:"EndTime,omitempty"`
|
||||
}
|
||||
type ConcatTemplate struct {
|
||||
ConcatFragment []ConcatFragment `xml:"ConcatFragment,omitempty"`
|
||||
Audio *Audio `xml:"Audio,omitempty"`
|
||||
Video *Video `xml:"Video,omitempty"`
|
||||
Container *Container `xml:"Container,omitempty"`
|
||||
Index string `xml:"Index,omitempty"`
|
||||
}
|
||||
type MediaProcessJobOperation struct {
|
||||
Output *JobOutput `xml:"Output,omitempty"`
|
||||
Transcode *Transcode `xml:"Transcode,omitempty"`
|
||||
Watermark *Watermark `xml:"Watermark,omitempty"`
|
||||
TemplateId string `xml:"TemplateId,omitempty"`
|
||||
WatermarkTemplateId []string `xml:"WatermarkTemplateId,omitempty"`
|
||||
ConcatTemplate *ConcatTemplate `xml:"ConcatTemplate,omitempty"`
|
||||
}
|
||||
|
||||
type CreateMediaJobsOptions struct {
|
||||
|
||||
@@ -30,7 +30,78 @@ func log_status(err error) {
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
func InvokeConcatTask() {
|
||||
u, _ := url.Parse("https://wwj-bj-1253960454.cos.ap-beijing.myqcloud.com")
|
||||
cu, _ := url.Parse("https://wwj-bj-1253960454.ci.ap-beijing.myqcloud.com")
|
||||
b := &cos.BaseURL{BucketURL: u, CIURL: cu}
|
||||
c := cos.NewClient(b, &http.Client{
|
||||
Transport: &cos.AuthorizationTransport{
|
||||
SecretID: os.Getenv("COS_SECRETID"),
|
||||
SecretKey: os.Getenv("COS_SECRETKEY"),
|
||||
Transport: &debug.DebugRequestTransport{
|
||||
RequestHeader: true,
|
||||
// Notice when put a large file and set need the request body, might happend out of memory error.
|
||||
RequestBody: true,
|
||||
ResponseHeader: true,
|
||||
ResponseBody: true,
|
||||
},
|
||||
},
|
||||
})
|
||||
// DescribeMediaProcessQueues
|
||||
DescribeQueueOpt := &cos.DescribeMediaProcessQueuesOptions{
|
||||
QueueIds: "",
|
||||
PageNumber: 1,
|
||||
PageSize: 2,
|
||||
}
|
||||
DescribeQueueRes, _, err := c.CI.DescribeMediaProcessQueues(context.Background(), DescribeQueueOpt)
|
||||
log_status(err)
|
||||
fmt.Printf("%+v\n", DescribeQueueRes)
|
||||
// CreateMediaJobs
|
||||
concatFragment := make([]cos.ConcatFragment, 0)
|
||||
concatFragment = append(concatFragment, cos.ConcatFragment{
|
||||
Url: "https://wwj-bj-1253960454.cos.ap-beijing.myqcloud.com/input/117374C.mp4",
|
||||
StartTime: "0",
|
||||
EndTime: "10",
|
||||
})
|
||||
concatFragment = append(concatFragment, cos.ConcatFragment{
|
||||
Url: "https://wwj-bj-1253960454.cos.ap-beijing.myqcloud.com/input/117374C.mp4",
|
||||
StartTime: "20",
|
||||
EndTime: "30",
|
||||
})
|
||||
createJobOpt := &cos.CreateMediaJobsOptions{
|
||||
Tag: "Concat",
|
||||
Operation: &cos.MediaProcessJobOperation{
|
||||
Output: &cos.JobOutput{
|
||||
Region: "ap-beijing",
|
||||
Object: "output/go_117374C.mp4",
|
||||
Bucket: "wwj-bj-1253960454",
|
||||
},
|
||||
ConcatTemplate: &cos.ConcatTemplate{
|
||||
Container: &cos.Container{
|
||||
Format: "mp4",
|
||||
},
|
||||
Video: &cos.Video{
|
||||
Codec: "H.264",
|
||||
},
|
||||
Audio: &cos.Audio{
|
||||
Codec: "AAC",
|
||||
},
|
||||
ConcatFragment:concatFragment,
|
||||
},
|
||||
},
|
||||
QueueId: DescribeQueueRes.QueueList[0].QueueId,
|
||||
}
|
||||
createJobRes, _, err := c.CI.CreateMediaJobs(context.Background(), createJobOpt)
|
||||
log_status(err)
|
||||
fmt.Printf("%+v\n", createJobRes.JobsDetail)
|
||||
|
||||
// DescribeMediaJobs
|
||||
DescribeJobRes, _, err := c.CI.DescribeMediaJob(context.Background(), createJobRes.JobsDetail.JobId)
|
||||
log_status(err)
|
||||
fmt.Printf("%+v\n", DescribeJobRes.JobsDetail)
|
||||
}
|
||||
|
||||
func InvokeTranscodeTask() {
|
||||
u, _ := url.Parse("https://wwj-cq-1253960454.cos.ap-chongqing.myqcloud.com")
|
||||
cu, _ := url.Parse("https://wwj-cq-1253960454.ci.ap-chongqing.myqcloud.com")
|
||||
b := &cos.BaseURL{BucketURL: u, CIURL: cu}
|
||||
@@ -95,3 +166,8 @@ func main() {
|
||||
log_status(err)
|
||||
fmt.Printf("%+v\n", DescribeJobRes.JobsDetail)
|
||||
}
|
||||
|
||||
func main() {
|
||||
InvokeConcatTask()
|
||||
//InvokeTranscodeTask()
|
||||
}
|
||||
|
||||
2
go.sum
2
go.sum
@@ -1,7 +1,9 @@
|
||||
github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
|
||||
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
|
||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/mozillazg/go-httpheader v0.2.1 h1:geV7TrjbL8KXSyvghnFm+NyTux/hxwueTSrwhe88TQQ=
|
||||
github.com/mozillazg/go-httpheader v0.2.1/go.mod h1:jJ8xECTlalr6ValeXYdOF8fFUISeBAdw6E61aqQma60=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
|
||||
Reference in New Issue
Block a user