Skip to content

Commit

Permalink
Merge pull request jbsparrow#417 from datawhores/video-props
Browse files Browse the repository at this point in the history
Fix:  solution for average frames being zero
  • Loading branch information
datawhores authored Dec 31, 2024
2 parents ac402a7 + f46c5fe commit ef75bb0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cyberdrop_dl/utils/sorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ def sort_video(self, file: Path, base_name: str) -> None:
"""Sorts a video file into the sorted video folder."""
if not self.video_format:
return

codec = duration = fps = height = resolution = width = None

with contextlib.suppress(RuntimeError, CalledProcessError):
Expand All @@ -165,7 +166,11 @@ def sort_video(self, file: Path, base_name: str) -> None:

codec = props.get("codec_name")
duration = int(float(props.get("duration", 0))) or None
fps = float(Fraction(props.get("avg_frame_rate", 0))) or None
fps = (
float(Fraction(props.get("avg_frame_rate", 0)))
if str(props.get("avg_frame_rate", 0)) not in {"0/0", "0"}
else None
)
if fps:
fps = int(fps) if fps.is_integer() else f"{fps:.2f}"

Expand Down

0 comments on commit ef75bb0

Please sign in to comment.