Writer
- class plugins.convert.writer.ffmpeg.Writer(output_folder: str, total_count: int, frame_ranges: list[tuple[int, int]] | None, source_video: str, **kwargs)
Bases:
OutputVideo output writer using pyAV.
- Parameters:
output_folder (str) – The folder to save the output video to
total_count (int) – The total number of frames to be converted
frame_ranges (list or
None) – List of tuples for starting and end values of each frame range to be converted orNoneif all frames are to be convertedsource_video (str) – The full path to the source video for obtaining fps and audio
kwargs (dict) – Any additional standard
plugins.convert.writer._base.Outputkey word arguments.
Attributes Summary
Whether the writer outputs a stream or a series images.
Override if the plugin can output an alpha channel and the user configuration option is set to use it.
Methods Summary
cache_frame(filename, image)Add the incoming converted frame to the cache ready for writing out.
close()Close the ffmpeg writer
get_output_filename(filename, extension[, ...])Obtain the full path for the output file, including the correct extension, for the given input filename.
pre_encode(image, **kwargs)Some writer plugins support the pre-encoding of images prior to saving out.
write(filename, image)Frames come from the pool in arbitrary order, so frames are cached for writing out in the correct order.
Attributes Documentation
- is_stream
Whether the writer outputs a stream or a series images.
Writers that write to a stream have a frame_order parameter to dictate the order in which frames should be written out (eg. gif/ffmpeg)
- output_alpha
Override if the plugin can output an alpha channel and the user configuration option is set to use it. Default
False
Methods Documentation
- cache_frame(filename: str, image: ndarray) None
Add the incoming converted frame to the cache ready for writing out.
Used for ffmpeg and gif writers to ensure that the frames are written out in the correct order.
- Parameters:
filename (str) – The filename of the incoming frame, where the frame index can be extracted from
image (ndarray) – The converted frame corresponding to the given filename
- Return type:
None
- close() None
Close the ffmpeg writer
- Return type:
None
- get_output_filename(filename: str, extension: str, separate_mask: bool = False) list[str]
Obtain the full path for the output file, including the correct extension, for the given input filename.
- Parameters:
filename (str) – The input frame filename to generate the output file name for
extension (str) – The extension to use for the output file
separate_mask (bool) –
Trueif the mask should be saved out to a sub-folder otherwiseFalse
- Returns:
The full path for the output converted frame to be saved to in position 1. The full path
for the mask to be output to in position 2 (if requested)
- Return type:
list[str]
- pre_encode(image: ndarray, **kwargs) Any
Some writer plugins support the pre-encoding of images prior to saving out. As patching is done in multiple threads, but writing is done in a single thread, it can speed up the process to do any pre-encoding as part of the converter process.
If the writer supports pre-encoding then override this to pre-encode the image in
lib.convertto speed up saving.- Parameters:
image (ndarray) – The converted image that is to be run through the pre-encoding function
- Returns:
If
Nonethen the writer does not support pre-encoding, otherwise return output of theplugin specific pre-encode function
- Return type:
Any
- write(filename: str, image: npt.NDArray[np.uint8]) None
Frames come from the pool in arbitrary order, so frames are cached for writing out in the correct order.
- Parameters:
filename (str) – The incoming frame filename.
image (
numpy.ndarray) – The converted image to be written
- Return type:
None
- close() None
Close the ffmpeg writer
- Return type:
None
- write(filename: str, image: npt.NDArray[np.uint8]) None
Frames come from the pool in arbitrary order, so frames are cached for writing out in the correct order.
- Parameters:
filename (str) – The incoming frame filename.
image (
numpy.ndarray) – The converted image to be written
- Return type:
None