upsies.jobs.screenshots

Create screenshots from video file(s)

Classes

class upsies.jobs.screenshots.ScreenshotsJob(*, home_directory=None, cache_directory=None, cache_id='', ignore_cache=False, no_output_is_ok=False, hidden=False, autostart=True, guaranteed=False, precondition=None, prejobs=(), callbacks={}, **kwargs)[source]

Bases: JobBase

Create screenshots from video file(s) or Playlist instances

To get Playlists, this job relies on a PlaylistsJob instance to be available via a job siblings named “playlists”.

This job adds the following signals to signal:

screenshots_total

Emitted before screenshots are created. Registered callbacks get the total number of screenshots as a positional argument.

cache_id = None
initialize(*, content_path, precreated=(), exclude_files=(), timestamps=(), count=0, from_all_videos=False, optimize='default', tonemap=False)[source]

Set internal state

Parameters:
  • content_path (str) – Path to file or directory or sequence of paths

  • precreated

    Sequence of paths of already existing screenshots

    These do not count towards the wanted number of screenshots. count screenshots are created in addition to any precreated screenshots.

  • exclude_files

    Sequence of glob patterns (str) and re.Pattern objects (return value from re.compile()) that are matched against the relative path beneath each source

    Glob patterns are matched case-insensitively.

    Note

    Non-video files and stuff like Sample.mkv are always excluded by fs.find_main_videos().

  • timestamps (sequence of "[[H+:]M+:]S+" strings or seconds) – Screenshot positions in the video

  • count

    Number of screenshots to make or callable() that returns how many screenshots to make

    If this is a callable (synchronous or asynchronous), it is called when this job is start()ed, and count is 0 until then.

  • from_all_videos (bool) –

    Whether to take count screenshots from each video file or only from the first video

    See fs.find_main_videos() for more information.

  • optimize

    level argument for optimize()

    If this is "default", missing optimization dependencies are silently ignored.

  • tonemap (bool) – Whether to apply tonemap algorithm for HDR screenshots

If timestamps and count are not given, screenshot positions are picked at even intervals. If count is larger than the number of timestamps, more timestamps are added.

async run()[source]

Execute subprocesses for screenshot creation and optimization

terminate(reason=None)[source]

Stop screenshot creation and optimization subprocesses before terminating the job

property exit_code

0 if all screenshots were made, 1 otherwise, None if unfinished

property exclude_files

Sequence of glob and regex patterns to exclude

See initialize() for more information.

Setting this property when this job is_started raises RuntimeError.

property from_all_videos

Whether to make screenshots from all video files or only the first

Setting this property when this job is_started raises RuntimeError.

property count

How many screenshots to make per video file

Setting this property when this job is_started raises RuntimeError.

property timestamps

Specific list of timestamps to make

Setting this property when this job is_started raises RuntimeError.

property screenshots_total

Total number of screenshots to make

Note

This is -1 until the subprocess that creates the screenshots is executed and determined the number of screenshots.

property screenshots_created

Total number of screenshots made so far

property screenshots_by_file

Map video file paths to sequences of generated screenshot file paths so far

add_output(screenshot_filepath, video_filepath, source)[source]

Populate output and screenshots_by_file and bump screenshots_created

Parameters:
  • screenshots_filepath – Path to screenshot file

  • video_filepath – Path to video file screenshot_filepath is from

  • source – Path to release directory, Playlist instance or the same as video_filepath