Skip to content

Commit 5eda21d

Browse files
authored
Detect text fix (#222)
- 视频截图 - 媒体拼接 - 媒体处理 - 内容审核fix - 文本结果格式fix
1 parent d4f5553 commit 5eda21d

11 files changed

+673
-8
lines changed

sample/createMediaConcatJobs.php

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<?php
2+
3+
require dirname(__FILE__) . '/../vendor/autoload.php';
4+
5+
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
6+
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
7+
$region = "ap-beijing"; //设置一个默认的存储桶地域
8+
$cosClient = new Qcloud\Cos\Client(
9+
array(
10+
'region' => $region,
11+
'schema' => 'https', //协议头部,默认为http
12+
'credentials'=> array(
13+
'secretId' => $secretId ,
14+
'secretKey' => $secretKey)));
15+
try {
16+
// start --------------- 使用模版 ----------------- //
17+
$result = $cosClient->createMediaConcatJobs(array(
18+
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
19+
'Tag' => 'Concat',
20+
'QueueId' => 'asdadadfafsdkjhfjghdfjg',
21+
'CallBack' => 'https://example.com/callback',
22+
'Input' => array(
23+
'Object' => 'video01.mp4'
24+
),
25+
'Operation' => array(
26+
'TemplateId' => 'asdfafiahfiushdfisdhfuis',
27+
'Output' => array(
28+
'Region' => $region,
29+
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
30+
'Object' => 'concat-video02.mp4',
31+
),
32+
),
33+
));
34+
// 请求成功
35+
print_r($result);
36+
// end --------------- 使用模版 ----------------- //
37+
38+
// start --------------- 自定义参数 ----------------- //
39+
$result = $cosClient->createMediaConcatJobs(array(
40+
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
41+
'Tag' => 'Concat',
42+
'QueueId' => 'asdadadfafsdkjhfjghdfjg',
43+
'CallBack' => 'https://example.com/callback',
44+
'Input' => array(
45+
'Object' => 'video01.mp4'
46+
),
47+
'Operation' => array(
48+
'Output' => array(
49+
'Region' => $region,
50+
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
51+
'Object' => 'concat-video03.mp4',
52+
),
53+
'ConcatTemplate' => array(
54+
'ConcatFragments' => array(
55+
array(
56+
'Url' => 'https://example.com/video01.mp4',
57+
'Mode' => 'Start',
58+
// 'StartTime' => '0',
59+
// 'EndTime' => '7',
60+
),
61+
array(
62+
'Url' => 'https://example.com/video02.mp4',
63+
'Mode' => 'Start',
64+
// 'StartTime' => '0',
65+
// 'EndTime' => '10',
66+
),
67+
// ... repeated
68+
),
69+
'Index' => 1,
70+
'Container' => array(
71+
'Format' => 'mp4'
72+
),
73+
'Audio' => array(
74+
'Codec' => 'mp3',
75+
'Samplerate' => '',
76+
'Bitrate' => '',
77+
'Channels' => '',
78+
),
79+
'Video' => array(
80+
'Codec' => 'H.264',
81+
'Bitrate' => '1000',
82+
'Width' => '1280',
83+
'Height' => '',
84+
'Fps' => '30',
85+
),
86+
),
87+
),
88+
));
89+
// 请求成功
90+
print_r($result);
91+
// end --------------- 自定义参数 ----------------- //
92+
} catch (\Exception $e) {
93+
// 请求失败
94+
echo($e);
95+
}
96+

sample/createMediaSnapshotJobs.php

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?php
2+
3+
require dirname(__FILE__) . '/../vendor/autoload.php';
4+
5+
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
6+
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
7+
$region = "ap-beijing"; //设置一个默认的存储桶地域
8+
$cosClient = new Qcloud\Cos\Client(
9+
array(
10+
'region' => $region,
11+
'schema' => 'https', //协议头部,默认为http
12+
'credentials'=> array(
13+
'secretId' => $secretId ,
14+
'secretKey' => $secretKey)));
15+
try {
16+
// start --------------- 使用模版 ----------------- //
17+
$result = $cosClient->createMediaSnapshotJobs(array(
18+
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
19+
'Tag' => 'Snapshot',
20+
'QueueId' => 'asdadadfafsdkjhfjghdfjg',
21+
'CallBack' => 'https://example.com/callback',
22+
'Input' => array(
23+
'Object' => 'video01.mp4'
24+
),
25+
'Operation' => array(
26+
'TemplateId' => 'asdfafiahfiushdfisdhfuis',
27+
'Output' => array(
28+
'Region' => $region,
29+
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
30+
'Object' => 'snapshot-${Number}.jpg',
31+
),
32+
),
33+
));
34+
// 请求成功
35+
print_r($result);
36+
// end --------------- 使用模版 ----------------- //
37+
38+
39+
// start --------------- 自定义参数 ----------------- //
40+
$result = $cosClient->createMediaSnapshotJobs(array(
41+
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
42+
'Tag' => 'Snapshot',
43+
'QueueId' => 'asdadadfafsdkjhfjghdfjg',
44+
'CallBack' => 'https://example.com/callback',
45+
'Input' => array(
46+
'Object' => 'video01.mp4'
47+
),
48+
'Operation' => array(
49+
'Output' => array(
50+
'Region' => $region,
51+
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
52+
'Object' => 'snapshot-${Number}.jpg',
53+
),
54+
'Snapshot' => array(
55+
'Mode' => 'Average',
56+
'Start' => 3,
57+
'TimeInterval' => '',
58+
'Count' => 3,
59+
'Width' => '1280',
60+
'Height' => '',
61+
),
62+
),
63+
));
64+
// 请求成功
65+
print_r($result);
66+
// end --------------- 自定义参数 ----------------- //
67+
} catch (\Exception $e) {
68+
// 请求失败
69+
echo($e);
70+
}
71+

sample/createMediaTranscodeJobs.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
'secretId' => $secretId ,
1414
'secretKey' => $secretKey)));
1515
try {
16+
// start --------------- 使用模版 ----------------- //
1617
$result = $cosClient->createMediaTranscodeJobs(array(
1718
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
1819
'Tag' => 'Transcode',
@@ -32,6 +33,57 @@
3233
));
3334
// 请求成功
3435
print_r($result);
36+
// end --------------- 使用模版 ----------------- //
37+
38+
39+
// start --------------- 自定义参数 ----------------- //
40+
$result = $cosClient->createMediaTranscodeJobs(array(
41+
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
42+
'Tag' => 'Transcode',
43+
'QueueId' => 'asdadadfafsdkjhfjghdfjg',
44+
'CallBack' => 'https://example.com/callback',
45+
'Input' => array(
46+
'Object' => 'video01.mp4'
47+
),
48+
'Operation' => array(
49+
'Output' => array(
50+
'Region' => $region,
51+
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
52+
'Object' => 'video01.mkv',
53+
),
54+
'Transcode' => array(
55+
'Container' => array(
56+
'Format' => 'mp4'
57+
),
58+
'Video' => array(
59+
'Codec' => 'H.264',
60+
'Profile' => 'high',
61+
'Bitrate' => '1000',
62+
'Preset' => 'medium',
63+
'Width' => '1280',
64+
'Fps' => '30',
65+
),
66+
'Audio' => array(
67+
'Codec' => 'aac',
68+
'Samplerate' => '44100',
69+
'Bitrate' => '128',
70+
'Channels' => '4',
71+
),
72+
'TransConfig' => array(
73+
'AdjDarMethod' => 'scale',
74+
'IsCheckReso' => 'false',
75+
'ResoAdjMethod' => '1',
76+
),
77+
'TimeInterval' => array(
78+
'Start' => '0',
79+
'Duration' => '60',
80+
),
81+
),
82+
),
83+
));
84+
// 请求成功
85+
print_r($result);
86+
// end --------------- 自定义参数 ----------------- //
3587
} catch (\Exception $e) {
3688
// 请求失败
3789
echo($e);

sample/detectAudio.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
'secretId' => $secretId ,
1414
'secretKey' => $secretKey)));
1515
try {
16+
// start --------------- 桶文件审核 ----------------- //
1617
$result = $cosClient->detectAudio(array(
1718
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
1819
'Input' => array(
@@ -26,6 +27,23 @@
2627
));
2728
// 请求成功
2829
print_r($result);
30+
// end --------------- 桶文件审核 ----------------- //
31+
32+
// start --------------- 音频文件地址审核 ----------------- //
33+
$result = $cosClient->detectAudio(array(
34+
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
35+
'Input' => array(
36+
'Url' => 'https://example.com/test.mp3',
37+
),
38+
'Conf' => array(
39+
'DetectType' => 'Porn,Terrorism,Politics,Ads',
40+
'Callback' => 'https://example.com/callback',
41+
'BizType' => '',
42+
),
43+
));
44+
// 请求成功
45+
print_r($result);
46+
// end --------------- 音频文件地址审核 ----------------- //
2947
} catch (\Exception $e) {
3048
// 请求失败
3149
echo($e);

sample/detectDocument.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
'secretId' => $secretId ,
1414
'secretKey' => $secretKey)));
1515
try {
16-
$result = $cosClient->detectAudio(array(
16+
$result = $cosClient->detectDocument(array(
1717
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
1818
'Input' => array(
1919
'Url' => 'https://example.com/test01.docx',

sample/detectText.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
'secretKey' => $secretKey)));
1515
try {
1616
// start --------------- 文本内容审核 ----------------- //
17-
$content = '约炮';
17+
$content = '敏感词';
1818
$result = $cosClient->detectText(array(
1919
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
2020
'Input' => array(

src/Qcloud/Cos/Client.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@
9494
* @method object DetectText (array $arg)
9595
* @method object GetDetectTextResult (array $arg)
9696
* @method object CreateMediaTranscodeJobs (array $arg)
97+
* @method object CreateMediaSnapshotJobs (array $arg)
98+
* @method object CreateMediaConcatJobs (array $arg)
9799
* @method object DetectAudio (array $arg)
98100
* @method object GetDetectAudioResult (array $arg)
99101
* @method object DetectVideo (array $arg)

src/Qcloud/Cos/CommandToRequestTransformer.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ public function cosDomain2CiTransformer($command, $request) {
221221
$ciActions = array(
222222
'DetectText' => 1,
223223
'CreateMediaTranscodeJobs' => 1,
224+
'CreateMediaSnapshotJobs' => 1,
225+
'CreateMediaConcatJobs' => 1,
224226
'DetectAudio' => 1,
225227
'GetDetectAudioResult' => 1,
226228
'GetDetectTextResult' => 1,

0 commit comments

Comments
 (0)