Skip to content

Commit

Permalink
types: add samples conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
Ichunjo committed Oct 29, 2021
1 parent 1b569ba commit 4c8d996
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions vardefunc/types.py
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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

Expand Down Expand Up @@ -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'<DuplicateFrame object: \'x:{super().__repr__()}, dup:{self.dup}\'>'

Expand Down

0 comments on commit 4c8d996

Please sign in to comment.