diff --git a/demo/ci_media.py b/demo/ci_media.py
index ac2cf3e7..9513e327 100644
--- a/demo/ci_media.py
+++ b/demo/ci_media.py
@@ -46,58 +46,152 @@ def ci_get_media_bucket():
def ci_get_media_queue():
# 查询媒体队列信息
response = client.ci_get_media_queue(
- Bucket=bucket_name
+ Bucket=bucket_name,
)
print(response)
return response
-def ci_create_media_transcode_watermark_jobs():
- # 创建转码任务
+def ci_get_media_pic_queue():
+ # 查询图片处理队列信息
+ response = client.ci_get_media_pic_queue(
+ Bucket=bucket_name,
+ )
+ print(response)
+ return response
+
+
+def ci_put_media_queue():
+ # 更新媒体队列信息
body = {
- 'Input':{
- 'Object':'117374C.mp4'
+ 'Name': 'media-queue',
+ 'QueueID': 'p5135bc6xxxxxxxxxxxxxxxxf047454',
+ 'State': 'Active',
+ 'NotifyConfig': {
+ 'Type': 'Url',
+ 'Url': 'http://www.demo.callback.com',
+ 'Event': 'TaskFinish',
+ 'State': 'On',
+ 'ResultFormat': 'JSON'
+ }
+ }
+ response = client.ci_update_media_queue(
+ Bucket=bucket_name,
+ QueueId='p5135bcxxxxxxxxxxxxxxxxf047454',
+ Request=body,
+ ContentType='application/xml'
+ )
+ print(response)
+ return response
+
+
+def ci_put_media_pic_queue():
+ # 更新图片处理队列信息
+ body = {
+ 'Name': 'media-pic-queue',
+ 'QueueID': 'peb83bdxxxxxxxxxxxxxxxxa21c7d68',
+ 'State': 'Active',
+ 'NotifyConfig': {
+ 'Type': 'Url',
+ 'Url': 'http://www.demo.callback.com',
+ 'Event': 'TaskFinish',
+ 'State': 'On',
+ 'ResultFormat': 'JSON'
+ }
+ }
+ response = client.ci_update_media_pic_queue(
+ Bucket=bucket_name,
+ QueueId='peb83bdxxxxxxxxxxxxxxxxxx4a21c7d68',
+ Request=body,
+ ContentType='application/xml'
+ )
+ print(response)
+ return response
+
+
+def ci_create_media_transcode_with_digital_watermark_jobs():
+ # 创建带数字水印的转码任务
+ body = {
+ 'Input': {
+ 'Object': 'demo.mp4'
},
- 'QueueId': 'pe943803693bd42d1a3105804ddaee525',
+ 'QueueId': 'p5135bcxxxxxxxxxxxxxxxx047454',
'Tag': 'Transcode',
'Operation': {
- 'Output':{'Bucket':bucket_name, 'Region':region, 'Object':'117374C_output.mp4'},
- 'TemplateId': 't02db40900dc1c43ad9bdbd8acec6075c5',
- # "WatermarkTemplateId": ["", ""],
- 'Watermark': [
- {
- 'Type':'Text',
- 'Pos':'TopRight',
- 'LocMode':'Absolute',
- 'Dx':'64',
- 'Dy': '64',
- 'StartTime':'0',
- 'EndTime':'1000.5',
- 'Text': {
- 'Text': '水印内容',
- 'FontSize': '90',
- 'FontType': 'simfang.ttf',
- 'FontColor': '0xFFEEFF',
- 'Transparency': '100',
- },
+ 'Output': {
+ 'Bucket': bucket_name,
+ 'Region': region,
+ 'Object': 'transcode_with_digital_watermark_output.mp4'
},
- {
- 'Type':'Image',
- 'Pos':'TopLeft',
- 'LocMode':'Absolute',
- 'Dx':'100',
- 'Dy': '100',
- 'StartTime':'0',
- 'EndTime':'1000.5',
- 'Image': {
- 'Url': 'http://'+bucket_name+".cos."+region+".tencentcos.cn/1215shuiyin.jpg",
- 'Mode': 'Fixed',
- 'Width': '128',
- 'Height': '128',
- 'Transparency': '100',
+ 'TemplateId': 't04e1ab86554984f1aa17c062fbf6c007c',
+ 'DigitalWatermark': {
+ 'Type': 'Text',
+ 'Message': '123456789ab',
+ 'Version': 'V1',
+ 'IgnoreError': 'false',
+ },
+ }
+ }
+ response = client.ci_create_media_jobs(
+ Bucket=bucket_name,
+ Jobs=body,
+ Lst={},
+ ContentType='application/xml'
+ )
+ print(response)
+ return response
+
+
+def ci_create_media_transcode_with_watermark_jobs():
+ # 创建带水印的转码任务
+ body = {
+ 'Input': {
+ 'Object': 'demo.mp4'
+ },
+ 'QueueId': 'p5135bc6xxxxxxxxxxxxxxxxxxbf047454',
+ 'Tag': 'Transcode',
+ 'Operation': {
+ 'Output': {
+ 'Bucket': bucket_name,
+ 'Region': region,
+ 'Object': 'transcode_with_watermark_output.mp4'
+ },
+ 'TemplateId': 't04e1ab86554984f1aa17c062fbf6c007c',
+ # "WatermarkTemplateId": ["", ""],
+ 'Watermark': [
+ {
+ 'Type': 'Text',
+ 'Pos': 'TopRight',
+ 'LocMode': 'Absolute',
+ 'Dx': '64',
+ 'Dy': '64',
+ 'StartTime': '0',
+ 'EndTime': '1000.5',
+ 'Text': {
+ 'Text': '水印内容',
+ 'FontSize': '90',
+ 'FontType': 'simfang.ttf',
+ 'FontColor': '0xFFEEFF',
+ 'Transparency': '100',
+ },
},
- }
- ]
+ {
+ 'Type': 'Image',
+ 'Pos': 'TopLeft',
+ 'LocMode': 'Absolute',
+ 'Dx': '100',
+ 'Dy': '100',
+ 'StartTime': '0',
+ 'EndTime': '1000.5',
+ 'Image': {
+ 'Url': 'http://'+bucket_name+".cos."+region+".myqcloud.com/watermark.png",
+ 'Mode': 'Fixed',
+ 'Width': '128',
+ 'Height': '128',
+ 'Transparency': '100',
+ },
+ }
+ ]
}
}
# dict中数组类型的标签,都需要特殊处理
@@ -114,20 +208,108 @@ def ci_create_media_transcode_watermark_jobs():
ContentType='application/xml'
)
print(response)
- return response
+ return response
+
+
+def ci_create_media_hls_transcode_jobs():
+ # 创建hls转码任务
+ body = {
+ 'Input': {
+ 'Object': 'demo.mp4'
+ },
+ 'QueueId': 'p5135xxxxxxxxxxxxxxxxxxxxx047454',
+ 'Tag': 'Transcode',
+ 'Operation': {
+ "Transcode": {
+ "Container": {
+ "Format": "hls"
+ },
+ "Video": {
+ "Codec": "H.264",
+ "Profile": "high",
+ "Bitrate": "1000",
+ "Width": "1280",
+ "Fps": "30",
+ "Preset": "medium",
+ "Bufsize": "1000",
+ "Maxrate": "10"
+ },
+ "Audio": {
+ "Codec": "aac",
+ "Samplerate": "44100",
+ "Bitrate": "128",
+ "Channels": "4"
+ },
+ "TransConfig": {
+ 'HlsEncrypt': {
+ 'IsHlsEncrypt': 'true',
+ 'UriKey': 'http://www.demo.com'
+ }
+ },
+ },
+ 'Output': {
+ 'Bucket': bucket_name,
+ 'Region': region,
+ 'Object': 'transcode_output.mp4'
+ },
+ # 'TemplateId': 't02db40900dc1c43ad9bdbd8acec6075c5'
+ }
+ }
+ response = client.ci_create_media_jobs(
+ Bucket=bucket_name,
+ Jobs=body,
+ Lst={},
+ ContentType='application/xml'
+ )
+ print(response)
+ return response
def ci_create_media_transcode_jobs():
# 创建转码任务
body = {
- 'Input':{
- 'Object':'117374C.mp4'
+ 'Input': {
+ 'Object': 'demo.mp4'
},
- 'QueueId': 'pe943803693bd42d1a3105804ddaee525',
+ 'QueueId': 'p5135bxxxxxxxxxxxxxxxxxx8bf047454',
'Tag': 'Transcode',
'Operation': {
- 'Output':{'Bucket':bucket_name, 'Region':region, 'Object':'117374C_output.mp4'},
- 'TemplateId': 't02db40900dc1c43ad9bdbd8acec6075c5'
+ "Transcode": {
+ "Container": {
+ "Format": "mp4"
+ },
+ "Video": {
+ "Codec": "H.264",
+ "Profile": "high",
+ "Bitrate": "1000",
+ "Width": "1280",
+ "Fps": "30",
+ "Preset": "medium",
+ "Bufsize": "1000",
+ "Maxrate": "10"
+ },
+ "Audio": {
+ "Codec": "aac",
+ "Samplerate": "44100",
+ "Bitrate": "128",
+ "Channels": "4"
+ },
+ "TransConfig": {
+ "AdjDarMethod": "scale",
+ "IsCheckReso": "false",
+ "ResoAdjMethod": "1"
+ },
+ "TimeInterval": {
+ "Start": "0",
+ "Duration": "60"
+ }
+ },
+ 'Output': {
+ 'Bucket': bucket_name,
+ 'Region': region,
+ 'Object': 'transcode_output.mp4'
+ },
+ # 'TemplateId': 't02db40900dc1c43ad9bdbd8acec6075c5'
}
}
response = client.ci_create_media_jobs(
@@ -137,30 +319,623 @@ def ci_create_media_transcode_jobs():
ContentType='application/xml'
)
print(response)
- return response
+ return response
+
+
+def ci_create_media_snapshot_jobs():
+ # 创建截图任务
+ body = {
+ 'Input': {
+ 'Object': 'demo.mp4'
+ },
+ 'QueueId': 'p5135bxxxxxxxxxxxxxxxxxxxc8bf047454',
+ 'Tag': 'Snapshot',
+ 'Operation': {
+ 'Snapshot': {
+ 'Mode': 'Interval',
+ 'Width': '1280',
+ 'Height': '1280',
+ 'Start': '0',
+ 'TimeInterval': '',
+ 'Count': '1',
+ 'SnapshotOutMode': 'SnapshotAndSprite',
+ 'SpriteSnapshotConfig': {
+ "CellHeight": "128",
+ "CellWidth": "128",
+ "Color": "White",
+ "Columns": "10",
+ "Lines": "10",
+ "Margin": "0",
+ "Padding": "0"
+ }
+ },
+ 'Output': {
+ 'Bucket': bucket_name,
+ 'Region': region,
+ 'Object': 'snapshot-${Number}.jpg',
+ 'SpriteObject': 'sprite-snapshot-${Number}.jpg'
+ },
+ # 'TemplateId': 't02db40900dc1c43ad9bdbd8acec6075c5'
+ }
+ }
+ response = client.ci_create_media_jobs(
+ Bucket=bucket_name,
+ Jobs=body,
+ Lst={},
+ ContentType='application/xml'
+ )
+ print(response)
+ return response
+
+
+def ci_create_media_animation_jobs():
+ # 创建转动图任务
+ body = {
+ 'Input': {
+ 'Object': 'demo.mp4'
+ },
+ 'QueueId': 'p5135bxxxxxxxxxxxxxxxxxxxc8bf047454',
+ 'Tag': 'Animation',
+ 'Operation': {
+ "Animation": {
+ "Container": {
+ "Format": "gif"
+ },
+ "Video": {
+ "Codec": "gif",
+ "Width": "1280",
+ "Fps": "15",
+ "AnimateOnlyKeepKeyFrame": "true"
+ },
+ "TimeInterval": {
+ "Start": "0",
+ "Duration": "60"
+ }
+ },
+ 'Output': {
+ 'Bucket': bucket_name,
+ 'Region': region,
+ 'Object': 'snapshot.gif'
+ },
+ # 'TemplateId': 't02db40900dc1c43ad9bdbd8acec6075c5'
+ }
+ }
+ response = client.ci_create_media_jobs(
+ Bucket=bucket_name,
+ Jobs=body,
+ Lst={},
+ ContentType='application/xml'
+ )
+ print(response)
+ return response
+
+
+def ci_create_media_concat_jobs():
+ # 创建拼接任务
+ body = {
+ 'Input': {
+ 'Object': 'demo.mp4'
+ },
+ 'QueueId': 'p5135bxxxxxxxxxxxxxxxxxxxc8bf047454',
+ 'Tag': 'Concat',
+ 'Operation': {
+ "ConcatTemplate": {
+ "ConcatFragment": [
+ {
+ "Url": "http://demo-1xxxxxxxxx.cos.ap-chongqing.myqcloud.com/1.mp4"
+ },
+ {
+ "Url": "http://demo-1xxxxxxxxx.cos.ap-chongqing.myqcloud.com/2.mp4"
+ }
+ ],
+ "Audio": {
+ "Codec": "mp3"
+ },
+ "Video": {
+ "Codec": "H.264",
+ "Bitrate": "1000",
+ "Width": "1280",
+ "Fps": "30"
+ },
+ "Container": {
+ "Format": "mp4"
+ }
+ },
+ 'Output': {
+ 'Bucket': bucket_name,
+ 'Region': region,
+ 'Object': 'concat-result.mp4'
+ },
+ # 'TemplateId': 't02db40900dc1c43ad9bdbd8acec6075c5'
+ }
+ }
+ lst = ['', '']
+ response = client.ci_create_media_jobs(
+ Bucket=bucket_name,
+ Jobs=body,
+ Lst=lst,
+ ContentType='application/xml'
+ )
+ print(response)
+ return response
+
+
+def ci_create_media_smart_cover_jobs():
+ # 创建智能封面任务
+ body = {
+ 'Input': {
+ 'Object': 'demo.mp4'
+ },
+ 'QueueId': 'p5135bxxxxxxxxxxxxxxxxxxxc8bf047454',
+ 'Tag': 'SmartCover',
+ 'Operation': {
+ 'SmartCover': {
+ 'Format': 'jpg',
+ 'Width': '128',
+ 'Height': '128',
+ 'Count': '3',
+ 'DeleteDuplicates': 'true'
+ },
+ 'Output': {
+ 'Bucket': bucket_name,
+ 'Region': region,
+ 'Object': 'smart-cover-${Number}.jpg'
+ },
+ # 'TemplateId': 't02db40900dc1c43ad9bdbd8acec6075c5'
+ }
+ }
+ response = client.ci_create_media_jobs(
+ Bucket=bucket_name,
+ Jobs=body,
+ Lst={},
+ ContentType='application/xml'
+ )
+ print(response)
+ return response
+
+
+def ci_create_media_video_process_jobs():
+ # 创建视频增强任务
+ body = {
+ 'Input': {
+ 'Object': 'demo.mp4'
+ },
+ 'QueueId': 'p5135bxxxxxxxxxxxxxxxxxxxc8bf047454',
+ 'Tag': 'VideoProcess',
+ 'Operation': {
+ "VideoProcess": {
+ "ColorEnhance": {
+ "Enable": "true",
+ "Contrast": "10",
+ "Correction": "10",
+ "Saturation": "10"
+ },
+ "MsSharpen": {
+ "Enable": "true",
+ "SharpenLevel": "1"
+ }
+ },
+ 'Output': {
+ 'Bucket': bucket_name,
+ 'Region': region,
+ 'Object': 'video-process.mp4'
+ },
+ # 'TemplateId': 't02db40900dc1c43ad9bdbd8acec6075c5',
+ 'TranscodeTemplateId': 't04e1ab86554984f1aa17c062fbf6c007c'
+ }
+ }
+ response = client.ci_create_media_jobs(
+ Bucket=bucket_name,
+ Jobs=body,
+ Lst={},
+ ContentType='application/xml'
+ )
+ print(response)
+ return response
+
+
+def ci_create_media_video_montage_jobs():
+ # 创建精彩集锦任务
+ body = {
+ 'Input': {
+ 'Object': 'demo.mp4'
+ },
+ 'QueueId': 'p5135bxxxxxxxxxxxxxxxxxxxc8bf047454',
+ 'Tag': 'VideoMontage',
+ 'Operation': {
+ "VideoMontage": {
+ "Container": {
+ "Format": "mp4"
+ },
+ "Video": {
+ "Codec": "H.264",
+ "Bitrate": "1000",
+ "Width": "1280",
+ "Height": "1280"
+ },
+ "Audio": {
+ "Codec": "aac",
+ "Samplerate": "44100",
+ "Bitrate": "128",
+ "Channels": "4"
+ },
+ "AudioMix": {
+ "AudioSource": "https://demo-xxxxxxxxxxxx.cos.ap-chongqing.myqcloud.com/1.mp4",
+ "MixMode": "Once",
+ "Replace": "true"
+ },
+ "Duration": "1"
+ },
+ 'Output': {
+ 'Bucket': bucket_name,
+ 'Region': region,
+ 'Object': 'video-montage.mp4'
+ },
+ # 'TemplateId': 't02db40900dc1c43ad9bdbd8acec6075c5',
+ }
+ }
+ response = client.ci_create_media_jobs(
+ Bucket=bucket_name,
+ Jobs=body,
+ Lst={},
+ ContentType='application/xml'
+ )
+ print(response)
+ return response
+
+
+def ci_create_media_voice_separate_jobs():
+ # 创建人声分离任务
+ body = {
+ 'Input': {
+ 'Object': 'demo.mp4'
+ },
+ 'QueueId': 'p5135bxxxxxxxxxxxxxxxxxxxc8bf047454',
+ 'Tag': 'VoiceSeparate',
+ 'Operation': {
+ "VoiceSeparate": {
+ "AudioMode": "IsAudio",
+ "AudioConfig": {
+ "Codec": "mp3",
+ "Samplerate": "44100",
+ "Bitrate": "12",
+ "Channels": "2"
+ }
+ },
+ 'Output': {
+ 'Bucket': bucket_name,
+ 'Region': region,
+ 'Object': 'voice-separate.mp3',
+ 'AuObject': 'voice-separate-audio.mp3'
+ },
+ # 'TemplateId': 't02db40900dc1c43ad9bdbd8acec6075c5',
+ }
+ }
+ response = client.ci_create_media_jobs(
+ Bucket=bucket_name,
+ Jobs=body,
+ Lst={},
+ ContentType='application/xml'
+ )
+ print(response)
+ return response
+
+
+def ci_create_media_sdr2hdr_jobs():
+ # 创建sdr2hdr任务
+ body = {
+ 'Input': {
+ 'Object': 'demo.mp4'
+ },
+ 'QueueId': 'p5135bxxxxxxxxxxxxxxxxxxxc8bf047454',
+ 'Tag': 'SDRtoHDR',
+ 'Operation': {
+ "SDRtoHDR": {
+ "HdrMode": "HLG",
+ },
+ 'Output': {
+ 'Bucket': bucket_name,
+ 'Region': region,
+ 'Object': 'sdr2hdr.mp4'
+ },
+ 'TranscodeTemplateId': 't04e1ab86554984f1aa17c062fbf6c007c'
+ }
+ }
+ response = client.ci_create_media_jobs(
+ Bucket=bucket_name,
+ Jobs=body,
+ Lst={},
+ ContentType='application/xml'
+ )
+ print(response)
+ return response
+
+
+def ci_create_media_digital_watermark_jobs():
+ # 创建嵌入数字水印任务
+ body = {
+ 'Input': {
+ 'Object': 'demo.mp4'
+ },
+ 'QueueId': 'p5135bxxxxxxxxxxxxxxxxxxxc8bf047454',
+ 'Tag': 'DigitalWatermark',
+ 'Operation': {
+ "DigitalWatermark": {
+ "Type": "Text",
+ "Message": "123456789ab",
+ "Version": "V1"
+ },
+ 'Output': {
+ 'Bucket': bucket_name,
+ 'Region': region,
+ 'Object': 'digital.mp4'
+ },
+ }
+ }
+ response = client.ci_create_media_jobs(
+ Bucket=bucket_name,
+ Jobs=body,
+ Lst={},
+ ContentType='application/xml'
+ )
+ print(response)
+ return response
+
+
+def ci_create_media_extract_digital_watermark_jobs():
+ # 创建提取数字水印任务
+ body = {
+ 'Input': {
+ 'Object': 'digital.mp4'
+ },
+ 'QueueId': 'p5135bxxxxxxxxxxxxxxxxxxxc8bf047454',
+ 'Tag': 'ExtractDigitalWatermark',
+ 'Operation': {
+ "ExtractDigitalWatermark": {
+ "Type": "Text",
+ "Version": "V1"
+ },
+ }
+ }
+ response = client.ci_create_media_jobs(
+ Bucket=bucket_name,
+ Jobs=body,
+ Lst={},
+ ContentType='application/xml'
+ )
+ print(response)
+ return response
+
+
+def ci_create_media_super_resolution_jobs():
+ # 创建超分任务
+ body = {
+ 'Input':{
+ 'Object': 'demo.mp4'
+ },
+ 'QueueId': 'p5135bxxxxxxxxxxxxxxxxxxxc8bf047454',
+ 'Tag': 'SuperResolution',
+ 'Operation': {
+ "SuperResolution": {
+ "Resolution": "sdtohd",
+ "EnableScaleUp": "true"
+ },
+ 'TranscodeTemplateId': 't04e1ab86554984f1aa17c062fbf6c007c',
+ 'Output': {
+ 'Bucket': bucket_name,
+ 'Region': region,
+ 'Object': 'super.mp4'
+ },
+ },
+ }
+ response = client.ci_create_media_jobs(
+ Bucket=bucket_name,
+ Jobs=body,
+ Lst={},
+ ContentType='application/xml'
+ )
+ print(response)
+ return response
+
+
+def ci_create_media_video_tag_jobs():
+ # 创建视频标签任务
+ body = {
+ 'Input':{
+ 'Object': 'demo.mp4'
+ },
+ 'QueueId': 'p5135bxxxxxxxxxxxxxxxxxxxc8bf047454',
+ 'Tag': 'VideoTag',
+ 'Operation': {
+ "VideoTag": {
+ "Scenario": "Stream"
+ },
+ },
+ }
+ response = client.ci_create_media_jobs(
+ Bucket=bucket_name,
+ Jobs=body,
+ Lst={},
+ ContentType='application/xml'
+ )
+ print(response)
+ return response
+
+
+def ci_create_media_segment_jobs():
+ # 创建转封装任务
+ body = {
+ 'Input': {
+ 'Object': 'demo.mp4'
+ },
+ 'QueueId': 'p5135bxxxxxxxxxxxxxxxxxxxc8bf047454',
+ 'Tag': 'Segment',
+ 'Operation': {
+ "Segment": {
+ "Format": "mp4",
+ "Duration": "5",
+ },
+ 'Output': {
+ 'Bucket': bucket_name,
+ 'Region': region,
+ 'Object': 'segment-${Number}.mp4'
+ },
+ },
+ }
+ response = client.ci_create_media_jobs(
+ Bucket=bucket_name,
+ Jobs=body,
+ Lst={},
+ ContentType='application/xml'
+ )
+ print(response)
+ return response
+
+
+def ci_create_multi_jobs():
+ # 创建多任务
+ body = {
+ 'Input': {
+ 'Object': '117374C.mp4'
+ },
+ 'QueueId': 'p5135bxxxxxxxxxxxxxxxxxxxc8bf047454',
+ 'Operation': [
+ {
+ 'Tag': 'Segment',
+ "Segment": {
+ "Format": "mp4",
+ "Duration": "50",
+ },
+ 'Output': {
+ 'Bucket': bucket_name,
+ 'Region': region,
+ 'Object': 'multi-segment-${Number}.mp4'
+ },
+ },
+ {
+ 'Tag': 'SDRtoHDR',
+ "SDRtoHDR": {
+ "HdrMode": "HLG",
+ },
+ 'Output': {
+ 'Bucket': bucket_name,
+ 'Region': region,
+ 'Object': 'multi-sdr2hdr.mp4'
+ },
+ 'TranscodeTemplateId': 't04e1ab86554984f1aa17c062fbf6c007c'
+ }
+ ],
+ }
+ lst = ['', '']
+ response = client.ci_create_media_jobs(
+ Bucket=bucket_name,
+ Jobs=body,
+ Lst=lst,
+ ContentType='application/xml'
+ )
+ print(response)
+ return response
+
+
+def ci_create_get_media_info_jobs():
+ # 创建获取媒体信息任务
+ body = {
+ 'Input': {
+ 'Object': 'demo.mp4'
+ },
+ 'QueueId': 'p5135bxxxxxxxxxxxxxxxxxxxc8bf047454',
+ 'Tag': 'MediaInfo',
+ }
+ response = client.ci_create_media_jobs(
+ Bucket=bucket_name,
+ Jobs=body,
+ Lst={},
+ ContentType='application/xml'
+ )
+ print(response)
+ return response
+
+
+def ci_create_media_pic_jobs():
+ # 创建图片处理任务
+ body = {
+ 'Input': {
+ 'Object': '1.png'
+ },
+ 'QueueId': 'peb83bdbxxxxxxxxxxxxxxxxxxxa21c7d68',
+ 'Tag': 'PicProcess',
+ 'Operation': {
+ "PicProcess": {
+ "IsPicInfo": "true",
+ "ProcessRule": "imageMogr2/rotate/90",
+ },
+ 'Output': {
+ 'Bucket': bucket_name,
+ 'Region': region,
+ 'Object': 'pic-process-result.png'
+ },
+ }
+ }
+ response = client.ci_create_media_pic_jobs(
+ Bucket=bucket_name,
+ Jobs=body,
+ Lst={},
+ ContentType='application/xml'
+ )
+ print(response)
+ return response
def ci_list_media_transcode_jobs():
- # 转码任务
+ # 转码任务列表
response = client.ci_list_media_jobs(
Bucket=bucket_name,
- QueueId='pe943803693bd42d1a3105804ddaee525',
- Tag='Transcode',
- ContentType='application/xml'
+ QueueId='p5135bxxxxxxxxxxxxxxxxxxxc8bf047454',
+ Tag='DigitalWatermark',
+ ContentType='application/xml',
+ StartCreationTime='2022-05-27T00:00:00+0800',
+ EndCreationTime='2022-05-31T00:00:00+0800',
+ States='Success'
)
print(response)
- return response
+ return response
def ci_get_media_transcode_jobs():
- # 转码任务
+ # 转码任务详情
response = client.ci_get_media_jobs(
Bucket=bucket_name,
- JobIDs='j3feb7ccc28fc11eca50b6f68c211dc6c,jb83bcc5a28fb11ecae48a1f29371c5f8',
+ JobIDs='j318302b8e0bc11ec97444b29c7b914d9',
ContentType='application/xml'
)
print(response)
- return response
+ return response
+
+
+def ci_list_media_pic_jobs():
+ # 图片处理任务列表
+ response = client.ci_list_media_pic_jobs(
+ Bucket=bucket_name,
+ QueueId='peb83bdbxxxxxxxxxxxxxxxxxxxa21c7d68',
+ Tag='PicProcess',
+ ContentType='application/xml',
+ StartCreationTime='2022-05-30T23:30:00+0800',
+ EndCreationTime='2022-05-31T01:00:00+0800',
+ States='Success'
+ )
+ print(response)
+ return response
+
+
+def ci_get_media_pic_jobs():
+ # 图片处理任务详情
+ response = client.ci_get_media_jobs(
+ Bucket=bucket_name,
+ JobIDs='c01742xxxxxxxxxxxxxxxxxx7438e39',
+ ContentType='application/xml'
+ )
+ print(response)
+ return response
def get_media_info():
@@ -228,13 +1003,38 @@ def ci_list_workflowexecution():
if __name__ == "__main__":
- #ci_get_media_queue()
- #ci_get_media_transcode_jobs()
- #ci_create_media_transcode_jobs()
+ ci_get_media_queue()
+ # ci_get_media_transcode_jobs()
+ # ci_create_media_transcode_jobs()
# get_media_info()
# get_snapshot()
- #ci_trigger_workflow()
- #ci_list_workflowexecution()
+ # ci_trigger_workflow()
+ # ci_list_workflowexecution()
# ci_get_workflowexecution()
# ci_get_media_bucket()
- get_pm3u8()
+ # get_pm3u8()
+ # ci_create_media_snapshot_jobs()
+ # ci_create_media_animation_jobs()
+ # ci_create_media_smart_cover_jobs()
+ # ci_create_media_video_process_jobs()
+ # ci_create_media_video_montage_jobs()
+ # ci_create_media_voice_separate_jobs()
+ # ci_create_media_sdr2hdr_jobs()
+ # ci_create_media_super_resolution_jobs()
+ # ci_create_media_concat_jobs()
+ # ci_create_media_digital_watermark_jobs()
+ # ci_create_media_extract_digital_watermark_jobs()
+ # ci_create_media_video_tag_jobs()
+ # ci_create_media_segment_jobs()
+ # ci_create_multi_jobs()
+ # ci_create_media_pic_jobs()
+ # ci_get_media_pic_jobs()
+ # ci_create_get_media_info_jobs()
+ # ci_put_media_queue()
+ # ci_create_media_transcode_with_watermark_jobs()
+ # ci_create_media_transcode_with_digital_watermark_jobs()
+ # ci_create_media_hls_transcode_jobs()
+ # ci_list_media_transcode_jobs()
+ # ci_list_media_pic_jobs()
+ # ci_get_media_pic_queue()
+ # ci_put_media_pic_queue()
diff --git a/qcloud_cos/cos_client.py b/qcloud_cos/cos_client.py
index 91e9c835..953c3ab7 100644
--- a/qcloud_cos/cos_client.py
+++ b/qcloud_cos/cos_client.py
@@ -5780,10 +5780,15 @@ def ci_get_media_bucket(self, Regions='', BucketName='', BucketNames='', PageNum
format_dict(data, ['MediaBucketList'])
return data
- def ci_get_media_queue(self, Bucket, **kwargs):
+ def ci_get_media_queue(self, Bucket, State='All', QueueIds='', PageNumber='', PageSize='', UrlPath='/queue', **kwargs):
"""查询媒体处理队列接口 https://cloud.tencent.com/document/product/436/54045
:param Bucket(string): 存储桶名称.
+ :param QueueIds(string): 队列 ID,以“,”符号分割字符串.
+ :param State(string): 队列状态
+ :param PageNumber(string): 第几页
+ :param PageSize(string): 每页个数
+ :param UrlPath(string): 请求URL路径,无需主动设置
:param kwargs(dict): 设置请求的headers.
:return(dict): 查询成功返回的结果,dict类型.
@@ -5809,8 +5814,15 @@ def ci_get_media_queue(self, Bucket, **kwargs):
params = format_values(params)
- path = "/queue"
+ path = UrlPath
url = self._conf.uri(bucket=Bucket, path=path, endpoint=self._conf._endpoint_ci)
+ url = u"{url}?{queueIds}&{state}&{pageNumber}&{pageSize}".format(
+ url=to_unicode(url),
+ queueIds=to_unicode('queueIds='+QueueIds),
+ state=to_unicode('state='+State),
+ pageNumber=to_unicode('pageNumber='+PageNumber),
+ pageSize=to_unicode('pageSize='+PageSize),
+ )
logger.info("get_media_queue result, url=:{url} ,headers=:{headers}, params=:{params}".format(
url=url,
headers=headers,
@@ -5828,6 +5840,110 @@ def ci_get_media_queue(self, Bucket, **kwargs):
format_dict(data, ['QueueList'])
return data
+ def ci_update_media_queue(self, Bucket, QueueId, Request={}, UrlPath="/queue/", **kwargs):
+ """ 更新媒体处理队列接口 https://cloud.tencent.com/document/product/436/54046
+
+ :param Bucket(string): 存储桶名称.
+ :param QueueId(string): 队列ID.
+ :param Request(dict): 更新队列配置请求体.
+ :param UrlPath(string): 请求URL路径,无需主动设置
+ :param kwargs(dict): 设置请求的headers.
+ :return(dict): 查询成功返回的结果,dict类型.
+
+ .. code-block:: python
+
+ config = CosConfig(Region=region, SecretId=secret_id, SecretKey=secret_key, Token=token) # 获取配置对象
+ client = CosS3Client(config)
+ # 创建任务接口
+ response = client.ci_update_media_queue(
+ Bucket='bucket',
+ QueueId='',
+ Request={},
+ )
+ print response
+ """
+ headers = mapped(kwargs)
+ final_headers = {}
+ params = {}
+ for key in headers:
+ if key.startswith("response"):
+ params[key] = headers[key]
+ else:
+ final_headers[key] = headers[key]
+ headers = final_headers
+
+ params = format_values(params)
+ xml_config = format_xml(data=Request, root='Request')
+ path = UrlPath + QueueId
+ url = self._conf.uri(bucket=Bucket, path=path, endpoint=self._conf._endpoint_ci)
+ logger.info("update_media_queue result, url=:{url} ,headers=:{headers}, params=:{params}, xml_config=:{xml_config}".format(
+ url=url,
+ headers=headers,
+ params=params,
+ xml_config=xml_config))
+ rt = self.send_request(
+ method='PUT',
+ url=url,
+ bucket=Bucket,
+ data=xml_config,
+ auth=CosS3Auth(self._conf, path, params=params),
+ params=params,
+ headers=headers)
+
+ data = xml_to_dict(rt.content)
+ # 单个元素时将dict转为list
+ format_dict(data, ['Queue'])
+ return data
+
+ def ci_update_media_pic_queue(self, Bucket, QueueId, Request={}, **kwargs):
+ """ 更新图片处理队列接口
+
+ :param Bucket(string): 存储桶名称.
+ :param QueueId(string): 队列ID.
+ :param Request(dict): 更新队列配置请求体.
+ :param kwargs(dict): 设置请求的headers.
+ :return(dict): 查询成功返回的结果,dict类型.
+
+ .. code-block:: python
+
+ config = CosConfig(Region=region, SecretId=secret_id, SecretKey=secret_key, Token=token) # 获取配置对象
+ client = CosS3Client(config)
+ # 创建任务接口
+ response = client.ci_update_media_pic_queue(
+ Bucket='bucket',
+ QueueId='',
+ Request={},
+ )
+ print response
+ """
+ return self.ci_update_media_queue(Bucket=Bucket, QueueId=QueueId,
+ Request=Request, UrlPath="/picqueue/", **kwargs)
+
+ def ci_get_media_pic_queue(self, Bucket, State='All', QueueIds='', PageNumber='', PageSize='', **kwargs):
+ """查询图片处理队列接口
+
+ :param Bucket(string): 存储桶名称.
+ :param QueueIds(string): 队列 ID,以“,”符号分割字符串.
+ :param State(string): 队列状态
+ :param PageNumber(string): 第几页
+ :param PageSize(string): 每页个数
+ :param kwargs(dict): 设置请求的headers.
+ :return(dict): 查询成功返回的结果,dict类型.
+
+ .. code-block:: python
+
+ config = CosConfig(Region=region, SecretId=secret_id, SecretKey=secret_key, Token=token) # 获取配置对象
+ client = CosS3Client(config)
+ # 查询媒体处理队列接口
+ response = client.ci_get_media_pic_queue(
+ Bucket='bucket'
+ )
+ print response
+ """
+ return self.ci_get_media_queue(Bucket=Bucket, State=State, QueueIds=QueueIds,
+ PageNumber=PageNumber, PageSize=PageSize,
+ UrlPath="/picqueue", **kwargs)
+
def ci_create_media_jobs(self, Bucket, Jobs={}, Lst={}, **kwargs):
""" 创建任务接口 https://cloud.tencent.com/document/product/436/54013
@@ -5882,6 +5998,60 @@ def ci_create_media_jobs(self, Bucket, Jobs={}, Lst={}, **kwargs):
format_dict(data, ['JobsDetail'])
return data
+ def ci_create_media_pic_jobs(self, Bucket, Jobs={}, Lst={}, **kwargs):
+ """ 创建图片处理任务接口 https://cloud.tencent.com/document/product/436/67194
+
+ :param Bucket(string): 存储桶名称.
+ :param Jobs(dict): 创建任务的配置.
+ :param Lst(dict): 创建任务dict转xml时去除Key数组.
+ :param kwargs(dict): 设置请求的headers.
+ :return(dict): 查询成功返回的结果,dict类型.
+
+ .. code-block:: python
+
+ config = CosConfig(Region=region, SecretId=secret_id, SecretKey=secret_key, Token=token) # 获取配置对象
+ client = CosS3Client(config)
+ # 创建任务接口
+ response = client.ci_create_media_pic_jobs(
+ Bucket='bucket'
+ Jobs={},
+ Lst={}
+ )
+ print response
+ """
+ headers = mapped(kwargs)
+ final_headers = {}
+ params = {}
+ for key in headers:
+ if key.startswith("response"):
+ params[key] = headers[key]
+ else:
+ final_headers[key] = headers[key]
+ headers = final_headers
+
+ params = format_values(params)
+ xml_config = format_xml(data=Jobs, root='Request', lst=Lst)
+ path = "/pic_jobs"
+ url = self._conf.uri(bucket=Bucket, path=path, endpoint=self._conf._endpoint_ci)
+ logger.info("create_media_pic_jobs result, url=:{url} ,headers=:{headers}, params=:{params}, xml_config=:{xml_config}".format(
+ url=url,
+ headers=headers,
+ params=params,
+ xml_config=xml_config))
+ rt = self.send_request(
+ method='POST',
+ url=url,
+ bucket=Bucket,
+ data=xml_config,
+ auth=CosS3Auth(self._conf, path, params=params),
+ params=params,
+ headers=headers)
+
+ data = xml_to_dict(rt.content)
+ # 单个元素时将dict转为list
+ format_dict(data, ['JobsDetail'])
+ return data
+
def ci_get_media_jobs(self, Bucket, JobIDs, **kwargs):
""" 查询任务接口 https://cloud.tencent.com/document/product/436/54010
@@ -5934,7 +6104,92 @@ def ci_get_media_jobs(self, Bucket, JobIDs, **kwargs):
format_dict(data, ['JobsDetail'])
return data
- def ci_list_media_jobs(self, Bucket, QueueId, Tag, StartCreationTime=None, EndCreationTime=None, OrderByTime='Desc', States='All', Size=10, NextToken='', **kwargs):
+ def ci_get_media_pic_jobs(self, Bucket, JobIDs, **kwargs):
+ """ 查询图片处理任务接口 https://cloud.tencent.com/document/product/436/67197
+
+ :param Bucket(string): 存储桶名称.
+ :param JobIDs(string): 任务ID,以,分割多个任务ID.
+ :param kwargs(dict): 设置请求的headers.
+ :return(dict): 查询成功返回的结果,dict类型.
+
+ .. code-block:: python
+
+ config = CosConfig(Region=region, SecretId=secret_id, SecretKey=secret_key, Token=token) # 获取配置对象
+ client = CosS3Client(config)
+ # 创建任务接口
+ response = client.ci_get_media_pic_jobs(
+ Bucket='bucket'
+ JobIDs={}
+ )
+ print response
+ """
+ headers = mapped(kwargs)
+ final_headers = {}
+ params = {}
+ for key in headers:
+ if key.startswith("response"):
+ params[key] = headers[key]
+ else:
+ final_headers[key] = headers[key]
+ headers = final_headers
+
+ params = format_values(params)
+ path = "/pic_jobs/" + JobIDs
+ url = self._conf.uri(bucket=Bucket, path=path, endpoint=self._conf._endpoint_ci)
+ logger.info("get_media_jobs result, url=:{url} ,headers=:{headers}, params=:{params}".format(
+ url=url,
+ headers=headers,
+ params=params))
+ rt = self.send_request(
+ method='GET',
+ url=url,
+ bucket=Bucket,
+ auth=CosS3Auth(self._conf, path, params=params),
+ params=params,
+ headers=headers)
+ logger.debug("ci_get_media_pic_jobs result, url=:{url} ,content=:{content}".format(
+ url=url,
+ content=rt.content))
+
+ data = xml_to_dict(rt.content)
+ # 单个元素时将dict转为list
+ format_dict(data, ['JobsDetail'])
+ return data
+
+ def ci_list_media_pic_jobs(self, Bucket, QueueId, Tag, StartCreationTime=None, EndCreationTime=None, OrderByTime='Desc', States='All', Size=10, NextToken='', **kwargs):
+ """ 查询图片处理任务列表接口 https://cloud.tencent.com/document/product/436/67198
+
+ :param Bucket(string): 存储桶名称.
+ :param QueueId(string): 队列ID.
+ :param Tag(string): 任务类型.
+ :param StartCreationTime(string): 开始时间.
+ :param EndCreationTime(string): 结束时间.
+ :param OrderByTime(string): 排序方式.
+ :param States(string): 任务状态.
+ :param Size(string): 任务个数.
+ :param NextToken(string): 请求的上下文,用于翻页.
+ :param kwargs(dict): 设置请求的headers.
+ :return(dict): 查询成功返回的结果,dict类型.
+
+ .. code-block:: python
+
+ config = CosConfig(Region=region, SecretId=secret_id, SecretKey=secret_key, Token=token) # 获取配置对象
+ client = CosS3Client(config)
+ # 创建任务接口
+ response = client.ci_get_media_pic_jobs(
+ Bucket='bucket'
+ QueueId='',
+ Tag='PicProcess'
+ )
+ print response
+ """
+ return self.ci_list_media_jobs(Bucket=Bucket, QueueId=QueueId, Tag=Tag,
+ StartCreationTime=StartCreationTime,
+ EndCreationTime=EndCreationTime,
+ OrderByTime=OrderByTime, States=States,
+ Size=Size, NextToken=NextToken, Path='/pic_jobs', **kwargs)
+
+ def ci_list_media_jobs(self, Bucket, QueueId, Tag, StartCreationTime=None, EndCreationTime=None, OrderByTime='Desc', States='All', Size=10, NextToken='', Path='/jobs', **kwargs):
""" 查询任务接口 https://cloud.tencent.com/document/product/436/54011
:param Bucket(string): 存储桶名称.
@@ -5972,7 +6227,7 @@ def ci_list_media_jobs(self, Bucket, QueueId, Tag, StartCreationTime=None, EndCr
headers = final_headers
params = format_values(params)
- path = "/jobs"
+ path = Path
url = self._conf.uri(bucket=Bucket, path=path, endpoint=self._conf._endpoint_ci)
url = u"{url}?{QueueId}&{Tag}&{OrderByTime}&{States}&{Size}&{NextToken}".format(
url=to_unicode(url),
@@ -5984,9 +6239,11 @@ def ci_list_media_jobs(self, Bucket, QueueId, Tag, StartCreationTime=None, EndCr
NextToken=to_unicode('nextToken='+NextToken)
)
if StartCreationTime is not None:
- url = u"{url}&{StartCreationTime}".format(StartCreationTime=to_unicode('startCreationTime='+StartCreationTime))
+ url = u"{url}&{StartCreationTime}".format(url=url,
+ StartCreationTime=quote(to_bytes(to_unicode('startCreationTime='+StartCreationTime)), b'/-_.~='))
if EndCreationTime is not None:
- url = u"{url}&{EndCreationTime}".format(EndCreationTime=to_unicode('endCreationTime='+EndCreationTime))
+ url = u"{url}&{EndCreationTime}".format(url=url,
+ EndCreationTime=quote(to_bytes(to_unicode('endCreationTime='+EndCreationTime)), b'/-_.~='))
logger.info("list_media_jobs result, url=:{url} ,headers=:{headers}, params=:{params}".format(
url=url,
headers=headers,
diff --git a/ut/test.py b/ut/test.py
index 65d2bb1b..a3d07822 100644
--- a/ut/test.py
+++ b/ut/test.py
@@ -1628,20 +1628,35 @@ def test_ci_get_media_queue():
# 查询媒体队列信息
response = client.ci_get_media_queue(
- Bucket=ci_bucket_name
+ Bucket=ci_bucket_name,
+ State="Active",
)
print(response)
assert (response['QueueList'])
+def test_ci_get_media_pic_queue():
+ if TEST_CI != 'true':
+ return
+
+ # 查询图片处理队列信息
+ response = client.ci_get_media_pic_queue(
+ Bucket=ci_bucket_name,
+ State="Active",
+ )
+ print(response)
+ assert (response['QueueList'])
+
+
def test_ci_create_media_transcode_watermark_jobs():
if TEST_CI != 'true':
return
# 创建转码任务
response = client.ci_get_media_queue(
- Bucket=ci_bucket_name
- )
+ Bucket=ci_bucket_name,
+ State="Active",
+ )
QueueId = response['QueueList'][0]['QueueId']
body = {
@@ -1717,8 +1732,9 @@ def test_ci_create_media_transcode_jobs():
# 创建转码任务
response = client.ci_get_media_queue(
- Bucket=ci_bucket_name
- )
+ Bucket=ci_bucket_name,
+ State="Active",
+ )
QueueId = response['QueueList'][0]['QueueId']
body = {
'Input': {
@@ -1745,14 +1761,75 @@ def test_ci_create_media_transcode_jobs():
assert (response['JobsDetail'])
+def test_ci_create_media_pic_jobs():
+ if TEST_CI != 'true':
+ return
+
+ response = client.ci_get_media_pic_queue(
+ Bucket=ci_bucket_name,
+ State="Active",
+ )
+ QueueId = response['QueueList'][0]['QueueId']
+ # 创建图片处理任务
+ body = {
+ 'Input': {
+ 'Object': '1.png'
+ },
+ 'QueueId': QueueId,
+ 'Tag': 'PicProcess',
+ 'Operation': {
+ "PicProcess": {
+ "IsPicInfo": "true",
+ "ProcessRule": "imageMogr2/rotate/90",
+ },
+ 'Output': {
+ 'Bucket': ci_bucket_name,
+ 'Region': ci_region,
+ 'Object': 'pic-process-result.png'
+ },
+ }
+ }
+ response = client.ci_create_media_pic_jobs(
+ Bucket=ci_bucket_name,
+ Jobs=body,
+ Lst={},
+ ContentType='application/xml'
+ )
+ print(response)
+ assert (response['JobsDetail'])
+
+
+def test_ci_list_media_pic_jobs():
+ if TEST_CI != 'true':
+ return
+
+ # 图片处理任务列表
+ response = client.ci_get_media_pic_queue(
+ Bucket=ci_bucket_name,
+ State="Active",
+ )
+ QueueId = response['QueueList'][0]['QueueId']
+
+ response = client.ci_list_media_pic_jobs(
+ Bucket=ci_bucket_name,
+ QueueId=QueueId,
+ Tag='PicProcess',
+ ContentType='application/xml',
+ States='Success'
+ )
+ print(response)
+ assert (response['JobsDetail'])
+
+
def test_ci_list_media_transcode_jobs():
if TEST_CI != 'true':
return
# 转码任务
response = client.ci_get_media_queue(
- Bucket=ci_bucket_name
- )
+ Bucket=ci_bucket_name,
+ State="Active",
+ )
QueueId = response['QueueList'][0]['QueueId']
response = client.ci_list_media_jobs(
Bucket=ci_bucket_name,
@@ -2031,5 +2108,8 @@ def test_sse_c_file():
test_get_pm3u8()
test_ci_get_media_bucket()
test_sse_c_file()
+ test_ci_list_media_pic_jobs()
+ test_ci_create_media_pic_jobs()
+ test_ci_get_media_pic_queue()
"""
tearDown()