File tree 2 files changed +7
-16
lines changed
2 files changed +7
-16
lines changed Original file line number Diff line number Diff line change 1
- google-cloud-videointelligence == 0.28 .0
1
+ google-cloud-videointelligence == 1.0 .0
Original file line number Diff line number Diff line change 29
29
# [START full_tutorial]
30
30
# [START imports]
31
31
import argparse
32
- import sys
33
- import time
34
32
35
- from google .cloud import videointelligence_v1beta2
36
- from google .cloud .videointelligence_v1beta2 import enums
33
+ from google .cloud import videointelligence
37
34
# [END imports]
38
35
39
36
40
37
def analyze_shots (path ):
41
38
""" Detects camera shot changes. """
42
39
# [START construct_request]
43
- video_client = videointelligence_v1beta2 .VideoIntelligenceServiceClient ()
44
- features = [enums .Feature .SHOT_CHANGE_DETECTION ]
45
- operation = video_client .annotate_video (path , features )
40
+ video_client = videointelligence .VideoIntelligenceServiceClient ()
41
+ features = [videointelligence . enums .Feature .SHOT_CHANGE_DETECTION ]
42
+ operation = video_client .annotate_video (path , features = features )
46
43
# [END construct_request]
47
44
print ('\n Processing video for shot change annotations:' )
48
45
49
46
# [START check_operation]
50
- while not operation .done ():
51
- sys .stdout .write ('.' )
52
- sys .stdout .flush ()
53
- time .sleep (20 )
54
-
47
+ result = operation .result (timeout = 90 )
55
48
print ('\n Finished processing.' )
56
49
# [END check_operation]
57
50
58
51
# [START parse_response]
59
- shots = operation .result ().annotation_results [0 ].shot_annotations
60
-
61
- for i , shot in enumerate (shots ):
52
+ for i , shot in enumerate (result .annotation_results [0 ].shot_annotations ):
62
53
start_time = (shot .start_time_offset .seconds +
63
54
shot .start_time_offset .nanos / 1e9 )
64
55
end_time = (shot .end_time_offset .seconds +
You can’t perform that action at this time.
0 commit comments