@@ -112,7 +112,7 @@ func CreateWorkflow() {
112112 Dependencies : map [string ]string {"Start" : "Transcode_1581665960537" , "Transcode_1581665960537" : "Snapshot_1581665960536" ,
113113 "Snapshot_1581665960536" : "End" },
114114 Nodes : map [string ]cos.Node {"Start" : cos.Node {Type : "Start" , Input : & cos.NodeInput {QueueId : "p09d709939fef48a0a5c247ef39d90cec" ,
115- ObjectPrefix : "wk-test" , ExtFilter : & cos.ExtFilter {State : "On" , CustomExts : "mp4" }}},
115+ ObjectPrefix : "wk-test" , ExtFilter : & cos.ExtFilter {State : "On" , Custom : "true" , CustomExts : "mp4" }}},
116116 "Transcode_1581665960537" : cos.Node {Type : "Transcode" , Operation : & cos.NodeOperation {TemplateId : "t01e57db1c2d154d2fb57aa5de9313a897" ,
117117 Output : & cos.NodeOutput {Region : "ap-chongqing" , Bucket : "lilang-1253960454" , Object : "trans1.mp4" }}},
118118 "Snapshot_1581665960536" : cos.Node {Type : "Snapshot" , Operation : & cos.NodeOperation {TemplateId : "t07740e32081b44ad7a0aea03adcffd54a" ,
@@ -136,82 +136,181 @@ func CreateWorkflow() {
136136 }
137137}
138138
139- // // UpdateTranscodeWorkflow TODO
140- // func UpdateTranscodeWorkflow() {
141- // u, _ := url.Parse("https://lilang-1253960454.cos.ap-chongqing.myqcloud.com")
142- // cu, _ := url.Parse("https://lilang-1253960454.ci.ap-chongqing.myqcloud.com")
143- // b := &cos.BaseURL{BucketURL: u, CIURL: cu}
144- // c := cos.NewClient(b, &http.Client{
145- // Transport: &cos.AuthorizationTransport{
146- // SecretID: os.Getenv("COS_SECRETID"),
147- // SecretKey: os.Getenv("COS_SECRETKEY"),
148- // Transport: &debug.DebugRequestTransport{
149- // RequestHeader: true,
150- // // Notice when put a large file and set need the request body, might happend out of memory error.
151- // RequestBody: true,
152- // ResponseHeader: true,
153- // ResponseBody: true,
154- // },
155- // },
156- // })
157- // // UpdateMediaWorkflow
158- // rand.Seed(time.Now().UnixNano())
159- // updateTplOpt := &cos.CreateMediaTranscodeWorkflowOptions{
160- // Tag: "Transcode",
161- // Name: "transtpl-" + strconv.Itoa(rand.Intn(100)),
162- // Container: &cos.Container{
163- // Format: "mp4",
164- // },
165- // Video: &cos.Video{
166- // Codec: "h.264",
167- // Width: "1280",
168- // Fps: "30",
169- // Crf: "26",
170- // },
171- // Audio: &cos.Audio{
172- // Codec: "aac",
173- // },
174- // TimeInterval: &cos.TimeInterval{
175- // Start: "0",
176- // Duration: "",
177- // },
178- // }
179- // WorkflowId := "t1d31d58d8a4204d7396087f56a448abd5"
180- // updateTplRes, _, err := c.CI.UpdateMediaTranscodeWorkflow(context.Background(), updateTplOpt, WorkflowId)
181- // log_status(err)
182- // fmt.Printf("%+v\n", updateTplRes.Workflow)
139+ // UpdateWorkflow TODO
140+ func UpdateWorkflow () {
141+ u , _ := url .Parse ("https://lilang-1253960454.cos.ap-chongqing.myqcloud.com" )
142+ cu , _ := url .Parse ("https://lilang-1253960454.ci.ap-chongqing.myqcloud.com" )
143+ b := & cos.BaseURL {BucketURL : u , CIURL : cu }
144+ c := cos .NewClient (b , & http.Client {
145+ Transport : & cos.AuthorizationTransport {
146+ SecretID : os .Getenv ("COS_SECRETID" ),
147+ SecretKey : os .Getenv ("COS_SECRETKEY" ),
148+ Transport : & debug.DebugRequestTransport {
149+ RequestHeader : true ,
150+ // Notice when put a large file and set need the request body, might happend out of memory error.
151+ RequestBody : true ,
152+ ResponseHeader : true ,
153+ ResponseBody : true ,
154+ },
155+ },
156+ })
157+ // UpdateMediaWorkflow
158+ rand .Seed (time .Now ().UnixNano ())
159+ updateWorkflowOpt := & cos.CreateMediaWorkflowOptions {
160+ MediaWorkflow : & cos.MediaWorkflow {
161+ Name : "workflow-" + strconv .Itoa (rand .Intn (100 )),
162+ State : "Paused" ,
163+ Topology : & cos.Topology {
164+ Dependencies : map [string ]string {"Start" : "Transcode_1581665960537" , "Transcode_1581665960537" : "Snapshot_1581665960536" ,
165+ "Snapshot_1581665960536" : "End" },
166+ Nodes : map [string ]cos.Node {"Start" : cos.Node {Type : "Start" , Input : & cos.NodeInput {QueueId : "p09d709939fef48a0a5c247ef39d90cec" ,
167+ ObjectPrefix : "wk-test" , ExtFilter : & cos.ExtFilter {State : "On" , Custom : "true" , CustomExts : "mp4" }}},
168+ "Transcode_1581665960537" : cos.Node {Type : "Transcode" , Operation : & cos.NodeOperation {TemplateId : "t01e57db1c2d154d2fb57aa5de9313a897" ,
169+ Output : & cos.NodeOutput {Region : "ap-chongqing" , Bucket : "lilang-1253960454" , Object : "trans1.mp4" }}},
170+ "Snapshot_1581665960536" : cos.Node {Type : "Snapshot" , Operation : & cos.NodeOperation {TemplateId : "t07740e32081b44ad7a0aea03adcffd54a" ,
171+ Output : & cos.NodeOutput {Region : "ap-chongqing" , Bucket : "lilang-1253960454" , Object : "snapshot-${number}.jpg" }}},
172+ },
173+ },
174+ },
175+ }
176+ WorkflowId := "web6ac56c1ef54dbfa44d7f4103203be9"
177+ updateWorkflowRes , _ , err := c .CI .UpdateMediaWorkflow (context .Background (), updateWorkflowOpt , WorkflowId )
178+ log_status (err )
179+ fmt .Printf ("%+v\n " , updateWorkflowRes .MediaWorkflow )
180+
181+ opt := & cos.DescribeMediaWorkflowOptions {
182+ Ids : WorkflowId ,
183+ }
184+ DescribeWorkflowRes , _ , err := c .CI .DescribeMediaWorkflow (context .Background (), opt )
185+ log_status (err )
186+ fmt .Printf ("%+v\n " , DescribeWorkflowRes )
187+ }
188+
189+ // CreateStreamWorkflow 创建自适应码流工作流
190+ func CreateStreamWorkflow () {
191+ u , _ := url .Parse ("https://lilang-1253960454.cos.ap-chongqing.myqcloud.com" )
192+ cu , _ := url .Parse ("https://lilang-1253960454.ci.ap-chongqing.myqcloud.com" )
193+ b := & cos.BaseURL {BucketURL : u , CIURL : cu }
194+ c := cos .NewClient (b , & http.Client {
195+ Transport : & cos.AuthorizationTransport {
196+ SecretID : os .Getenv ("COS_SECRETID" ),
197+ SecretKey : os .Getenv ("COS_SECRETKEY" ),
198+ Transport : & debug.DebugRequestTransport {
199+ RequestHeader : true ,
200+ // Notice when put a large file and set need the request body, might happend out of memory error.
201+ RequestBody : true ,
202+ ResponseHeader : true ,
203+ ResponseBody : true ,
204+ },
205+ },
206+ })
207+ // CreateMediaWorkflow
208+ rand .Seed (time .Now ().UnixNano ())
209+ hpi := & cos.NodeHlsPackInfo {}
210+ vsc1 := & cos.VideoStreamConfig {VideoStreamName : "VideoStream_1581665960536" , BandWidth : "200000" }
211+ vsc2 := & cos.VideoStreamConfig {VideoStreamName : "VideoStream_1581665960537" , BandWidth : "500000" }
212+ hpi .VideoStreamConfig = append (hpi .VideoStreamConfig , * vsc1 , * vsc2 )
213+ createWorkflowOpt := & cos.CreateMediaWorkflowOptions {
214+ MediaWorkflow : & cos.MediaWorkflow {
215+ Name : "workflow-" + strconv .Itoa (rand .Intn (100 )),
216+ State : "Active" ,
217+ Topology : & cos.Topology {
218+ Dependencies : map [string ]string {"Start" : "StreamPackConfig_1581665960532" , "StreamPackConfig_1581665960532" : "VideoStream_1581665960536,VideoStream_1581665960537" ,
219+ "VideoStream_1581665960536" : "StreamPack_1581665960538" , "VideoStream_1581665960537" : "StreamPack_1581665960538" ,
220+ "StreamPack_1581665960538" : "End" },
221+ Nodes : map [string ]cos.Node {"Start" : cos.Node {Type : "Start" , Input : & cos.NodeInput {QueueId : "p09d709939fef48a0a5c247ef39d90cec" ,
222+ ObjectPrefix : "wk-test" , ExtFilter : & cos.ExtFilter {State : "On" , Custom : "true" , CustomExts : "mp4" }}},
223+ "StreamPackConfig_1581665960532" : cos.Node {Type : "StreamPackConfig" , Operation : & cos.NodeOperation {
224+ Output : & cos.NodeOutput {Region : "ap-chongqing" , Bucket : "lilang-1253960454" , Object : "${InputPath}/${InputName}._${RunId}.${ext}" },
225+ StreamPackConfigInfo : & cos.NodeStreamPackConfigInfo {PackType : "HLS" , IgnoreFailedStream : true }}},
226+ "VideoStream_1581665960536" : cos.Node {Type : "VideoStream" , Operation : & cos.NodeOperation {TemplateId : "t03e862f296fba4152a1dd186b4ad5f64b" ,
227+ Output : & cos.NodeOutput {Region : "ap-chongqing" , Bucket : "lilang-1253960454" , Object : "${RunId}_Substream_1/video.m3u8" }}},
228+ "VideoStream_1581665960537" : cos.Node {Type : "VideoStream" , Operation : & cos.NodeOperation {TemplateId : "t09f9da59ed3c44ecd8ea1778e5ce5669c" ,
229+ Output : & cos.NodeOutput {Region : "ap-chongqing" , Bucket : "lilang-1253960454" , Object : "${RunId}_Substream_1/video.m3u8" }}},
230+ "StreamPack_1581665960538" : cos.Node {Type : "StreamPack" , Operation : & cos.NodeOperation {StreamPackInfo : hpi }},
231+ },
232+ },
233+ },
234+ }
235+ createWorkflowRes , _ , err := c .CI .CreateMediaWorkflow (context .Background (), createWorkflowOpt )
236+ log_status (err )
237+ fmt .Printf ("%+v\n " , createWorkflowRes .MediaWorkflow )
238+
239+ // DescribeMediaWorkflow
240+ if createWorkflowRes .MediaWorkflow != nil {
241+ opt := & cos.DescribeMediaWorkflowOptions {
242+ Ids : createWorkflowRes .MediaWorkflow .WorkflowId ,
243+ }
244+ DescribeWorkflowRes , _ , err := c .CI .DescribeMediaWorkflow (context .Background (), opt )
245+ log_status (err )
246+ fmt .Printf ("%+v\n " , DescribeWorkflowRes )
247+ }
248+ }
249+
250+ // UpdatStreamWorkflow 更新自适应码流工作流
251+ func UpdatStreamWorkflow () {
252+ u , _ := url .Parse ("https://lilang-1253960454.cos.ap-chongqing.myqcloud.com" )
253+ cu , _ := url .Parse ("https://lilang-1253960454.ci.ap-chongqing.myqcloud.com" )
254+ b := & cos.BaseURL {BucketURL : u , CIURL : cu }
255+ c := cos .NewClient (b , & http.Client {
256+ Transport : & cos.AuthorizationTransport {
257+ SecretID : os .Getenv ("COS_SECRETID" ),
258+ SecretKey : os .Getenv ("COS_SECRETKEY" ),
259+ Transport : & debug.DebugRequestTransport {
260+ RequestHeader : true ,
261+ // Notice when put a large file and set need the request body, might happend out of memory error.
262+ RequestBody : true ,
263+ ResponseHeader : true ,
264+ ResponseBody : true ,
265+ },
266+ },
267+ })
268+ // UpdateMediaWorkflow
269+ rand .Seed (time .Now ().UnixNano ())
270+ hpi := & cos.NodeHlsPackInfo {}
271+ vsc1 := & cos.VideoStreamConfig {VideoStreamName : "VideoStream_1581665960536" , BandWidth : "200000" }
272+ vsc2 := & cos.VideoStreamConfig {VideoStreamName : "VideoStream_1581665960537" , BandWidth : "500000" }
273+ hpi .VideoStreamConfig = append (hpi .VideoStreamConfig , * vsc1 , * vsc2 )
274+ updateWorkflowOpt := & cos.CreateMediaWorkflowOptions {
275+ MediaWorkflow : & cos.MediaWorkflow {
276+ Name : "workflow-" + strconv .Itoa (rand .Intn (100 )),
277+ State : "Active" ,
278+ Topology : & cos.Topology {
279+ Dependencies : map [string ]string {"Start" : "StreamPackConfig_1581665960532" , "StreamPackConfig_1581665960532" : "VideoStream_1581665960536,VideoStream_1581665960537" ,
280+ "VideoStream_1581665960536" : "StreamPack_1581665960538" , "VideoStream_1581665960537" : "StreamPack_1581665960538" ,
281+ "StreamPack_1581665960538" : "End" },
282+ Nodes : map [string ]cos.Node {"Start" : cos.Node {Type : "Start" , Input : & cos.NodeInput {QueueId : "p09d709939fef48a0a5c247ef39d90cec" ,
283+ ObjectPrefix : "wk-test" , ExtFilter : & cos.ExtFilter {State : "On" , Custom : "true" , CustomExts : "mp4" }}},
284+ "StreamPackConfig_1581665960532" : cos.Node {Type : "StreamPackConfig" , Operation : & cos.NodeOperation {
285+ Output : & cos.NodeOutput {Region : "ap-chongqing" , Bucket : "lilang-1253960454" , Object : "${InputPath}/${InputName}._${RunId}.${ext}" },
286+ StreamPackConfigInfo : & cos.NodeStreamPackConfigInfo {PackType : "HLS" , IgnoreFailedStream : true }}},
287+ "VideoStream_1581665960536" : cos.Node {Type : "VideoStream" , Operation : & cos.NodeOperation {TemplateId : "t03e862f296fba4152a1dd186b4ad5f64b" ,
288+ Output : & cos.NodeOutput {Region : "ap-chongqing" , Bucket : "lilang-1253960454" , Object : "${RunId}_Substream_1/video.m3u8" }}},
289+ "VideoStream_1581665960537" : cos.Node {Type : "VideoStream" , Operation : & cos.NodeOperation {TemplateId : "t09f9da59ed3c44ecd8ea1778e5ce5669c" ,
290+ Output : & cos.NodeOutput {Region : "ap-chongqing" , Bucket : "lilang-1253960454" , Object : "${RunId}_Substream_1/video.m3u8" }}},
291+ "StreamPack_1581665960538" : cos.Node {Type : "StreamPack" , Operation : & cos.NodeOperation {StreamPackInfo : hpi }},
292+ },
293+ },
294+ },
295+ }
296+ WorkflowId := "w5fecd57f8a7745b3ac8143b211613789"
297+ updateWorkflowRes , _ , err := c .CI .UpdateMediaWorkflow (context .Background (), updateWorkflowOpt , WorkflowId )
298+ log_status (err )
299+ fmt .Printf ("%+v\n " , updateWorkflowRes .MediaWorkflow )
183300
184- // opt := &cos.DescribeMediaWorkflowOptions{
185- // Ids: WorkflowId,
186- // }
187- // DescribeWorkflowRes, _, err := c.CI.DescribeMediaWorkflow(context.Background(), opt)
188- // log_status(err)
189- // fmt.Printf("%+v\n", DescribeWorkflowRes)
190- // }
301+ opt := & cos.DescribeMediaWorkflowOptions {
302+ Ids : WorkflowId ,
303+ }
304+ DescribeWorkflowRes , _ , err := c .CI .DescribeMediaWorkflow (context .Background (), opt )
305+ log_status (err )
306+ fmt .Printf ("%+v\n " , DescribeWorkflowRes )
307+ }
191308
192309func main () {
193- DescribeWorkflow ()
310+ // DescribeWorkflow()
194311 // DeleteWorkflow()
195312 // CreateWorkflow()
196- // UpdateTranscodeWorkflow()
197- // CreateSnapshotWorkflow()
198- // UpdateSnapshotWorkflow()
199- // CreateHighSpeedHdWorkflow()
200- // UpdateHighSpeedHdWorkflow()
201- // CreateAnimationWorkflow()
202- // UpdateAnimationWorkflow()
203- // CreateConcatWorkflow()
204- // UpdateConcatWorkflow()
205- // CreateVideoProcessWorkflow()
206- // UpdateVideoProcessWorkflow()
207- // CreateVideoMontageWorkflow()
208- // UpdateVideoMontageWorkflow()
209- // CreateVoiceSeparateWorkflow()
210- // UpdateVoiceSeparateWorkflow()
211- // CreateSuperResolutionWorkflow()
212- // UpdateSuperResolutionWorkflow()
213- // CreatePicProcessWorkflow()
214- // UpdatePicProcessWorkflow()
215- // CreateWatermarkWorkflow()
216- // UpdateWatermarkWorkflow()
313+ // UpdateWorkflow()
314+ // CreateStreamWorkflow()
315+ UpdatStreamWorkflow ()
217316}
0 commit comments