From 3eb5e50f0395b7b5a3f4f2a8e17dd4b5b8ef4068 Mon Sep 17 00:00:00 2001 From: Touyu Pan Date: Thu, 9 Nov 2023 17:49:44 +0800 Subject: [PATCH] pre-commit --- src/ffmpeg_media_type/utils/ffmpeg.py | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/src/ffmpeg_media_type/utils/ffmpeg.py b/src/ffmpeg_media_type/utils/ffmpeg.py index 12956ed..16e93e7 100644 --- a/src/ffmpeg_media_type/utils/ffmpeg.py +++ b/src/ffmpeg_media_type/utils/ffmpeg.py @@ -87,9 +87,8 @@ def _parse_muxer_info(content: str) -> dict[str, Any]: return output -def _get_muxer_info( - version: str, flag: str, codec: str, description: str -) -> FFMpegSupport: +def _get_muxer_info(version: str, flag: str, codec: str, description: str) -> FFMpegSupport: + muxer_info = { "common_exts": [], "mime_type": "", @@ -130,9 +129,7 @@ def _get_muxer_info( def _extract_file_format(content: str) -> list[tuple[str, str, str]]: - re_ffmpeg_support_file_format = re.compile( - r"(?P[DE]+)[\s]+(?P[\w\d,]+)[\s]+(?P[^\n]*)" - ) + re_ffmpeg_support_file_format = re.compile(r"(?P[DE]+)[\s]+(?P[\w\d,]+)[\s]+(?P[^\n]*)") output = [] for iline in content.split("\n"): support_infos = re_ffmpeg_support_file_format.findall(iline) @@ -143,9 +140,7 @@ def _extract_file_format(content: str) -> list[tuple[str, str, str]]: def list_support_format(version: str) -> list[FFMpegSupport]: - content = call( - ["docker", "run", f"jrottenberg/ffmpeg:{version}-scratch", "-formats"] - ) + content = call(["docker", "run", f"jrottenberg/ffmpeg:{version}-scratch", "-formats"]) # print(f"FFMpeg version: {version}") @@ -160,9 +155,7 @@ def list_support_format(version: str) -> list[FFMpegSupport]: def _cache_file(version: str) -> str: major_minor_version = get_ffmpeg_version("minor") - return str( - Path(__file__).parent.parent / "data" / f"ffmpeg-{major_minor_version}.json" - ) + return str(Path(__file__).parent.parent / "data" / f"ffmpeg-{major_minor_version}.json") def _generate_cache(version: str) -> None: @@ -255,17 +248,11 @@ def get_ffmpeg_version(mode: Literal["major", "minor", "patch"] = "patch") -> st raise RuntimeError(f"FFmpeg version not found {result}") from e -def animated_webp_support( - func: Callable[[str], FFProbeInfo] -) -> Callable[[str], FFProbeInfo]: +def animated_webp_support(func: Callable[[str], FFProbeInfo]) -> Callable[[str], FFProbeInfo]: @wraps(func) def wrapper(uri: str) -> FFProbeInfo: probe_info = func(uri) - if ( - probe_info.streams[0].height == 0 - and probe_info.streams[0].width == 0 - and probe_info.format.format_name == "webp_pipe" - ): + if probe_info.streams[0].height == 0 and probe_info.streams[0].width == 0 and probe_info.format.format_name == "webp_pipe": webpmux_command = get_webpmux() + ["-get", "frame", "1", uri, "-o", uri] call(webpmux_command) return func(uri)