Skip to content

Commit

Permalink
pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Touyu-Pan committed Nov 9, 2023
1 parent bbe1a44 commit 3eb5e50
Showing 1 changed file with 7 additions and 20 deletions.
27 changes: 7 additions & 20 deletions src/ffmpeg_media_type/utils/ffmpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down Expand Up @@ -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<flag>[DE]+)[\s]+(?P<codec>[\w\d,]+)[\s]+(?P<description>[^\n]*)"
)
re_ffmpeg_support_file_format = re.compile(r"(?P<flag>[DE]+)[\s]+(?P<codec>[\w\d,]+)[\s]+(?P<description>[^\n]*)")
output = []
for iline in content.split("\n"):
support_infos = re_ffmpeg_support_file_format.findall(iline)
Expand All @@ -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}")

Expand All @@ -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:
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3eb5e50

Please sign in to comment.