Skip to content

Commit

Permalink
地图拼接需求
Browse files Browse the repository at this point in the history
  • Loading branch information
lilang committed Jun 26, 2023
1 parent 5a5195c commit 6ac0209
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 1 deletion.
29 changes: 29 additions & 0 deletions ci_media.go
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,8 @@ type MediaProcessJobOperation struct {
SpeechRecognition *SpeechRecognition `xml:"SpeechRecognition,omitempty"`
SpeechRecognitionResult *SpeechRecognitionResult `xml:"SpeechRecognitionResult,omitempty"`
SoundHoundResult *SoundHoundResult `xml:"SoundHoundResult,omitempty"`
FillConcat *FillConcat `xml:"FillConcat,omitempty"`
VideoSynthesis *VideoSynthesis `xml:"VideoSynthesis,omitempty"`
}

// CreatePicJobsOptions TODO
Expand Down Expand Up @@ -3400,3 +3402,30 @@ func (s *CIService) DeleteTemplate(ctx context.Context, tempalteId string) (*Del
resp, err := s.client.send(ctx, &sendOpt)
return &res, resp, err
}

// FillConcat 填充拼接
type FillConcat struct {
Format string `xml:"Format,omitempty"`
FillInput []FillConcatInput `xml:"FillInput,omitempty"`
}

// FillConcatInput 填充拼接输入
type FillConcatInput struct {
Url string `xml:"Url,omitempty"`
FillTime string `xml:"FillTime,omitempty"`
}

// VideoSynthesis 视频合成
type VideoSynthesis struct {
KeepAudioTrack string `xml:"KeepAudioTrack,omitempty"`
SpliceInfo []VideoSynthesisSpliceInfo `xml:"SpliceInfo,omitempty"`
}

// VideoSynthesisSpliceInfo 视频合成输入
type VideoSynthesisSpliceInfo struct {
Url string `xml:"Url,omitempty"`
X string `xml:"X,omitempty"`
Y string `xml:"Y,omitempty"`
Width string `xml:"Width,omitempty"`
Height string `xml:"Height,omitempty"`
}
95 changes: 94 additions & 1 deletion example/CI/workflow_and_job/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func DescribeJobs() {
// https://cloud.tencent.com/document/product/460/84765
func DescribeJob() {
c := getClient()
DescribeJobRes, _, err := c.CI.DescribeJob(context.Background(), "j5c6b2d1e044e11ee8b23bda0f853af96")
DescribeJobRes, _, err := c.CI.DescribeJob(context.Background(), "ja507fb3413f711eebccc9dd62ab48c0e")
log_status(err)
fmt.Printf("%+v\n", DescribeJobRes.JobsDetail)
}
Expand Down Expand Up @@ -952,6 +952,99 @@ func InvokeMultiJobs() {
}
}

// InvokeFillConcatJob 提交一个填充拼接任务
func InvokeFillConcatJob() {
c := getClient()
FillConcat := make([]cos.FillConcatInput, 0)
FillConcat = append(FillConcat, cos.FillConcatInput{
Url: "https://lilang-1253960454.cos.ap-chongqing.myqcloud.com/input/car.mp4",
})
FillConcat = append(FillConcat, cos.FillConcatInput{
FillTime: "5.5",
})
FillConcat = append(FillConcat, cos.FillConcatInput{
Url: "https://lilang-1253960454.cos.ap-chongqing.myqcloud.com/input/game.mp4",
})
createJobOpt := &cos.CreateJobsOptions{
Tag: "FillConcat",
Operation: &cos.MediaProcessJobOperation{
FillConcat: &cos.FillConcat{
Format: "mp4",
FillInput: FillConcat,
},
Output: &cos.JobOutput{
Region: "ap-chongqing",
Object: "fill_concat.mp4",
Bucket: "lilang-1253960454",
},
},
}
createJobRes, _, err := c.CI.CreateJob(context.Background(), createJobOpt)
log_status(err)
fmt.Printf("%+v\n", createJobRes.JobsDetail)
}

// InvokeVideoSynthesisJob 提交一个视频合成任务
func InvokeVideoSynthesisJob() {
c := getClient()
SpliceInfo := make([]cos.VideoSynthesisSpliceInfo, 0)
SpliceInfo = append(SpliceInfo, cos.VideoSynthesisSpliceInfo{
Url: "https://lilang-1253960454.cos.ap-chongqing.myqcloud.com/input/car.mp4",
Width: "640",
})
SpliceInfo = append(SpliceInfo, cos.VideoSynthesisSpliceInfo{
Url: "https://lilang-1253960454.cos.ap-chongqing.myqcloud.com/input/game.mp4",
X: "640",
Width: "640",
})
w := cos.Watermark{
Type: "Text",
LocMode: "Absolute",
Dx: "640",
Pos: "TopLeft",
Text: &cos.Text{
Text: "helloworld",
FontSize: "25",
FontType: "simfang.ttf",
FontColor: "0xff0000",
Transparency: "100",
},
}
ws := []cos.Watermark{}
ws = append(ws, w)
createJobOpt := &cos.CreateJobsOptions{
Tag: "VideoSynthesis",
Operation: &cos.MediaProcessJobOperation{
VideoSynthesis: &cos.VideoSynthesis{
KeepAudioTrack: "false",
SpliceInfo: SpliceInfo,
},
Transcode: &cos.Transcode{
Container: &cos.Container{
Format: "mp4",
},
Video: &cos.Video{
Codec: "H.264",
Width: "1280",
Height: "960",
},
Audio: &cos.Audio{
Codec: "AAC",
},
},
Watermark: ws,
Output: &cos.JobOutput{
Region: "ap-chongqing",
Object: "video_synthesis.mp4",
Bucket: "lilang-1253960454",
},
},
}
createJobRes, _, err := c.CI.CreateJob(context.Background(), createJobOpt)
log_status(err)
fmt.Printf("%+v\n", createJobRes.JobsDetail)
}

// JobNotifyCallback 解析任务回调
func JobNotifyCallback() {
taskBody := "<Response><EventName>TaskFinish</EventName><JobsDetail><Code>Success</Code><CreationTime>2022-06-30T19:30:20+0800</CreationTime><EndTime>2022-06-30T19:31:56+0800</EndTime><Input><BucketId>test-123456789</BucketId><Object>input/demo.mp4</Object><Region>ap-chongqing</Region><CosHeaders><Key>Content-Type</Key><Value>video/mp4</Value></CosHeaders><CosHeaders><Key>x-cos-request-id</Key><Value>NjJiZDYwYTFfNjUzYTYyNjRfZjEwZl8xMmZhYzY5</Value></CosHeaders><CosHeaders><Key>EventName</Key><Value>cos:ObjectCreated:Put</Value></CosHeaders><CosHeaders><Key>Size</Key><Value>1424687</Value></CosHeaders></Input><JobId>j06668dc0f86811ecb90d0b03267ce0e5</JobId><Message/><Operation><DigitalWatermark><IgnoreError>false</IgnoreError><Message>123456789ab</Message><State>Failed</State><Type>Text</Type><Version>V1</Version></DigitalWatermark><MediaInfo><Format><Bitrate>8867.172000</Bitrate><Duration>13.654000</Duration><FormatLongName>QuickTime / MOV</FormatLongName><FormatName>mov,mp4,m4a,3gp,3g2,mj2</FormatName><NumProgram>0</NumProgram><NumStream>2</NumStream><Size>15134046</Size><StartTime>0.000000</StartTime></Format><Stream><Audio><Bitrate>128.726000</Bitrate><Channel>2</Channel><ChannelLayout>stereo</ChannelLayout><CodecLongName>AAC (Advanced Audio Coding)</CodecLongName><CodecName>aac</CodecName><CodecTag>0x6134706d</CodecTag><CodecTagString>mp4a</CodecTagString><CodecTimeBase>1/44100</CodecTimeBase><Duration>13.652993</Duration><Index>1</Index><Language>und</Language><SampleFmt>fltp</SampleFmt><SampleRate>44100</SampleRate><StartTime>0.000000</StartTime><Timebase>1/44100</Timebase></Audio><Subtitle/><Video><AvgFps>25.000000</AvgFps><Bitrate>9197.180000</Bitrate><CodecLongName>H.265 / HEVC (High Efficiency Video Coding)</CodecLongName><CodecName>hevc</CodecName><CodecTag>0x31766568</CodecTag><CodecTagString>hev1</CodecTagString><CodecTimeBase>1/12800</CodecTimeBase><ColorPrimaries>bt470bg</ColorPrimaries><ColorRange>tv</ColorRange><ColorTransfer>smpte170m</ColorTransfer><Duration>12.960000</Duration><FieldOrder>progressive</FieldOrder><Fps>25.000000</Fps><HasBFrame>2</HasBFrame><Height>1920</Height><Index>0</Index><Language>und</Language><Level>120</Level><NumFrames>324</NumFrames><PixFormat>yuv420p</PixFormat><Profile>Main</Profile><RefFrames>1</RefFrames><Rotation>0.000000</Rotation><StartTime>0.000000</StartTime><Timebase>1/12800</Timebase><Width>1088</Width></Video></Stream></MediaInfo><MediaResult><OutputFile><Bucket>test-123456789</Bucket><Md5Info><Md5>852883012a6ba726e6ed8d9b984edfdf</Md5><ObjectName>output/super_resolution.mp4</ObjectName></Md5Info><ObjectName>output/super_resolution.mp4</ObjectName><ObjectPrefix/><Region>ap-chongqing</Region></OutputFile></MediaResult><Output><Bucket>test-123456789</Bucket><Object>output/super_resolution.${ext}</Object><Region>ap-chongqing</Region></Output><TemplateId>t1f1ae1dfsdc9ds41dsb31632d45710642a</TemplateId><TemplateName>template_superresolution</TemplateName><TranscodeTemplateId>t156c107210e7243c5817354565d81b578</TranscodeTemplateId><UserData>This is my SuperResolution job.</UserData><JobLevel>0</JobLevel><WatermarkTemplateId>t143ae6e040af6431aa772c9ec3f0a3f36</WatermarkTemplateId><WatermarkTemplateId>t12a74d11687d444deba8a6cc52051ac27</WatermarkTemplateId></Operation><QueueId>p2242ab62c7c94486915508540933a2c6</QueueId><StartTime>2022-06-30T19:30:21+0800</StartTime><State>Success</State><Progress>100</Progress><SubTag>DigitalWatermark</SubTag><Tag>SuperResolution</Tag><Workflow><Name>SuperResolution_1581665960537</Name><RunId>ic90edd59f84f11ec9d4f525400a3c59f</RunId><WorkflowId>web6ac56c1ef54dbfa44d7f4103203be9</WorkflowId><WorkflowName>workflow-test</WorkflowName></Workflow></JobsDetail></Response>"
Expand Down

0 comments on commit 6ac0209

Please sign in to comment.