mendevi.convert.filter_best_order¶
- mendevi.convert.filter_best_order(video: Path | str, additional_filter: str, fps: Fraction | None, pix_fmt: str | None, resolution: tuple[int, int] | None) str[source]¶
Generate the ffmpeg filter command that performs this conversion.
Parameters¶
- videopathlike
The video to be filtered. It is required to know the relevant filters and find the best possible order.
- additional_filterstr
The additional video filter, (can be an empty string).
- fpsfractions.Fraction, optional
The new framerate.
- pix_fmtstr, optional
The new pixel format, it has to match the regex
yuv4[24][024]p(?:10le|12le)?.- resolutiontuple[int, int], optional
The new (height, width) video shape.
Returns¶
- filterstr
The ffmpeg video filter argument. It can be an empty string if nothing has to be done.
Examples¶
>>> from fractions import Fraction >>> import cutcutcodec >>> from mendevi.convert import filter_best_order >>> video = cutcutcodec.utils.get_project_root() / "media" / "video" / "intro.webm" >>> filter_best_order(video, additional_filter="", fps=None, pix_fmt=None, resolution=None) '' >>> filter_best_order( ... video, ... additional_filter="", ... fps=Fraction(60000, 1001), ... pix_fmt="yuv420p10le", ... resolution=(1080, 1920), ... ) 'scale=h=1080:w=1920:sws_flags=bicubic,format=yuv420p10le,fps=60000/1001' >>> filter_best_order( ... video, ... additional_filter="", ... fps=Fraction(24000, 1001), ... pix_fmt="yuv420p", ... resolution=(480, 720), ... ) 'fps=24000/1001,scale=h=480:w=720:sws_flags=bicubic' >>>