lvsfunc.render

Clip rendering helpers.

lvsfunc.render.clip_async_render(clip[, ...])

Render a clip by requesting frames asynchronously using clip.get_frame_async, providing for callback with frame number and frame object.

lvsfunc.render.find_scene_changes(clip[, mode])

Generate a list of scene changes (keyframes).

lvsfunc.render.get_render_progress()

Returns render progress.

class lvsfunc.render.RenderContext(clip, queued)

Bases: object

Contains info on the current render operation.

clip: vapoursynth.VideoNode
condition: threading.Condition
frames: Dict[int, vapoursynth.VideoFrame]
frames_rendered: int
queued: int
timecodes: List[float]
lvsfunc.render.clip_async_render(clip, outfile=None, timecodes=None, progress='Rendering clip...', callback=None)

Render a clip by requesting frames asynchronously using clip.get_frame_async, providing for callback with frame number and frame object.

This is mostly a re-implementation of VideoNode.output, but a little bit slower since it’s pure python. You only really need this when you want to render a clip while operating on each frame in order or you want timecodes without using vspipe.

Parameters
  • clip (VideoNode) – Clip to render.

  • outfile (Optional[BinaryIO]) – Y4MPEG render output BinaryIO handle. If None, no Y4M output is performed. Use sys.stdout.buffer for stdout. (Default: None)

  • timecodes (Optional[TextIO]) – Timecode v2 file TextIO handle. If None, timecodes will not be written.

  • progress (str | None) – String to use for render progress display. If empty or None, no progress display.

  • callback (Union[Callable[[int, VideoFrame], None], List[Callable[[int, VideoFrame], None]], None]) – Single or list of callbacks to be performed. The callbacks are called when each sequential frame is output, not when each frame is done. Must have signature Callable[[int, vs.VideoNode], None] See lvsfunc.comparison.diff() for a use case (Default: None).

Return type

List[float]

Returns

List of timecodes from rendered clip.

lvsfunc.render.find_scene_changes(clip, mode=SceneChangeMode.WWXD)

Generate a list of scene changes (keyframes).

Dependencies:

  • vapoursynth-wwxd

  • vapoursynth-scxvid (Optional: scxvid mode)

Parameters
  • clip (VideoNode) – Clip to search for scene changes. Will be rendered in its entirety.

  • mode (SceneChangeMode) –

    Scene change detection mode:

    • WWXD: Use wwxd

    • SCXVID: Use scxvid

    • WWXD_SCXVID_UNION: Union of wwxd and sxcvid (must be detected by at least one)

    • WWXD_SCXVID_INTERSECTION: Intersection of wwxd and scxvid (must be detected by both)

Return type

List[int]

Returns

List of scene changes.

lvsfunc.render.finish_frame(outfile, timecodes, ctx)

Output a frame.

Parameters
  • outfile (BinaryIO | None) – Output IO handle for Y4MPEG

  • timecodes (TextIO | None) – Output IO handle for timecodesv2

  • ctx (RenderContext) – Rendering context

Return type

None

lvsfunc.render.get_render_progress()

Returns render progress.

Return type

Progress