Skip to content

Commit

Permalink
dev(narugo): optional min frame interval settings
Browse files Browse the repository at this point in the history
  • Loading branch information
narugo1992 committed Jan 24, 2024
1 parent 041f8bb commit 568db8a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions waifuc/source/video.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import glob
import logging
import os
from typing import Iterator
from typing import Iterator, Optional
from urllib.error import HTTPError

from tqdm.auto import tqdm
Expand All @@ -24,7 +24,7 @@


class VideoSource(NamedDataSource):
def __init__(self, video_file, min_frame_interval: float = _DEFAULT_MIN_FRAME_INTERVAL):
def __init__(self, video_file, min_frame_interval: Optional[float] = _DEFAULT_MIN_FRAME_INTERVAL):
if not _VIDEO_EXTRACT_AVAILABLE:
raise ImportError(f'pyav not installed, {self.__class__.__name__} is unavailable. '
f'Please install this with `pip install git+https://github.com/deepghs/waifuc.git@main#egg=waifuc[video]` to solve this problem.')
Expand All @@ -50,7 +50,8 @@ def _iter(self) -> Iterator[ImageItem]:
for i, frame in enumerate(tqdm(
container.decode(stream),
desc=f'Video Extracting - {os.path.basename(self.video_file)}')):
if _last_frame_time is None or frame.time - _last_frame_time >= self.min_frame_interval:
if self.min_frame_interval is None or \

Check warning on line 53 in waifuc/source/video.py

View check run for this annotation

Codecov / codecov/patch

waifuc/source/video.py#L53

Added line #L53 was not covered by tests
_last_frame_time is None or frame.time - _last_frame_time >= self.min_frame_interval:
filebody, _ = os.path.splitext(os.path.basename(self.video_file))
meta = {

Check warning on line 56 in waifuc/source/video.py

View check run for this annotation

Codecov / codecov/patch

waifuc/source/video.py#L55-L56

Added lines #L55 - L56 were not covered by tests
'video_file': self.video_file,
Expand Down

0 comments on commit 568db8a

Please sign in to comment.