Skip to content

Commit add395f

Browse files
authored
chore: upgrade video samples to new surface (#1884)
1 parent f97e761 commit add395f

11 files changed

+63
-50
lines changed

video/composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "google/video-sample",
33
"type": "project",
44
"require": {
5-
"google/cloud-videointelligence": "^1.5"
5+
"google/cloud-videointelligence": "^1.14"
66
},
77
"require-dev": {
88
"google/cloud-core": "^1.23"

video/quickstart.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
require __DIR__ . '/vendor/autoload.php';
2020

2121
# [START video_quickstart]
22-
use Google\Cloud\VideoIntelligence\V1\VideoIntelligenceServiceClient;
22+
use Google\Cloud\VideoIntelligence\V1\Client\VideoIntelligenceServiceClient;
23+
use Google\Cloud\VideoIntelligence\V1\AnnotateVideoRequest;
2324
use Google\Cloud\VideoIntelligence\V1\Feature;
2425

2526
# Instantiate a client.
@@ -31,7 +32,10 @@
3132
'inputUri' => 'gs://cloud-samples-data/video/cat.mp4',
3233
'features' => $features
3334
];
34-
$operation = $video->annotateVideo($options);
35+
$request = (new AnnotateVideoRequest())
36+
->setInputUri($options['inputUri'])
37+
->setFeatures($options['features']);
38+
$operation = $video->annotateVideo($request);
3539

3640
# Wait for the request to complete.
3741
$operation->pollUntilComplete();

video/src/analyze_explicit_content.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
namespace Google\Cloud\Samples\VideoIntelligence;
2626

2727
// [START video_analyze_explicit_content]
28-
use Google\Cloud\VideoIntelligence\V1\VideoIntelligenceServiceClient;
28+
use Google\Cloud\VideoIntelligence\V1\AnnotateVideoRequest;
29+
use Google\Cloud\VideoIntelligence\V1\Client\VideoIntelligenceServiceClient;
2930
use Google\Cloud\VideoIntelligence\V1\Feature;
3031
use Google\Cloud\VideoIntelligence\V1\Likelihood;
3132

@@ -39,10 +40,10 @@ function analyze_explicit_content(string $uri, int $pollingIntervalSeconds = 0)
3940

4041
# Execute a request.
4142
$features = [Feature::EXPLICIT_CONTENT_DETECTION];
42-
$operation = $video->annotateVideo([
43-
'inputUri' => $uri,
44-
'features' => $features,
45-
]);
43+
$request = (new AnnotateVideoRequest())
44+
->setInputUri($uri)
45+
->setFeatures($features);
46+
$operation = $video->annotateVideo($request);
4647

4748
# Wait for the request to complete.
4849
$operation->pollUntilComplete([

video/src/analyze_labels_file.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
namespace Google\Cloud\Samples\VideoIntelligence;
2020

2121
// [START video_analyze_labels]
22-
use Google\Cloud\VideoIntelligence\V1\VideoIntelligenceServiceClient;
22+
use Google\Cloud\VideoIntelligence\V1\AnnotateVideoRequest;
23+
use Google\Cloud\VideoIntelligence\V1\Client\VideoIntelligenceServiceClient;
2324
use Google\Cloud\VideoIntelligence\V1\Feature;
2425

2526
/**
@@ -36,10 +37,10 @@ function analyze_labels_file(string $path, int $pollingIntervalSeconds = 0)
3637

3738
# Execute a request.
3839
$features = [Feature::LABEL_DETECTION];
39-
$operation = $video->annotateVideo([
40-
'inputContent' => $inputContent,
41-
'features' => $features,
42-
]);
40+
$request = (new AnnotateVideoRequest())
41+
->setInputContent($inputContent)
42+
->setFeatures($features);
43+
$operation = $video->annotateVideo($request);
4344

4445
# Wait for the request to complete.
4546
$operation->pollUntilComplete([

video/src/analyze_labels_gcs.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
namespace Google\Cloud\Samples\VideoIntelligence;
2020

2121
// [START video_analyze_labels_gcs]
22-
use Google\Cloud\VideoIntelligence\V1\VideoIntelligenceServiceClient;
22+
use Google\Cloud\VideoIntelligence\V1\AnnotateVideoRequest;
23+
use Google\Cloud\VideoIntelligence\V1\Client\VideoIntelligenceServiceClient;
2324
use Google\Cloud\VideoIntelligence\V1\Feature;
2425

2526
/**
@@ -33,10 +34,10 @@ function analyze_labels_gcs(string $uri, int $pollingIntervalSeconds = 0)
3334

3435
# Execute a request.
3536
$features = [Feature::LABEL_DETECTION];
36-
$operation = $video->annotateVideo([
37-
'inputUri' => $uri,
38-
'features' => $features,
39-
]);
37+
$request = (new AnnotateVideoRequest())
38+
->setInputUri($uri)
39+
->setFeatures($features);
40+
$operation = $video->annotateVideo($request);
4041

4142
# Wait for the request to complete.
4243
$operation->pollUntilComplete([

video/src/analyze_object_tracking.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
namespace Google\Cloud\Samples\VideoIntelligence;
2020

2121
// [START video_object_tracking_gcs]
22-
use Google\Cloud\VideoIntelligence\V1\VideoIntelligenceServiceClient;
22+
use Google\Cloud\VideoIntelligence\V1\AnnotateVideoRequest;
23+
use Google\Cloud\VideoIntelligence\V1\Client\VideoIntelligenceServiceClient;
2324
use Google\Cloud\VideoIntelligence\V1\Feature;
2425

2526
/**
@@ -33,10 +34,10 @@ function analyze_object_tracking(string $uri, int $pollingIntervalSeconds = 0)
3334

3435
# Execute a request.
3536
$features = [Feature::OBJECT_TRACKING];
36-
$operation = $video->annotateVideo([
37-
'inputUri' => $uri,
38-
'features' => $features,
39-
]);
37+
$request = (new AnnotateVideoRequest())
38+
->setInputUri($uri)
39+
->setFeatures($features);
40+
$operation = $video->annotateVideo($request);
4041

4142
# Wait for the request to complete.
4243
$operation->pollUntilComplete([

video/src/analyze_object_tracking_file.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
namespace Google\Cloud\Samples\VideoIntelligence;
2020

2121
// [START video_object_tracking]
22-
use Google\Cloud\VideoIntelligence\V1\VideoIntelligenceServiceClient;
22+
use Google\Cloud\VideoIntelligence\V1\AnnotateVideoRequest;
23+
use Google\Cloud\VideoIntelligence\V1\Client\VideoIntelligenceServiceClient;
2324
use Google\Cloud\VideoIntelligence\V1\Feature;
2425

2526
/**
@@ -36,10 +37,10 @@ function analyze_object_tracking_file(string $path, int $pollingIntervalSeconds
3637

3738
# Execute a request.
3839
$features = [Feature::OBJECT_TRACKING];
39-
$operation = $video->annotateVideo([
40-
'inputContent' => $inputContent,
41-
'features' => $features,
42-
]);
40+
$request = (new AnnotateVideoRequest())
41+
->setInputContent($inputContent)
42+
->setFeatures($features);
43+
$operation = $video->annotateVideo($request);
4344

4445
# Wait for the request to complete.
4546
$operation->pollUntilComplete([

video/src/analyze_shots.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
namespace Google\Cloud\Samples\VideoIntelligence;
2020

2121
// [START video_analyze_shots]
22-
use Google\Cloud\VideoIntelligence\V1\VideoIntelligenceServiceClient;
22+
use Google\Cloud\VideoIntelligence\V1\AnnotateVideoRequest;
23+
use Google\Cloud\VideoIntelligence\V1\Client\VideoIntelligenceServiceClient;
2324
use Google\Cloud\VideoIntelligence\V1\Feature;
2425

2526
/**
@@ -33,10 +34,10 @@ function analyze_shots(string $uri, int $pollingIntervalSeconds = 0)
3334

3435
# Execute a request.
3536
$features = [Feature::SHOT_CHANGE_DETECTION];
36-
$operation = $video->annotateVideo([
37-
'inputUri' => $uri,
38-
'features' => $features,
39-
]);
37+
$request = (new AnnotateVideoRequest())
38+
->setInputUri($uri)
39+
->setFeatures($features);
40+
$operation = $video->annotateVideo($request);
4041

4142
# Wait for the request to complete.
4243
$operation->pollUntilComplete([

video/src/analyze_text_detection.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
namespace Google\Cloud\Samples\VideoIntelligence;
2020

2121
// [START video_detect_text_gcs]
22-
use Google\Cloud\VideoIntelligence\V1\VideoIntelligenceServiceClient;
22+
use Google\Cloud\VideoIntelligence\V1\AnnotateVideoRequest;
23+
use Google\Cloud\VideoIntelligence\V1\Client\VideoIntelligenceServiceClient;
2324
use Google\Cloud\VideoIntelligence\V1\Feature;
2425

2526
/**
@@ -33,10 +34,10 @@ function analyze_text_detection(string $uri, int $pollingIntervalSeconds = 0)
3334

3435
# Execute a request.
3536
$features = [Feature::TEXT_DETECTION];
36-
$operation = $video->annotateVideo([
37-
'inputUri' => $uri,
38-
'features' => $features,
39-
]);
37+
$request = (new AnnotateVideoRequest())
38+
->setInputUri($uri)
39+
->setFeatures($features);
40+
$operation = $video->annotateVideo($request);
4041

4142
# Wait for the request to complete.
4243
$operation->pollUntilComplete([

video/src/analyze_text_detection_file.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
namespace Google\Cloud\Samples\VideoIntelligence;
2020

2121
// [START video_detect_text]
22-
use Google\Cloud\VideoIntelligence\V1\VideoIntelligenceServiceClient;
22+
use Google\Cloud\VideoIntelligence\V1\AnnotateVideoRequest;
23+
use Google\Cloud\VideoIntelligence\V1\Client\VideoIntelligenceServiceClient;
2324
use Google\Cloud\VideoIntelligence\V1\Feature;
2425

2526
/**
@@ -36,10 +37,10 @@ function analyze_text_detection_file(string $path, int $pollingIntervalSeconds =
3637

3738
# Execute a request.
3839
$features = [Feature::TEXT_DETECTION];
39-
$operation = $video->annotateVideo([
40-
'inputContent' => $inputContent,
41-
'features' => $features,
42-
]);
40+
$request = (new AnnotateVideoRequest())
41+
->setInputContent($inputContent)
42+
->setFeatures($features);
43+
$operation = $video->annotateVideo($request);
4344

4445
# Wait for the request to complete.
4546
$operation->pollUntilComplete([

video/src/analyze_transcription.php

+8-7
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@
1919
namespace Google\Cloud\Samples\VideoIntelligence;
2020

2121
// [START video_speech_transcription_gcs]
22-
use Google\Cloud\VideoIntelligence\V1\VideoIntelligenceServiceClient;
22+
use Google\Cloud\VideoIntelligence\V1\AnnotateVideoRequest;
23+
use Google\Cloud\VideoIntelligence\V1\Client\VideoIntelligenceServiceClient;
2324
use Google\Cloud\VideoIntelligence\V1\Feature;
24-
use Google\Cloud\VideoIntelligence\V1\VideoContext;
2525
use Google\Cloud\VideoIntelligence\V1\SpeechTranscriptionConfig;
26+
use Google\Cloud\VideoIntelligence\V1\VideoContext;
2627

2728
/**
2829
* @param string $uri The cloud storage object to analyze (gs://your-bucket-name/your-object-name)
@@ -42,11 +43,11 @@ function analyze_transcription(string $uri, int $pollingIntervalSeconds = 0)
4243

4344
# execute a request.
4445
$features = [Feature::SPEECH_TRANSCRIPTION];
45-
$operation = $client->annotateVideo([
46-
'inputUri' => $uri,
47-
'videoContext' => $videoContext,
48-
'features' => $features,
49-
]);
46+
$request = (new AnnotateVideoRequest())
47+
->setInputUri($uri)
48+
->setVideoContext($videoContext)
49+
->setFeatures($features);
50+
$operation = $client->annotateVideo($request);
5051

5152
print('Processing video for speech transcription...' . PHP_EOL);
5253
# Wait for the request to complete.

0 commit comments

Comments
 (0)