33
33
34
34
35
35
def analyze_explicit_content (path ):
36
+ # [START video_analyze_explicit_content]
36
37
""" Detects explicit content from the GCS path to a video. """
37
38
video_client = videointelligence .VideoIntelligenceServiceClient ()
38
39
features = [videointelligence .enums .Feature .EXPLICIT_CONTENT_DETECTION ]
@@ -52,9 +53,11 @@ def analyze_explicit_content(path):
52
53
print ('Time: {}s' .format (frame_time ))
53
54
print ('\t pornography: {}' .format (
54
55
likely_string [frame .pornography_likelihood ]))
56
+ # [END video_analyze_explicit_content]
55
57
56
58
57
59
def analyze_labels (path ):
60
+ # [START video_analyze_labels_gcs]
58
61
""" Detects labels given a GCS path. """
59
62
video_client = videointelligence .VideoIntelligenceServiceClient ()
60
63
features = [videointelligence .enums .Feature .LABEL_DETECTION ]
@@ -129,9 +132,11 @@ def analyze_labels(path):
129
132
print ('\t First frame time offset: {}s' .format (time_offset ))
130
133
print ('\t First frame confidence: {}' .format (frame .confidence ))
131
134
print ('\n ' )
135
+ # [END video_analyze_labels_gcs]
132
136
133
137
134
138
def analyze_labels_file (path ):
139
+ # [START video_analyze_labels_local]
135
140
"""Detect labels given a file path."""
136
141
video_client = videointelligence .VideoIntelligenceServiceClient ()
137
142
features = [videointelligence .enums .Feature .LABEL_DETECTION ]
@@ -202,9 +207,11 @@ def analyze_labels_file(path):
202
207
print ('\t First frame time offset: {}s' .format (time_offset ))
203
208
print ('\t First frame confidence: {}' .format (frame .confidence ))
204
209
print ('\n ' )
210
+ # [END video_analyze_labels_local]
205
211
206
212
207
213
def analyze_shots (path ):
214
+ # [START video_analyze_shots]
208
215
""" Detects camera shot changes. """
209
216
video_client = videointelligence .VideoIntelligenceServiceClient ()
210
217
features = [videointelligence .enums .Feature .SHOT_CHANGE_DETECTION ]
@@ -221,6 +228,7 @@ def analyze_shots(path):
221
228
end_time = (shot .end_time_offset .seconds +
222
229
shot .end_time_offset .nanos / 1e9 )
223
230
print ('\t Shot {}: {} to {}' .format (i , start_time , end_time ))
231
+ # [END video_analyze_shots]
224
232
225
233
226
234
if __name__ == '__main__' :
0 commit comments