requesters
Contains Request models that validate and prepare a request for extraction.
Request
dataclass
Bases: ABC
Protocol defining the interface for validating and preparing extraction requests.
Public Methods:
`validate()` -> `Request`:
Validate fields if specified and return a validated request of the same
type.
`prepare()` -> `PreparedRequest`:
Construct and return a prepared request using a video and a validated
request of some type. A prepared request is required by an extractor of the
same type.
Properties:
`is_validated` (bool): If the request has been validated.
is_validated
abstractmethod
property
Return True if Request has been validated, False otherwise.
validate
abstractmethod
prepare
abstractmethod
Construct and return a prepared request using a video and a validated request of some type. A prepared request is required by an extractor of the same type.
BaseRequest
dataclass
Bases: Request
Stores, validates and prepares extraction request arguments shared by all methods.
Fields
`start_time` (float | int | str | None):
Specify the extraction's start time in seconds, or as a string in "HH:MM:SS"
format. Defaults to 0 if not specified.
`stop_time` (float | int | str | None):
Specify the extraction's stop time in seconds, or as a string in "HH:MM:SS"
format. Defaults to the video duration if not specified.
`destdir` (Path | None):
Specify the directory you want to save output to. Defaults to the video's
directory if not specified.
`filename` (str | None):
Specify the name of the extracted file(s). Defaults to the video filename
if not specified.
`verbose` (bool | None):
If True, the prepared request and extraction results will be printed as JSON
to console. Defaults to False if not specified.
`overwrite` (bool | None):
If True, permits overwriting the destination path if the file or directory
already exists. Defaults to False if not specified.
`fps` (float | None):
Override the frames per second (fps) value obtained from `cv2` when reading
the video. This value is used to set the start and stop frames for the
extraction range. This option should be used only in rare cases where `cv2`
fails to accurately read the fps. If not specified, it defaults to the fps
of the video as read by `cv2`.
Public Methods
- `validate()` -> `BaseRequest`:
Validate fields if specified and return a validated `BaseRequest`.
- `prepare()` -> `PreparedBaseRequest`:
Construct and return a prepared base request using a video and a base
request. A prepared base request is not used by any extractor. Its sole
purpose is to validate and prepare the shared request arguments.
Properties
- `is_validated` -> `bool`: If the request has been validated.
validate
Validate fields if specified and return a validated BaseRequest.
Source code in videoxt/requesters.py
prepare
Construct and return a PreparedBaseRequest using self and a Video.
Args:
`video` (Video): Contains video metadata used to prepare request.
Returns:
`PreparedBaseRequest`: A prepared base extraction request.
Source code in videoxt/requesters.py
AudioRequest
dataclass
Bases: BaseRequest
Stores, validates and prepares 'audio' extraction request arguments.
Fields
`start_time` (float | int | str | None):
Specify the extraction's start time in seconds, or as a string in "HH:MM:SS"
format. Defaults to 0 if not specified.
`stop_time` (float | int | str | None):
Specify the extraction's stop time in seconds, or as a string in "HH:MM:SS"
format. Defaults to the video duration if not specified.
`destdir` (Path | None):
Specify the directory you want to save output to. Defaults to the video's
directory if not specified.
`filename` (str | None):
Specify the name of the extracted file(s). Defaults to the video filename
if not specified.
`verbose` (bool | None):
If True, the prepared request and extraction results will be printed as JSON
to console. Defaults to False if not specified.
`overwrite` (bool | None):
If True, permits overwriting the destination path if the file or directory
already exists. Defaults to False if not specified.
`fps` (float | None):
Override the frames per second (fps) value obtained from `cv2` when reading
the video. This value is used to set the start and stop frames for the
extraction range. This option should be used only in rare cases where `cv2`
fails to accurately read the fps. If not specified, it defaults to the fps
of the video as read by `cv2`.
`audio_format` (str | None):
Set the extracted audio file format. Defaults to 'mp3' if not specified.
See: `videoxt.constants.SUPPORTED_AUDIO_FORMATS`.
`speed` (float | None):
Set the speed of the extracted audio. A value of 0.5 will halve the speed of
the extracted audio. Defaults to 1.0 if not specified (no change).
`bounce` (bool | None):
If True, bounce the extracted audio bommerang-style. Defaults to False if
not specified.
`reverse` (bool | None):
If True, reverse the extracted audio. Defaults to False if not specified.
`volume` (float | None):
Set the volume of the extracted audio. A value of 0.5 will halve the volume
of the extracted audio. Defaults to 1.0 if not specified (no change).
`normalize` (bool | None):
If True, normalize the audio. Normalization adjusts the gain of the audio to
ensure consistent levels, preventing distortion and enhancing clarity in
some cases. Defaults to False if not specified.
Public Methods
- `validate()` -> `AudioRequest`:
Validate fields if specified and return a validated `AudioRequest`.
- `prepare()` -> `PreparedAudioRequest`:
Construct and return a prepared audio request using a video and a validated
`AudioRequest`. A prepared audio request is required by an `AudioExtractor`.
Properties
- `is_validated` -> `bool`: If the request has been validated.
validate
Validate fields if specified and return a validated AudioRequest.
Source code in videoxt/requesters.py
prepare
Construct and return a PreparedAudioRequest using self and a Video.
Fields will validate before preparation if not validated.
Args:
`video` (Video): Contains video metadata used to prepare request.
Returns:
`PreparedAudioRequest`:
A prepared audio extraction request, required by an `AudioExtractor`.
Source code in videoxt/requesters.py
ClipRequest
dataclass
Bases: BaseRequest
Stores, validates and prepares 'clip' extraction request arguments.
Recommended usage: Set a short extraction range. The process can be slow for long or high-resolution videos.
Fields
`start_time` (float | int | str | None):
Specify the extraction's start time in seconds, or as a string in "HH:MM:SS"
format. Defaults to 0 if not specified.
`stop_time` (float | int | str | None):
Specify the extraction's stop time in seconds, or as a string in "HH:MM:SS"
format. Defaults to the video duration if not specified.
`destdir` (Path | None):
Specify the directory you want to save output to. Defaults to the video's
directory if not specified.
`filename` (str | None):
Specify the name of the extracted file(s). Defaults to the video filename
if not specified.
`verbose` (bool | None):
If True, the prepared request and extraction results will be printed as JSON
to console. Defaults to False if not specified.
`overwrite` (bool | None):
If True, permits overwriting the destination path if the file or directory
already exists. Defaults to False if not specified.
`fps` (float | None):
Override the frames per second (fps) value obtained from `cv2` when reading
the video. This value is used to set the start and stop frames for the
extraction range. This option should be used only in rare cases where `cv2`
fails to accurately read the fps. If not specified, it defaults to the fps
of the video as read by `cv2`.
`dimensions` (tuple[int, int] | None):
Specify the dimensions (frame width, frame height) of the clip. Defaults to
the video dimensions if not specified.
`resize` (float | None):
Resize the dimensions of the clip by a factor of `n`. A value of 0.5
will halve the dimensions. If you specify `dimensions`, `resize` will apply
to the dimensions you specify. Defaults to 1.0 if not specified (no change).
`rotate` (int | None):
Rotate the clip by `n` degrees. Allowed values: 0, 90, 180 or 270. Defaults
to 0 if not specified (no change).
`speed` (float | None):
Set the speed of the extracted clip. A value of 0.5 will halve the playback
speed of the clip. Defaults to 1.0 if not specified (no change).
`bounce` (bool | None):
If True, bounce the extracted clip bommerang-style. Defaults to False if
not specified.
`reverse` (bool | None):
If True, reverse the extracted clip. Defaults to False if not specified.
`monochrome` (bool | None):
If True, apply a black-and-white filter to the clip. Defaults to False if
not specified.
`volume` (float | None):
Set the volume of the extracted clip's audio. A value of 0.5 will halve the
volume of the clip's audio. Defaults to 1.0 if not specified (no change).
`normalize` (bool | None):
If True, normalize the audio. Normalization adjusts the gain of the audio to
ensure consistent levels, preventing distortion and enhancing clarity in
some cases. Defaults to False if not specified.
Public Methods
- `validate()` -> `ClipRequest`:
Validate fields if specified and return a validated `ClipRequest`.
- `prepare()` -> `PreparedClipRequest`:
Construct and return a prepared clip request using a video and a validated
`ClipRequest`. A prepared clip request is required by a `ClipExtractor`.
Properties
- `is_validated` -> `bool`: If the request has been validated.
validate
Validate fields if specified and return a validated ClipRequest.
Source code in videoxt/requesters.py
prepare
Construct and return a PreparedClipRequest using self and a Video.
Fields will validate before preparation if not validated.
Args:
`video` (Video): Contains video metadata used to prepare request.
Returns:
`PreparedClipRequest`:
A prepared clip extraction request, required by a `ClipExtractor`.
Source code in videoxt/requesters.py
FramesRequest
dataclass
Bases: BaseRequest
Stores, validates and prepares 'frames' extraction request arguments.
The images are saved to a directory named after the video file, or to a directory you specify.
Fields
`start_time` (float | int | str | None):
Specify the extraction's start time in seconds, or as a string in "HH:MM:SS"
format. Defaults to 0 if not specified.
`stop_time` (float | int | str | None):
Specify the extraction's stop time in seconds, or as a string in "HH:MM:SS"
format. Defaults to the video duration if not specified.
`destdir` (Path | None):
Specify the directory you want to save output to. Defaults to the video's
directory if not specified.
`filename` (str | None):
Specify the name of the extracted file(s). Defaults to the video filename
if not specified.
`verbose` (bool | None):
If True, the prepared request and extraction results will be printed as JSON
to console. Defaults to False if not specified.
`overwrite` (bool | None):
If True, permits overwriting the destination path if the file or directory
already exists. Defaults to False if not specified.
`fps` (float | None):
Override the frames per second (fps) value obtained from `cv2` when reading
the video. This value is used to set the start and stop frames for the
extraction range. This option should be used only in rare cases where `cv2`
fails to accurately read the fps. If not specified, it defaults to the fps
of the video as read by `cv2`.
`image_format` (str | None):
Set the extracted image file format. Defaults to 'jpg' if not specified.
See: `videoxt.constants.SUPPORTED_IMAGE_FORMATS`.
`capture_rate` (int | None):
Capture every Nth video frame. Defaults to 1 if not specified, which
extracts every frame within the extraction range.
`dimensions` (tuple[int, int] | None):
Specify the dimensions (frame width, frame height) of the images. Defaults
to the video dimensions if not specified.
`resize` (float | None):
Resize the dimensions of the images by a factor of `n`. A value of 0.5
will halve the dimensions. If you specify `dimensions`, `resize` will apply
to the dimensions you specify. Defaults to 1.0 if not specified (no change).
`rotate` (int | None):
Rotate the images by `n` degrees. Allowed values: 0, 90, 180 or 270.
Defaults to 0 if not specified (no change).
`monochrome` (bool | None):
If True, apply a black-and-white filter to the images. Defaults to False if
not specified.
Public Methods
- `validate()` -> `FramesRequest`:
Validate fields if specified and return a validated `FramesRequest`.
- `prepare()` -> `PreparedFramesRequest`:
Construct and return a prepared frames request using a video and a validated
`FramesRequest`. A prepared frames request is required by a
`FramesExtractor`.
Properties
- `is_validated` -> `bool`: If the request has been validated.
validate
Validate fields if specified and return a validated FramesRequest.
Source code in videoxt/requesters.py
prepare
Construct and return a PreparedFramesRequest using self and a Video.
Fields will validate before preparation if not validated.
Args:
`video` (Video): Contains video metadata used to prepare request.
Returns:
`PreparedFramesRequest`:
A prepared frames extraction request, required by a `FramesExtractor`.
Source code in videoxt/requesters.py
GifRequest
dataclass
Bases: BaseRequest
Stores, validates and prepares 'gif' extraction request arguments.
Recommended usage: Set a short extraction range. The process can be slow for long or high-resolution videos.
Fields
`start_time` (float | int | str | None):
Specify the extraction's start time in seconds, or as a string in "HH:MM:SS"
format. Defaults to 0 if not specified.
`stop_time` (float | int | str | None):
Specify the extraction's stop time in seconds, or as a string in "HH:MM:SS"
format. Defaults to the video duration if not specified.
`destdir` (Path | None):
Specify the directory you want to save output to. Defaults to the video's
directory if not specified.
`filename` (str | None):
Specify the name of the extracted file(s). Defaults to the video filename
if not specified.
`verbose` (bool | None):
If True, the prepared request and extraction results will be printed as JSON
to console. Defaults to False if not specified.
`overwrite` (bool | None):
If True, permits overwriting the destination path if the file or directory
already exists. Defaults to False if not specified.
`fps` (float | None):
Override the frames per second (fps) value obtained from `cv2` when reading
the video. This value is used to set the start and stop frames for the
extraction range. This option should be used only in rare cases where `cv2`
fails to accurately read the fps. If not specified, it defaults to the fps
of the video as read by `cv2`.
`dimensions` (tuple[int, int] | None):
Specify the dimensions (frame width, frame height) of the gif. Defaults to
the video dimensions if not specified.
`resize` (float | None):
Resize the dimensions of the gif by a factor of `n`. A value of 0.5
will halve the dimensions. If you specify `dimensions`, `resize` will apply
to the dimensions you specify. Defaults to 1.0 if not specified (no change).
`rotate` (int | None):
Rotate the gif by `n` degrees. Allowed values: 0, 90, 180 or 270. Defaults
to 0 if not specified (no change).
`speed` (float | None):
Set the speed of the extracted gif. A value of 0.5 will halve the playback
speed of the gif. Defaults to 1.0 if not specified (no change).
`bounce` (bool | None):
If True, bounce the extracted gif bommerang-style. Defaults to False if
not specified.
`reverse` (bool | None):
If True, reverse the extracted gif. Defaults to False if not specified.
`monochrome` (bool | None):
If True, apply a black-and-white filter to the gif. Defaults to False if
not specified.
Public Methods
- `validate()` -> `GifRequest`:
Validate fields if specified and return a validated `GifRequest`.
- `prepare()` -> `PreparedGifRequest`:
Construct and return a prepared gif request using a video and a validated
`GifRequest`. A prepared gif request is required by a `GifExtractor`.
Properties
- `is_validated` -> `bool`: If the request has been validated.
validate
Validate fields if specified and return a validated GifRequest.
Source code in videoxt/requesters.py
prepare
Construct and return a PreparedGifRequest using self and a Video.
Fields will validate before preparation if not validated.
Args:
`video` (Video): Contains video metadata used to prepare request.
Returns:
`PreparedGifRequest`:
A prepared gif extraction request, required by a `GifExtractor`.
Source code in videoxt/requesters.py
PreparedRequest
dataclass
Bases: ABC, ToJsonMixin
Protocol defining the interface for preparing requests for extraction.
Public Methods:
- `prepare()` -> `PreparedRequest`:
Prepare fields and return a fully prepared request of some type.
- `json()` -> `str`:
Return a JSON string representation of the prepared request type.
- `verbose_print()` -> `None`:
Print the JSON string to console with a title, without private keys.
Properties:
- `is_prepared` -> `bool`: If the request has been prepared.
- `is_verbose` -> `bool | None`: Return the state of the verbose field.
is_prepared
abstractmethod
property
Return True if the request has been prepared, False otherwise.
PreparedBaseRequest
dataclass
Bases: PreparedRequest
Prepares and stores request arguments shared by all extraction methods.
Fields
`video` (Video):
The object containing video metadata used to prepare the request.
`start_time` (float | int | str | None):
Specify the extraction's start time in seconds, or as a string in "HH:MM:SS"
format. Defaults to 0 if not specified.
`stop_time` (float | int | str | None):
Specify the extraction's stop time in seconds, or as a string in "HH:MM:SS"
format. Defaults to the video duration if not specified.
`destdir` (Path | None):
Specify the directory you want to save output to. Defaults to the video's
directory if not specified.
`filename` (str | None):
Specify the name of the extracted file(s). Defaults to the video filename
if not specified.
`verbose` (bool | None):
If True, the prepared request and extraction results will be printed as JSON
to console. Defaults to False if not specified.
`overwrite` (bool | None):
If True, permits overwriting the destination path if the file or directory
already exists. Defaults to False if not specified.
`fps` (float | None):
Override the frames per second (fps) value obtained from `cv2` when reading
the video. This value is used to set the start and stop frames for the
extraction range. This option should be used only in rare cases where `cv2`
fails to accurately read the fps. If not specified, it defaults to the fps
of the video as read by `cv2`.
`destpath` (Path):
The destination path of the extracted file or directory. Not initialized.
`extraction_range` (dict):
The range represented as seconds, as timestamps, and frame numbers.
Not initialized.
Public Methods
- `prepare()` -> `PreparedBaseRequest`:
Prepare fields and return a fully prepared base request.
- `json()` -> `str`:
Return a JSON string representation of the prepared base request.
- `verbose_print()` -> `None`:
Print the JSON string to console with a title, without private keys.
Properties:
- `is_prepared` -> `bool`: If the request has been prepared.
- `is_verbose` -> `bool | None`: Return the state of the verbose field.
extraction_range
class-attribute
instance-attribute
prepare
Prepare fields and return a PreparedBaseRequest.
Source code in videoxt/requesters.py
PreparedAudioRequest
dataclass
Bases: PreparedBaseRequest
Prepares and stores 'audio' extraction request arguments.
Fields
`video` (Video):
The object containing video metadata used to prepare the request.
`start_time` (float | int | str | None):
Specify the extraction's start time in seconds, or as a string in "HH:MM:SS"
format. Defaults to 0 if not specified.
`stop_time` (float | int | str | None):
Specify the extraction's stop time in seconds, or as a string in "HH:MM:SS"
format. Defaults to the video duration if not specified.
`destdir` (Path | None):
Specify the directory you want to save output to. Defaults to the video's
directory if not specified.
`filename` (str | None):
Specify the name of the extracted file(s). Defaults to the video filename
if not specified.
`verbose` (bool | None):
If True, the prepared request and extraction results will be printed as JSON
to console. Defaults to False if not specified.
`overwrite` (bool | None):
If True, permits overwriting the destination path if the file or directory
already exists. Defaults to False if not specified.
`fps` (float | None):
Override the frames per second (fps) value obtained from `cv2` when reading
the video. This value is used to set the start and stop frames for the
extraction range. This option should be used only in rare cases where `cv2`
fails to accurately read the fps. If not specified, it defaults to the fps
of the video as read by `cv2`.
`destpath` (Path):
The destination path of the extracted file or directory. Not initialized.
`extraction_range` (dict):
The range represented as seconds, as timestamps, and frame numbers.
Not initialized.
`audio_format` (str | None):
Set the extracted audio file format. Defaults to 'mp3' if not specified.
See: `videoxt.constants.SUPPORTED_AUDIO_FORMATS`.
`speed` (float | None):
Set the speed of the extracted audio. A value of 0.5 will halve the speed of
the extracted audio. Defaults to 1.0 if not specified (no change).
`bounce` (bool | None):
If True, bounce the extracted audio bommerang-style. Defaults to False if
not specified.
`reverse` (bool | None):
If True, reverse the extracted audio. Defaults to False if not specified.
`volume` (float | None):
Set the volume of the extracted audio. A value of 0.5 will halve the volume
of the extracted audio. Defaults to 1.0 if not specified (no change).
`normalize` (bool | None):
If True, normalize the audio. Normalization adjusts the gain of the audio to
ensure consistent levels, preventing distortion and enhancing clarity in
some cases. Defaults to False if not specified.
Public Methods
- `prepare()` -> `PreparedAudioRequest`:
Prepare fields and return a fully prepared audio request, required by an
`AudioExtractor`.
- `json()` -> `str`:
Return a JSON string representation of the prepared audio request.
- `verbose_print()` -> `None`:
Print the JSON string to console with a title, without private keys.
Properties:
- `is_prepared` -> `bool`: If the request has been prepared.
- `is_verbose` -> `bool | None`: Return the state of the verbose field.
prepare
Prepare request fields and return a PreparedAudioRequest, required by an
AudioExtractor.
Source code in videoxt/requesters.py
PreparedClipRequest
dataclass
Bases: PreparedBaseRequest
Prepares and stores 'clip' extraction request arguments.
Fields
`video` (Video):
The object containing video metadata used to prepare the request.
`start_time` (float | int | str | None):
Specify the extraction's start time in seconds, or as a string in "HH:MM:SS"
format. Defaults to 0 if not specified.
`stop_time` (float | int | str | None):
Specify the extraction's stop time in seconds, or as a string in "HH:MM:SS"
format. Defaults to the video duration if not specified.
`destdir` (Path | None):
Specify the directory you want to save output to. Defaults to the video's
directory if not specified.
`filename` (str | None):
Specify the name of the extracted file(s). Defaults to the video filename
if not specified.
`verbose` (bool | None):
If True, the prepared request and extraction results will be printed as JSON
to console. Defaults to False if not specified.
`overwrite` (bool | None):
If True, permits overwriting the destination path if the file or directory
already exists. Defaults to False if not specified.
`fps` (float | None):
Override the frames per second (fps) value obtained from `cv2` when reading
the video. This value is used to set the start and stop frames for the
extraction range. This option should be used only in rare cases where `cv2`
fails to accurately read the fps. If not specified, it defaults to the fps
of the video as read by `cv2`.
`destpath` (Path):
The destination path of the extracted file or directory. Not initialized.
`extraction_range` (dict):
The range represented as seconds, as timestamps, and frame numbers.
Not initialized.
`dimensions` (tuple[int, int] | None):
Specify the dimensions (frame width, frame height) of the clip. Defaults to
the video dimensions if not specified.
`resize` (float | None):
Resize the dimensions of the clip by a factor of `n`. A value of 0.5
will halve the dimensions. If you specify `dimensions`, `resize` will apply
to the dimensions you specify. Defaults to 1.0 if not specified (no change).
`rotate` (int | None):
Rotate the clip by `n` degrees. Allowed values: 0, 90, 180 or 270. Defaults
to 0 if not specified (no change).
`speed` (float | None):
Set the speed of the extracted clip. A value of 0.5 will halve the playback
speed of the clip. Defaults to 1.0 if not specified (no change).
`bounce` (bool | None):
If True, bounce the extracted clip bommerang-style. Defaults to False if
not specified.
`reverse` (bool | None):
If True, reverse the extracted clip. Defaults to False if not specified.
`monochrome` (bool | None):
If True, apply a black-and-white filter to the clip. Defaults to False if
not specified.
`volume` (float | None):
Set the volume of the extracted clip's audio. A value of 0.5 will halve the
volume of the clip's audio. Defaults to 1.0 if not specified (no change).
`normalize` (bool | None):
If True, normalize the audio. Normalization adjusts the gain of the audio to
ensure consistent levels, preventing distortion and enhancing clarity in
some cases. Defaults to False if not specified.
Public Methods
- `prepare()` -> `PreparedClipRequest`:
Prepare fields and return a fully prepared clip request, required by a
`ClipExtractor`.
- `json()` -> `str`:
Return a JSON string representation of the prepared clip request.
- `verbose_print()` -> `None`:
Print the JSON string to console with a title, without private keys.
Properties:
- `is_prepared` -> `bool`: If the request has been prepared.
- `is_verbose` -> `bool | None`: Return the state of the verbose field.
prepare
Prepare request fields and return a PreparedClipRequest, required by a
ClipExtractor.
Source code in videoxt/requesters.py
PreparedFramesRequest
dataclass
Bases: PreparedBaseRequest
Prepares and stores 'frames' extraction request arguments.
Fields
`video` (Video):
The object containing video metadata used to prepare the request.
`start_time` (float | int | str | None):
Specify the extraction's start time in seconds, or as a string in "HH:MM:SS"
format. Defaults to 0 if not specified.
`stop_time` (float | int | str | None):
Specify the extraction's stop time in seconds, or as a string in "HH:MM:SS"
format. Defaults to the video duration if not specified.
`destdir` (Path | None):
Specify the directory you want to save output to. Defaults to the video's
directory if not specified.
`filename` (str | None):
Specify the name of the extracted file(s). Defaults to the video filename
if not specified.
`verbose` (bool | None):
If True, the prepared request and extraction results will be printed as JSON
to console. Defaults to False if not specified.
`overwrite` (bool | None):
If True, permits overwriting the destination path if the file or directory
already exists. Defaults to False if not specified.
`fps` (float | None):
Override the frames per second (fps) value obtained from `cv2` when reading
the video. This value is used to set the start and stop frames for the
extraction range. This option should be used only in rare cases where `cv2`
fails to accurately read the fps. If not specified, it defaults to the fps
of the video as read by `cv2`.
`image_format` (str | None):
Set the extracted image file format. Defaults to 'jpg' if not specified.
See: `videoxt.constants.SUPPORTED_IMAGE_FORMATS`.
`capture_rate` (int | None):
Capture every Nth video frame. Defaults to 1 if not specified, which
extracts every frame within the extraction range.
`dimensions` (tuple[int, int] | None):
Specify the dimensions (frame width, frame height) of the images. Defaults
to the video dimensions if not specified.
`resize` (float | None):
Resize the dimensions of the images by a factor of `n`. A value of 0.5
will halve the dimensions. If you specify `dimensions`, `resize` will apply
to the dimensions you specify. Defaults to 1.0 if not specified (no change).
`rotate` (int | None):
Rotate the images by `n` degrees. Allowed values: 0, 90, 180 or 270.
Defaults to 0 if not specified (no change).
`monochrome` (bool | None):
If True, apply a black-and-white filter to the images. Defaults to False if
not specified.
`images_expected` (int):
The number of images expected to be written to disk. Not initialized.
Public Methods
- `prepare()` -> `PreparedFramesRequest`:
Prepare fields and return a fully prepared frames request, required by a
`FramesExtractor`.
- `json()` -> `str`:
Return a JSON string representation of the prepared frames request.
- `verbose_print()` -> `None`:
Print the JSON string to console with a title, without private keys.
Properties:
- `is_prepared` -> `bool`: If the request has been prepared.
- `is_verbose` -> `bool | None`: Return the state of the verbose field.
prepare
Prepare request fields and return a PreparedFramesRequest, required by a
FramesExtractor.
Source code in videoxt/requesters.py
PreparedGifRequest
dataclass
Bases: PreparedBaseRequest
Prepares and stores 'gif' extraction request arguments.
Fields
`video` (Video):
The object containing video metadata used to prepare the request.
`start_time` (float | int | str | None):
Specify the extraction's start time in seconds, or as a string in "HH:MM:SS"
format. Defaults to 0 if not specified.
`stop_time` (float | int | str | None):
Specify the extraction's stop time in seconds, or as a string in "HH:MM:SS"
format. Defaults to the video duration if not specified.
`destdir` (Path | None):
Specify the directory you want to save output to. Defaults to the video's
directory if not specified.
`filename` (str | None):
Specify the name of the extracted file(s). Defaults to the video filename
if not specified.
`verbose` (bool | None):
If True, the prepared request and extraction results will be printed as JSON
to console. Defaults to False if not specified.
`overwrite` (bool | None):
If True, permits overwriting the destination path if the file or directory
already exists. Defaults to False if not specified.
`fps` (float | None):
Override the frames per second (fps) value obtained from `cv2` when reading
the video. This value is used to set the start and stop frames for the
extraction range. This option should be used only in rare cases where `cv2`
fails to accurately read the fps. If not specified, it defaults to the fps
of the video as read by `cv2`.
`dimensions` (tuple[int, int] | None):
Specify the dimensions (frame width, frame height) of the gif. Defaults to
the video dimensions if not specified.
`resize` (float | None):
Resize the dimensions of the gif by a factor of `n`. A value of 0.5
will halve the dimensions. If you specify `dimensions`, `resize` will apply
to the dimensions you specify. Defaults to 1.0 if not specified (no change).
`rotate` (int | None):
Rotate the gif by `n` degrees. Allowed values: 0, 90, 180 or 270. Defaults
to 0 if not specified (no change).
`speed` (float | None):
Set the speed of the extracted gif. A value of 0.5 will halve the playback
speed of the gif. Defaults to 1.0 if not specified (no change).
`bounce` (bool | None):
If True, bounce the extracted gif bommerang-style. Defaults to False if
not specified.
`reverse` (bool | None):
If True, reverse the extracted gif. Defaults to False if not specified.
`monochrome` (bool | None):
If True, apply a black-and-white filter to the gif. Defaults to False if
not specified.
Public Methods
- `prepare()` -> `PreparedGifRequest`:
Prepare fields and return a fully prepared gif request, required by a
`GifExtractor`.
- `json()` -> `str`:
Return a JSON string representation of the prepared gif request.
- `verbose_print()` -> `None`:
Print the JSON string to console with a title, without private keys.
Properties:
- `is_prepared` -> `bool`: If the request has been prepared.
- `is_verbose` -> `bool | None`: Return the state of the verbose field.
prepare
Prepare request fields and return a PreparedGifRequest, required by a
GifExtractor.