@@ -3,6 +3,7 @@ package cos
33import (
44 "context"
55 "encoding/xml"
6+ "fmt"
67 "net/http"
78)
89
@@ -506,6 +507,7 @@ type MediaProcessBucket struct {
506507 CreateTime string `xml:"CreateTime,omitempty"`
507508}
508509
510+ // 媒体bucket接口 https://cloud.tencent.com/document/product/436/48988
509511func (s * CIService ) DescribeMediaProcessBuckets (ctx context.Context , opt * DescribeMediaProcessBucketsOptions ) (* DescribeMediaProcessBucketsResult , * Response , error ) {
510512 var res DescribeMediaProcessBucketsResult
511513 sendOpt := sendOptions {
@@ -518,3 +520,123 @@ func (s *CIService) DescribeMediaProcessBuckets(ctx context.Context, opt *Descri
518520 resp , err := s .client .send (ctx , & sendOpt )
519521 return & res , resp , err
520522}
523+
524+ type GetMediaInfoResult struct {
525+ XMLName xml.Name `xml:"Response"`
526+ MediaInfo struct {
527+ Format struct {
528+ Bitrate float32 `xml:"Bitrate"`
529+ Duration float32 `xml:"Duration"`
530+ FormatLongName string `xml:"FormatLongName"`
531+ FormatName string `xml:"FormatName"`
532+ NumProgram int `xml:"NumProgram"`
533+ NumStream int `xml:"NumStream"`
534+ Size int `xml:"Size"`
535+ StartTime float32 `xml:"StartTime"`
536+ } `xml:"Format"`
537+ Stream struct {
538+ Audio []struct {
539+ Index int `xml:"Index"`
540+ CodecName string `xml:"CodecName"`
541+ CodecLongName string `xml:"CodecLongName"`
542+ CodecTimeBase string `xml:"CodecTimeBase"`
543+ CodecTagString string `xml:"CodecTagString"`
544+ CodecTag string `xml:"CodecTag"`
545+ SampleFmt string `xml:"SampleFmt"`
546+ SampleRate int `xml:"SampleRate"`
547+ Channel int `xml:"Channel"`
548+ ChannelLayout string `xml:"ChannelLayout"`
549+ Timebase string `xml:"Timebase"`
550+ StartTime float32 `xml:"StartTime"`
551+ Duration float32 `xml:"Duration"`
552+ Bitrate float32 `xml:"Bitrate"`
553+ Language string `xml:"Language"`
554+ } `xml:"Audio"`
555+ Subtitle struct {
556+ Index int `xml:"Index"`
557+ Language string `xml:"Language"`
558+ } `xml:"Subtitle"`
559+ Video struct {
560+ Index int `xml:"Index"`
561+ CodecName string `xml:"CodecName"`
562+ CodecLongName string `xml:"CodecLongName"`
563+ CodecTimeBase string `xml:"CodecTimeBase"`
564+ CodecTagString string `xml:"CodecTagString"`
565+ CodecTag string `xml:"CodecTag"`
566+ Profile string `xml:"Profile"`
567+ Height int `xml:"Height"`
568+ Width int `xml:"Width"`
569+ HasBFrame int `xml:"HasBFrame"`
570+ RefFrames int `xml:"RefFrames"`
571+ Sar string `xml:"Sar"`
572+ Dar string `xml:"Dar"`
573+ PixFormat string `xml:"PixFormat"`
574+ FieldOrder string `xml:"FieldOrder"`
575+ Level int `xml:"Level"`
576+ Fps float32 `xml:"Fps"`
577+ AvgFps string `xml:"AvgFps"`
578+ Timebase string `xml:"Timebase"`
579+ StartTime float32 `xml:"StartTime"`
580+ Duration float32 `xml:"Duration"`
581+ Bitrate float32 `xml:"Bitrate"`
582+ NumFrames int `xml:"NumFrames"`
583+ Language string `xml:"Language"`
584+ } `xml:"Video"`
585+ } `xml:"Stream"`
586+ } `xml:"MediaInfo"`
587+ }
588+
589+ // 媒体信息接口 https://cloud.tencent.com/document/product/436/55672
590+ func (s * CIService ) GetMediaInfo (ctx context.Context , name string , opt * ObjectGetOptions , id ... string ) (* GetMediaInfoResult , * Response , error ) {
591+ var u string
592+ if len (id ) == 1 {
593+ u = fmt .Sprintf ("/%s?versionId=%s&ci-process=videoinfo" , encodeURIComponent (name ), id [0 ])
594+ } else if len (id ) == 0 {
595+ u = fmt .Sprintf ("/%s?ci-process=videoinfo" , encodeURIComponent (name ))
596+ } else {
597+ return nil , nil , fmt .Errorf ("wrong params" )
598+ }
599+
600+ var res GetMediaInfoResult
601+ sendOpt := sendOptions {
602+ baseURL : s .client .BaseURL .BucketURL ,
603+ uri : u ,
604+ method : http .MethodGet ,
605+ optQuery : opt ,
606+ optHeader : opt ,
607+ result : & res ,
608+ }
609+ resp , err := s .client .send (ctx , & sendOpt )
610+ return & res , resp , err
611+ }
612+
613+ type GetSnapshotOptions struct {
614+ Time float32 `url:"time,omitempty"`
615+ Height int `url:"height,omitempty"`
616+ Width int `url:"width,omitempty"`
617+ Format string `url:"format,omitempty"`
618+ Rotate string `url:"rotate,omitempty"`
619+ Mode string `url:"mode,omitempty"`
620+ }
621+
622+ // 媒体截图接口 https://cloud.tencent.com/document/product/436/55671
623+ func (s * CIService ) GetSnapshot (ctx context.Context , name string , opt * GetSnapshotOptions , id ... string ) (* Response , error ) {
624+ var u string
625+ if len (id ) == 1 {
626+ u = fmt .Sprintf ("/%s?versionId=%s&ci-process=snapshot" , encodeURIComponent (name ), id [0 ])
627+ } else if len (id ) == 0 {
628+ u = fmt .Sprintf ("/%s?ci-process=snapshot" , encodeURIComponent (name ))
629+ } else {
630+ return nil , fmt .Errorf ("wrong params" )
631+ }
632+
633+ sendOpt := sendOptions {
634+ baseURL : s .client .BaseURL .BucketURL ,
635+ uri : u ,
636+ method : http .MethodGet ,
637+ optQuery : opt ,
638+ disableCloseBody : true ,
639+ }
640+ resp , err := s .client .send (ctx , & sendOpt )
641+ return resp , err
642+ }
0 commit comments