diff --git a/vardefunc/types.py b/vardefunc/types.py index 7e5dd38..8fadd53 100644 --- a/vardefunc/types.py +++ b/vardefunc/types.py @@ -1,6 +1,7 @@ from __future__ import annotations from enum import Enum, IntEnum +from fractions import Fraction from os import PathLike from typing import (Any, Callable, Dict, List, Literal, Optional, Sequence, Tuple, TypeVar, Union, cast) @@ -9,6 +10,7 @@ from numpy import int8, int16, int32, uint8, uint16, uint32 from numpy.lib.index_tricks import CClass as NP_CClass from numpy.typing import NDArray +from pytimeconv import Convert from vapoursynth import VideoFormat, VideoNode from vsutil import Dither @@ -250,6 +252,9 @@ def __new__(cls, x: int, /, dup: int = 1) -> DuplicateFrame: df.dup = dup return df + def to_samples(self, ref_fps: Fraction, sample_rate: int) -> DuplicateFrame: + return DuplicateFrame(Convert.f2samples(int(self), ref_fps, sample_rate), dup=self.dup) + def __repr__(self) -> str: return f''