sleap.io.videowriter#

Module for writing avi/mp4 videos.

Usage:

> writer = VideoWriter.safe_builder(filename, height, width, fps)
> writer.add_frame(img)
> writer.close()
class sleap.io.videowriter.VideoWriter(filename, height, width, fps)[source]#

Abstract base class for writing avi/mp4 videos.

static can_use_ffmpeg()[source]#

Check if ffmpeg is available for writing videos.

static safe_builder(filename, height, width, fps)[source]#

Builds VideoWriter based on available dependencies.

class sleap.io.videowriter.VideoWriterImageio(filename, height, width, fps, crf: int = 21, preset: str = 'superfast')[source]#

Writes video using imageio as a wrapper for ffmpeg.

filename#

Path to video file to save to.

height#

Height of movie frames.

width#

Width of movie frames.

fps#

Playback framerate to save at.

crf#

Compression rate factor to control lossiness of video. Values go from 2 to 32, with numbers in the 18 to 30 range being most common. Lower values mean less compressed/higher quality.

preset#

Name of the libx264 preset to use (default: “superfast”).

class sleap.io.videowriter.VideoWriterOpenCV(filename, height, width, fps)[source]#

Writes video using OpenCV as wrapper for ffmpeg.