spdl.io.get_video_filter_desc¶
- get_video_filter_desc(*, frame_rate: tuple[int, int] | None = None, timestamp: tuple[float, float] | None = None, scale_width: int | None = None, scale_height: int | None = None, scale_algo: str = 'bicubic', scale_mode: str | None = 'pad', crop_width: int | None = None, crop_height: int | None = None, pix_fmt: str | None = 'rgb24', num_frames: int | None = None, pad_mode: str | None = None, filter_desc: str | None = None) str | None [source]¶
Construct FFmpeg filter expression for preprocessing video/image.
- Parameters:
frame_rate – Video: Optional: Change the frame rate.
timestamp – Optional: Trim the video by start and end time. This has to match the value passed to demux functions, which can be retrieved from
spdl.io.VideoPackets.timestamp
.scale_width – Video, Image: Optional: Change the resolution of the frame. If
0
, the original width is used. If-n
, the image is rescaled so that aspect ratio is maintained, then adjusted so that the size is divisible byn
.scale_height – Video, Image: Optional: Change the resolution of the frame. If
0
, the original height is used. If-1
, the image is rescaled so that aspect ratio is maintained, then adjusted so that the size is divisible byn
.scale_algo – Video, Image: Optional: Scaling algorithm. See https://ffmpeg.org/ffmpeg-scaler.html for the available values.
scale_mode –
Video, Image: Optional: How to handle the different aspect ratio when changing the resolution of the frame.
"pad"
: Scale the image so that the entire content of the original image is present with padding."crop"
: Scale the image first to cover the entire region of the output resolution, then crop the excess.None
: The image is scaled as-is.
crop_width – Video, Image: Optional: Crop the image at center (after scaling).
crop_height – Video, Image: Optional: Crop the image at center (after scaling).
pix_fmt – Video, Image: Optional: Change the pixel format. Valid values are (
"gray8"
,"rgba"
,"rgb24"
,"yuv444p"
,"yuv420p"
,"yuv422p"
,"nv12"
).num_frames – Video: Optional: Fix the number of output frames by dropping the exceeding frames or padding. The default behavior when padding is to repeat the last frame. This can be changed to fixed color frame with
pad_mode
argument.pad_mode – Video, Optional: Change the padding frames to the given color.
- Returns:
Filter description.