Browse Source

ci 分段任务struct demo提交

master
flynnzzhang 3 years ago
parent
commit
6b85e7b9e7
  1. 6
      ci_media.go
  2. 58
      example/CI/media_process/media_process.go

6
ci_media.go

@ -149,6 +149,11 @@ type Animation struct {
TimeInterval *TimeInterval `xml:"TimeInterval,omitempty"`
}
type Segment struct {
Format string `xml:"Format,omitempty"`
Duration string `xml:"Duration,omitempty"`
}
type MediaProcessJobOperation struct {
Tag string `xml:"Tag,omitempty"`
Output *JobOutput `xml:"Output,omitempty"`
@ -159,6 +164,7 @@ type MediaProcessJobOperation struct {
ConcatTemplate *ConcatTemplate `xml:"ConcatTemplate,omitempty"`
Snapshot *Snapshot `xml:"Snapshot,omitempty"`
Animation *Animation `xml:"Animation,omitempty"`
Segment *Segment `xml:"Segment,omitempty"`
}
type CreateMediaJobsOptions struct {

58
example/CI/media_process/media_process.go

@ -411,6 +411,61 @@ func InvokeSpriteSnapshotTask() {
fmt.Printf("%+v\n", DescribeJobRes.JobsDetail)
}
func InvokeSegmentTask() {
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}
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
createJobOpt := &cos.CreateMediaJobsOptions{
Tag: "Segment",
Input: &cos.JobInput{
Object: "input/117374C.mp4",
},
Operation: &cos.MediaProcessJobOperation{
Output: &cos.JobOutput{
Region: "ap-chongqing",
Object: "output/abc-${Number}.mp4",
Bucket: "wwj-cq-1253960454",
},
Segment: &cos.Segment{
Format: "mp4",
Duration: "10",
},
},
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 main() {
// InvokeSnapshotTask()
// InvokeConcatTask()
@ -418,5 +473,6 @@ func main() {
// InvokeMultiTasks()
// TaskNotifyCallback()
// WorkflowExecutionNotifyCallback()
InvokeSpriteSnapshotTask()
// InvokeSpriteSnapshotTask()
InvokeSegmentTask()
}
Loading…
Cancel
Save