|
26 | 26 |
|
27 | 27 | """
|
28 | 28 |
|
29 |
| -# [START full_tutorial] |
30 |
| -# [START imports] |
| 29 | +# [START video_shot_tutorial] |
| 30 | +# [START video_shot_tutorial_imports] |
31 | 31 | import argparse
|
32 | 32 |
|
33 | 33 | from google.cloud import videointelligence
|
34 |
| -# [END imports] |
| 34 | +# [END video_shot_tutorial_imports] |
35 | 35 |
|
36 | 36 |
|
37 | 37 | def analyze_shots(path):
|
38 | 38 | """ Detects camera shot changes. """
|
39 |
| - # [START construct_request] |
| 39 | + # [START video_shot_tutorial_construct_request] |
40 | 40 | video_client = videointelligence.VideoIntelligenceServiceClient()
|
41 | 41 | features = [videointelligence.enums.Feature.SHOT_CHANGE_DETECTION]
|
42 | 42 | operation = video_client.annotate_video(path, features=features)
|
43 |
| - # [END construct_request] |
| 43 | + # [END video_shot_tutorial_construct_request] |
44 | 44 | print('\nProcessing video for shot change annotations:')
|
45 | 45 |
|
46 |
| - # [START check_operation] |
| 46 | + # [START video_shot_tutorial_check_operation] |
47 | 47 | result = operation.result(timeout=90)
|
48 | 48 | print('\nFinished processing.')
|
49 |
| - # [END check_operation] |
| 49 | + # [END video_shot_tutorial_check_operation] |
50 | 50 |
|
51 |
| - # [START parse_response] |
| 51 | + # [START video_shot_tutorial_parse_response] |
52 | 52 | for i, shot in enumerate(result.annotation_results[0].shot_annotations):
|
53 | 53 | start_time = (shot.start_time_offset.seconds +
|
54 | 54 | shot.start_time_offset.nanos / 1e9)
|
55 | 55 | end_time = (shot.end_time_offset.seconds +
|
56 | 56 | shot.end_time_offset.nanos / 1e9)
|
57 | 57 | print('\tShot {}: {} to {}'.format(i, start_time, end_time))
|
58 |
| - # [END parse_response] |
| 58 | + # [END video_shot_tutorial_parse_response] |
59 | 59 |
|
60 | 60 |
|
61 | 61 | if __name__ == '__main__':
|
62 |
| - # [START running_app] |
| 62 | + # [START video_shot_tutorial_run_application] |
63 | 63 | parser = argparse.ArgumentParser(
|
64 | 64 | description=__doc__,
|
65 | 65 | formatter_class=argparse.RawDescriptionHelpFormatter)
|
66 | 66 | parser.add_argument('path', help='GCS path for shot change detection.')
|
67 | 67 | args = parser.parse_args()
|
68 | 68 |
|
69 | 69 | analyze_shots(args.path)
|
70 |
| - # [END running_app] |
71 |
| -# [END full_tutorial] |
| 70 | + # [END video_shot_tutorial_run_application] |
| 71 | +# [END video_shot_tutorial] |
0 commit comments