Skip to content

Commit 3c3a1ec

Browse files
committed
Merge branch 'dev-mediainfo' into 'master' (merge request !19)
add:支持万象域名下媒体接口
2 parents 9cc16ad + 117b5d3 commit 3c3a1ec

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

ci_media.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,26 @@ func (s *CIService) GetMediaInfo(ctx context.Context, name string, opt *ObjectGe
723723
return &res, resp, err
724724
}
725725

726+
type GenerateMediaInfoOptions struct {
727+
XMLName xml.Name `xml:"Request"`
728+
Input *JobInput `xml:"Input,omitempty"`
729+
}
730+
731+
// 生成媒体信息接口,支持大文件,耗时较大请求
732+
func (s *CIService) GenerateMediaInfo(ctx context.Context, opt *GenerateMediaInfoOptions) (*GetMediaInfoResult, *Response, error) {
733+
734+
var res GetMediaInfoResult
735+
sendOpt := sendOptions{
736+
baseURL: s.client.BaseURL.CIURL,
737+
uri: "/mediainfo",
738+
method: http.MethodPost,
739+
body: opt,
740+
result: &res,
741+
}
742+
resp, err := s.client.send(ctx, &sendOpt)
743+
return &res, resp, err
744+
}
745+
726746
type GetSnapshotOptions struct {
727747
Time float32 `url:"time,omitempty"`
728748
Height int `url:"height,omitempty"`

example/CI/media_process/media_process.go

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1040,6 +1040,34 @@ func DescribeJob() {
10401040
fmt.Printf("%+v\n", DescribeJobRes.JobsDetail.Operation.MediaResult)
10411041
}
10421042

1043+
func GenerateMediaInfo() {
1044+
u, _ := url.Parse("https://wwj-cq-1253960454.cos.ap-chongqing.myqcloud.com")
1045+
cu, _ := url.Parse("https://wwj-cq-1253960454.ci.ap-chongqing.myqcloud.com")
1046+
b := &cos.BaseURL{BucketURL: u, CIURL: cu}
1047+
c := cos.NewClient(b, &http.Client{
1048+
Transport: &cos.AuthorizationTransport{
1049+
SecretID: os.Getenv("COS_SECRETID"),
1050+
SecretKey: os.Getenv("COS_SECRETKEY"),
1051+
Transport: &debug.DebugRequestTransport{
1052+
RequestHeader: true,
1053+
// Notice when put a large file and set need the request body, might happend out of memory error.
1054+
RequestBody: true,
1055+
ResponseHeader: true,
1056+
ResponseBody: true,
1057+
},
1058+
},
1059+
})
1060+
opt := &cos.GenerateMediaInfoOptions{
1061+
Input: &cos.JobInput{
1062+
Object: "video02.mp4",
1063+
},
1064+
}
1065+
// DescribeMediaJobs
1066+
res, _, err := c.CI.GenerateMediaInfo(context.Background(), opt)
1067+
log_status(err)
1068+
fmt.Printf("%+v\n", res)
1069+
}
1070+
10431071
func main() {
10441072
// InvokeSnapshotJob()
10451073
// InvokeConcatJob()
@@ -1061,5 +1089,6 @@ func main() {
10611089
// DescribeMultiWorkflowExecution()
10621090
// InvokeASRJob()
10631091
// DescribeASRJob()
1064-
DescribeJob()
1092+
// DescribeJob()
1093+
GenerateMediaInfo()
10651094
}

0 commit comments

Comments
 (0)