22
33from typing import BinaryIO , Any , TypeAlias , Literal
44from collections .abc import Sequence
5- import json , fractions , re
5+ import json , re
6+ from fractions import Fraction
67from functools import lru_cache
78
89from .path import ffprobe , PIPE
@@ -39,7 +40,7 @@ def try_conv(v):
3940 v = _re_ratio .sub (r"\1/\2" , v )
4041
4142 try :
42- return fractions . Fraction (v )
43+ return Fraction (v )
4344 except :
4445 return v
4546
@@ -491,7 +492,7 @@ def video_streams_basic(
491492 )
492493
493494 def adjust (res ):
494- tb = fractions . Fraction (res .pop ("time_base" , "1" ))
495+ tb = Fraction (res .pop ("time_base" , "1" ))
495496 if "start_pts" in res :
496497 res ["start_time" ] = float (res .pop ("start_pts" , 0 ) * tb )
497498
@@ -505,7 +506,7 @@ def adjust(res):
505506
506507 fsa = res .pop ("avg_frame_rate" , "" )
507508 fsr = res .pop ("r_frame_rate" , "0" )
508- frame_rate = fractions . Fraction (fsa if fsa and fsa != "0/0" else fsr )
509+ frame_rate = Fraction (fsa if fsa and fsa != "0/0" else fsr )
509510 if not entries or "frame_rate" in entries :
510511 res ["frame_rate" ] = frame_rate
511512
@@ -697,8 +698,8 @@ def _video_info(
697698 str | None ,
698699 int | None ,
699700 int | None ,
700- fractions . Fraction | Literal ["0/0" ] | None ,
701- fractions . Fraction | None ,
701+ Fraction | Literal ["0/0" ] | None ,
702+ Fraction | None ,
702703]:
703704 "returns (pix_fmt, width, height, avg_frame_rate, r_frame_rate) of the specified url/stream"
704705
@@ -813,9 +814,7 @@ def frames(
813814
814815 if accurate_time and has_time :
815816
816- time_bases = {
817- d ["index" ]: fractions .Fraction (d ["time_base" ]) for d in res ["streams" ]
818- }
817+ time_bases = {d ["index" ]: Fraction (d ["time_base" ]) for d in res ["streams" ]}
819818
820819 if not pick_entries :
821820 time_entries = [e for e in out [0 ].keys () if e .endswith ("_time" )]
0 commit comments