Browse Source

Merge branch 'dev-SpriteSnapshot' into 'master' (merge request !9)

add:支持雪碧图任务
master
jojoliang 3 years ago
parent
commit
2d3f005bbf
  1. 12
      ci_media.go
  2. 71
      example/CI/media_process/media_process.go

12
ci_media.go

@ -14,6 +14,7 @@ type JobOutput struct {
Region string `xml:"Region,omitempty"`
Bucket string `xml:"Bucket,omitempty"`
Object string `xml:"Object,omitempty"`
SpriteObject string `xml:"SpriteObject,omitempty"`
}
type Container struct {
@ -110,6 +111,15 @@ type ConcatTemplate struct {
Index string `xml:"Index,omitempty"`
}
type SpriteSnapshotConfig struct {
CellHeight string `xml:"CellHeight,omitempty"`
CellWidth string `xml:"CellWidth,omitempty"`
Color string `xml:"Color,omitempty"`
Columns string `xml:"Columns,omitempty"`
Lines string `xml:"Lines,omitempty"`
Margin string `xml:"Margin,omitempty"`
Padding string `xml:"Padding,omitempty"`
}
type Snapshot struct {
Mode string `xml:"Mode,omitempty"`
Start string `xml:"Start,omitempty"`
@ -117,6 +127,8 @@ type Snapshot struct {
Count string `xml:"Count,omitempty"`
Width string `xml:"Width,omitempty"`
Height string `xml:"Height,omitempty"`
SnapshotOutMode string `xml:"SnapshotOutMode,omitempty"`
SpriteSnapshotConfig *SpriteSnapshotConfig `xml:"SpriteSnapshotConfig,omitempty"`
}
// 有意和转码区分,两种任务关注的参数不一样避免干扰

71
example/CI/media_process/media_process.go

@ -345,11 +345,78 @@ func WorkflowExecutionNotifyCallback() {
}
}
func InvokeSpriteSnapshotTask() {
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: "Snapshot",
Input: &cos.JobInput{
Object: "input/117374C.mp4",
},
Operation: &cos.MediaProcessJobOperation{
Output: &cos.JobOutput{
Region: "ap-chongqing",
Object: "output/abc-${Number}.jpg",
Bucket: "wwj-cq-1253960454",
SpriteObject: "output/sprite-${Number}.jpg",
},
Snapshot: &cos.Snapshot{
Mode: "Interval",
Start: "0",
Count: "100",
SnapshotOutMode: "SnapshotAndSprite", // OnlySnapshot OnlySprite
SpriteSnapshotConfig: &cos.SpriteSnapshotConfig{
CellHeight: "128",
CellWidth: "128",
Color: "Black",
Columns: "3",
Lines: "10",
Margin: "2",
},
},
},
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()
// InvokeTranscodeTask()
// InvokeMultiTasks()
TaskNotifyCallback()
WorkflowExecutionNotifyCallback()
// TaskNotifyCallback()
// WorkflowExecutionNotifyCallback()
InvokeSpriteSnapshotTask()
}
Loading…
Cancel
Save