-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathvideo_clips.py
37 lines (28 loc) · 1.14 KB
/
video_clips.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python
""" This example shows how to get a video clip from a video.
"""
import logging
import sys
import tator
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
logger = logging.getLogger(__name__)
if __name__ == '__main__':
# Create a parser that includes path to text file.
parser = tator.get_parser()
parser.add_argument('--video_id',
help='Media ID for a video.',
required=True, type=int)
parser.add_argument('--file_path',
help='Save path for the clip.',
required=True)
args = parser.parse_args()
# Create the api.
tator_api = tator.get_api(args.host, args.token)
# Get the video clip.
clip_info = tator_api.get_clip(args.video_id, frame_ranges=['0:30', '50:90'])
temporary_file = clip_info.file
# Download the file.
for progress in tator.util.download_temporary_file(tator_api,
temporary_file,
args.file_path):
logger.info(f"Download progress: {progress}%")