vikit.postprocessing.subtitles.video_subtitle_renderer

This module provides functionality for rendering styled subtitles onto video clips. It includes classes and utilities for processing subtitle data, splitting subtitles into groups and lines, and rendering them with customizable styles and visual properties.

Overview

Classes

VideoSubtitleRenderer

Renders styled subtitles onto video clips.

Classes

class vikit.postprocessing.subtitles.video_subtitle_renderer.VideoSubtitleRenderer(subtitle_style: SUBTITLE_STYLE, font_path: str, font_size_pt: int, text_color: str, highlight_color: str, bg_color: str, bg_opacity: float, margin_bottom_px: int, margin_h_px: int)

Renders styled subtitles onto video clips.

Usage Example: ```python from vikit.postprocessing.subtitles.video_subtitle_renderer import VideoSubtitleRenderer

renderer = VideoSubtitleRenderer(

subtitle_style=”highlight_spoken_word”, font_path=”/path/to/font.ttf”, font_size_pt=24, text_color=”white”, highlight_color=”yellow”, bg_color=”black”, bg_opacity=0.7, margin_bottom_px=50,

) renderer.render(

src_video_path=”/path/to/input_video.mp4”, dst_video_path=”/path/to/output_video.mp4”, subtitles_srt_path=”/path/to/subtitles.srt”,

)

Overview

Methods

render(src_video_path, dst_video_path, subtitles)

Render a sub-section of the specified subtitles onto the given video, splitting

Members

render(src_video_path: str, dst_video_path: str, subtitles: pysrt.SubRipFile) None

Render a sub-section of the specified subtitles onto the given video, splitting the subtitles into readable chunks if necessary.

Subtitles that are past the end of the video are ignored.

The video with the rendered subtitles is saved to the specified output path.

Parameters:
  • src_video_path -- The path to the input video file.

  • dst_video_path -- The path to the output video file.

  • subtitles -- The subtitles to render.

Attributes

vikit.postprocessing.subtitles.video_subtitle_renderer.BG_PADDING_H_PX = 5
vikit.postprocessing.subtitles.video_subtitle_renderer.SUBTITLE_STYLE
vikit.postprocessing.subtitles.video_subtitle_renderer.WORD_GROUP_DURATION_SEC = 3.0