add:增加截图任务参数
This commit is contained in:
16
ci_media.go
16
ci_media.go
@@ -109,6 +109,15 @@ type ConcatTemplate struct {
|
||||
Container *Container `xml:"Container,omitempty"`
|
||||
Index string `xml:"Index,omitempty"`
|
||||
}
|
||||
|
||||
type Snapshot struct {
|
||||
Mode string `xml:"Mode,omitempty"`
|
||||
Start string `xml:"Start,omitempty"`
|
||||
TimeInterval string `xml:"TimeInterval,omitempty"`
|
||||
Count string `xml:"Count,omitempty"`
|
||||
Width string `xml:"Width,omitempty"`
|
||||
Height string `xml:"Height,omitempty"`
|
||||
}
|
||||
type MediaProcessJobOperation struct {
|
||||
Output *JobOutput `xml:"Output,omitempty"`
|
||||
Transcode *Transcode `xml:"Transcode,omitempty"`
|
||||
@@ -116,6 +125,7 @@ type MediaProcessJobOperation struct {
|
||||
TemplateId string `xml:"TemplateId,omitempty"`
|
||||
WatermarkTemplateId []string `xml:"WatermarkTemplateId,omitempty"`
|
||||
ConcatTemplate *ConcatTemplate `xml:"ConcatTemplate,omitempty"`
|
||||
Snapshot *Snapshot `xml:"Snapshot,omitempty"`
|
||||
}
|
||||
|
||||
type CreateMediaJobsOptions struct {
|
||||
@@ -187,9 +197,9 @@ type DescribeMediaJobsOptions struct {
|
||||
}
|
||||
|
||||
type DescribeMediaJobsResult struct {
|
||||
XMLName xml.Name `xml:"Response"`
|
||||
JobsDetail []DocProcessJobDetail `xml:"JobsDetail,omitempty"`
|
||||
NextToken string `xml:"NextToken,omitempty"`
|
||||
XMLName xml.Name `xml:"Response"`
|
||||
JobsDetail []MediaProcessJobDetail `xml:"JobsDetail,omitempty"`
|
||||
NextToken string `xml:"NextToken,omitempty"`
|
||||
}
|
||||
|
||||
func (s *CIService) DescribeMediaJobs(ctx context.Context, opt *DescribeMediaJobsOptions) (*DescribeMediaJobsResult, *Response, error) {
|
||||
|
||||
@@ -30,6 +30,63 @@ func log_status(err error) {
|
||||
}
|
||||
}
|
||||
|
||||
func InvokeSnapshotTask() {
|
||||
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
|
||||
createJobOpt := &cos.CreateMediaJobsOptions{
|
||||
Tag: "Snapshot",
|
||||
Input: &cos.JobInput{
|
||||
Object: "input/117374C.mp4",
|
||||
},
|
||||
Operation: &cos.MediaProcessJobOperation{
|
||||
Output: &cos.JobOutput{
|
||||
Region: "ap-beijing",
|
||||
Object: "output/${InputName}-${Number}.jpg",
|
||||
Bucket: "wwj-bj-1253960454",
|
||||
},
|
||||
// TemplateId:"t1af5d050a8b4d45d1afb60bfbacbfa0f0",
|
||||
Snapshot: &cos.Snapshot{
|
||||
Mode: "Interval",
|
||||
Start: "0",
|
||||
Count: "1",
|
||||
},
|
||||
},
|
||||
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 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")
|
||||
@@ -81,10 +138,10 @@ func InvokeConcatTask() {
|
||||
Format: "mp4",
|
||||
},
|
||||
Video: &cos.Video{
|
||||
Codec: "H.264",
|
||||
Codec: "H.265",
|
||||
},
|
||||
Audio: &cos.Audio{
|
||||
Codec: "AAC",
|
||||
//Codec: "AAC",
|
||||
},
|
||||
ConcatFragment:concatFragment,
|
||||
},
|
||||
@@ -168,6 +225,8 @@ func InvokeTranscodeTask() {
|
||||
}
|
||||
|
||||
func main() {
|
||||
InvokeConcatTask()
|
||||
//InvokeTranscodeTask()
|
||||
InvokeSnapshotTask()
|
||||
// InvokeConcatTask()
|
||||
// InvokeTranscodeTask()
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user