Video Models¶
aana.core.models.video
¶
Video
¶
Video(path=None, url=None, content=None, media_id=lambda: str(uuid.uuid4())(), save_on_disk=True, is_saved=False, media_dir=settings.video_dir, title='', description='')
Bases: Media
A class representing a video.
At least one of path
, url
, or content
must be provided.
If save_on_disk
is True, the video will be saved on disk automatically.
ATTRIBUTE | DESCRIPTION |
---|---|
path |
the path to the video file
TYPE:
|
url |
the URL of the video
TYPE:
|
content |
the content of the video in bytes
TYPE:
|
media_id |
the ID of the video. If not provided, it will be generated automatically.
TYPE:
|
title |
the title of the video
TYPE:
|
description |
the description of the video
TYPE:
|
media_dir |
the directory to save the video in
TYPE:
|
save
¶
Save the media on disk.
If the media is already available on disk, do nothing. If the media represented as a byte string, save it on disk If the media is represented as a URL, download it and save it on disk.
RAISES | DESCRIPTION |
---|---|
ValueError
|
if at least one of 'path', 'url', or 'content' is not provided |
Source code in aana/core/models/media.py
get_content
¶
Get the content of the media as bytes.
RETURNS | DESCRIPTION |
---|---|
bytes
|
the content of the media
TYPE:
|
RAISES | DESCRIPTION |
---|---|
ValueError
|
if at least one of 'path', 'url', or 'content' is not provided |
Source code in aana/core/models/media.py
cleanup
¶
Cleanup the media.
If the media is saved on disk by the class, delete it.
is_video
¶
Checks if it's a valid video.
Source code in aana/core/models/video.py
VideoMetadata
¶
Bases: BaseModel
Metadata of a video.
ATTRIBUTE | DESCRIPTION |
---|---|
title |
the title of the video
TYPE:
|
description |
the description of the video
TYPE:
|
duration |
the duration of the video in seconds
TYPE:
|
VideoParams
¶
Bases: BaseModel
A pydantic model for video parameters.
ATTRIBUTE | DESCRIPTION |
---|---|
extract_fps |
the number of frames to extract per second
TYPE:
|
fast_mode_enabled |
whether to use fast mode (keyframes only)
TYPE:
|
VideoInput
¶
Bases: BaseModel
A video input.
Exactly one of 'path', 'url', or 'content' must be provided.
If 'content' is set to 'file', the video will be loaded from the files uploaded to the endpoint.
ATTRIBUTE | DESCRIPTION |
---|---|
media_id |
the ID of the video. If not provided, it will be generated automatically.
TYPE:
|
path |
the file path of the video
TYPE:
|
url |
the URL of the video (supports YouTube videos)
TYPE:
|
content |
the content of the video in bytes
TYPE:
|
check_only_one_field
¶
Check that exactly one of 'path', 'url', or 'content' is provided.
RAISES | DESCRIPTION |
---|---|
ValueError
|
if not exactly one of 'path', 'url', or 'content' is provided |
RETURNS | DESCRIPTION |
---|---|
Self
|
the instance
TYPE:
|
Source code in aana/core/models/video.py
set_files
¶
Set the files for the video.
PARAMETER | DESCRIPTION |
---|---|
files |
the files uploaded to the endpoint
TYPE:
|
RAISES | DESCRIPTION |
---|---|
UploadedFileNotFound
|
if the file is not found |
Source code in aana/core/models/video.py
convert_input_to_object
¶
Convert the video input to a video object.
RETURNS | DESCRIPTION |
---|---|
Video
|
the video object corresponding to the video input
TYPE:
|
RAISES | DESCRIPTION |
---|---|
UploadedFileNotFound
|
if the file is not found |
Source code in aana/core/models/video.py
VideoInputList
¶
Bases: BaseListModel
A pydantic model for a list of video inputs.
Only used for the requests, DO NOT use it for anything else.
Convert it to a list of video objects with convert_input_to_object().
check_non_empty
¶
Check that the list of videos isn't empty.
RAISES | DESCRIPTION |
---|---|
ValueError
|
if the list of videos is empty |
RETURNS | DESCRIPTION |
---|---|
Self
|
the instance
TYPE:
|
Source code in aana/core/models/video.py
set_files
¶
Set the files for the videos.
PARAMETER | DESCRIPTION |
---|---|
files |
the files uploaded to the endpoint
TYPE:
|
RAISES | DESCRIPTION |
---|---|
UploadedFileNotFound
|
if the file is not found |
Source code in aana/core/models/video.py
convert_input_to_object
¶
Convert the VideoInputList to a list of video inputs.
RETURNS | DESCRIPTION |
---|---|
list[VideoInput]
|
List[VideoInput]: the list of video inputs |