Skip to content

Commit 844de44

Browse files
committed
Add upload videos cli
1 parent 4ecaba7 commit 844de44

File tree

3 files changed

+102
-3
lines changed

3 files changed

+102
-3
lines changed

docs/source/cli.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,38 @@ scanned for available images.
5252

5353
Optional argument *extensions* accepts comma separated list of image extensions to look for. If the argument is not given then value *jpg,png* is assumed.
5454

55+
----------
56+
57+
.. _ref_upload_videos:
58+
59+
Uploading videos
60+
~~~~~~~~~~~~~~~~
61+
62+
To upload videos from folder to project use:
63+
64+
.. code-block:: bash
65+
66+
superannotate upload-videos --project <project_name> --folder <folder_path>
67+
[--recursive] [--extensions mp4,avi,mov,webm,flv,mpg,ogg]
68+
[--target-fps <float>] [--start-time <float>]
69+
[--end-time <float>]
70+
71+
If optional argument *recursive* is given then subfolders of :file:`<folder_path>` are also recursively
72+
scanned for available images.
73+
74+
Optional argument *extensions* accepts comma separated list of image extensions
75+
to look for. If the argument is not given then value *mp4,avi,mov,webm,flv,mpg,ogg* is assumed.
76+
77+
*target-fps* specifies how many frames per second need to extract from the videos (approximate).
78+
If not specified all frames will be uploaded.
79+
80+
*start-time* specifies time (in seconds) from which to start extracting frames,
81+
default is 0.0.
82+
83+
*end-time* specifies time (in seconds) up to which to extract frames.
84+
If it is not specified, then up to end is assumed.
85+
86+
5587
----------
5688

5789
.. _ref_cli_version:

superannotate/__main__.py

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ def main():
4343
command = sys.argv[1]
4444
further_args = sys.argv[2:]
4545

46-
if command == "image-upload":
46+
if command == "upload-images":
4747
image_upload(further_args)
48+
elif command == "upload-videos":
49+
video_upload(further_args)
4850
elif command == "init":
4951
ask_token(further_args)
5052
elif command == "export-project":
@@ -59,6 +61,70 @@ def _list_str(values):
5961
return values.split(',')
6062

6163

64+
def video_upload(args):
65+
parser = argparse.ArgumentParser()
66+
parser.add_argument(
67+
'--project', required=True, help='Project name to upload'
68+
)
69+
parser.add_argument(
70+
'--folder', required=True, help='Folder from which to upload'
71+
)
72+
parser.add_argument(
73+
'--recursive',
74+
default=False,
75+
action='store_true',
76+
help='Enables recursive subfolder upload.'
77+
)
78+
parser.add_argument(
79+
'--extensions',
80+
required=False,
81+
default=None,
82+
type=_list_str,
83+
help=
84+
'List of video extensions to include. Default is mp4,avi,mov,webm,flv,mpg,ogg'
85+
)
86+
parser.add_argument(
87+
'--set-annotation-status',
88+
required=False,
89+
default="NotStarted",
90+
help=
91+
'Set images\' annotation statuses after upload. Default is NotStarted'
92+
)
93+
parser.add_argument(
94+
'--target-fps',
95+
required=False,
96+
default=None,
97+
help=
98+
'How many frames per second need to extract from the videos (approximate). If not specified all frames will be uploaded'
99+
)
100+
parser.add_argument(
101+
'--start-time',
102+
required=False,
103+
default=0.0,
104+
help=
105+
'Time (in seconds) from which to start extracting frames. Default is 0.0'
106+
)
107+
parser.add_argument(
108+
'--end-time',
109+
required=False,
110+
default=None,
111+
help=
112+
'Time (in seconds) up to which to extract frames. If it is not specified, then up to end'
113+
)
114+
args = parser.parse_args(args)
115+
116+
sa.upload_videos_from_folder_to_project(
117+
project=args.project,
118+
folder_path=args.folder,
119+
extensions=args.extensions,
120+
annotation_status=args.set_annotation_status,
121+
recursive_subfolders=args.recursive,
122+
target_fps=args.target_fps,
123+
start_time=args.start_time,
124+
end_time=args.end_time
125+
)
126+
127+
62128
def image_upload(args):
63129
parser = argparse.ArgumentParser()
64130
parser.add_argument(

superannotate/db/projects.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,9 @@ def upload_videos_from_folder_to_project(
413413
:type end_time: float
414414
:param annotation_status: value to set the annotation statuses of the uploaded images NotStarted InProgress QualityCheck Returned Completed Skipped
415415
:type annotation_status: str
416-
:param image_quality_in_editor: image quality (in percents) that will be seen in SuperAnnotate web annotation editor. If None default value will be used.
417-
:type image_quality_in_editor: int
416+
:param image_quality_in_editor: image quality be seen in SuperAnnotate web annotation editor.
417+
Can be either "compressed" or "original". If None then the default value in project settings will be used.
418+
:type image_quality_in_editor: str
418419
419420
:return: uploaded and not-uploaded video frame images' filenames
420421
:rtype: tuple of list of strs

0 commit comments

Comments
 (0)