mendevi.convert.get_convert_cmd
- mendevi.convert.get_convert_cmd(video: Path | str, fps: Fraction | None, pix_fmt: str | None, resolution: tuple[int, int] | None) str[source]
Generates 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.
- 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 (heigh, 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 get_convert_cmd >>> media = cutcutcodec.utils.get_project_root().parent / "media" / "video" / "intro.webm" >>> get_convert_cmd(media, fps=None, pix_fmt=None, resolution=None) '' >>> get_convert_cmd( ... media, fps=Fraction(60000, 1001), pix_fmt="yuv420p10le", resolution=(1080, 1920) ... ) 'scale=h=1080:w=1920:sws_flags=bicubic,format=yuv420p10le,fps=60000/1001' >>> get_convert_cmd(media, fps=Fraction(24000, 1001), pix_fmt="yuv420p", resolution=(480, 720)) 'fps=24000/1001,scale=h=480:w=720:sws_flags=bicubic' >>>