vikit.postprocessing.subtitles.video_subtitle_renderer ====================================================== .. py:module:: vikit.postprocessing.subtitles.video_subtitle_renderer .. autoapi-nested-parse:: 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 -------- .. list-table:: Classes :header-rows: 0 :widths: auto :class: summarytable * - :py:obj:`VideoSubtitleRenderer ` - Renders styled subtitles onto video clips. .. list-table:: Attributes :header-rows: 0 :widths: auto :class: summarytable * - :py:obj:`BG_PADDING_H_PX ` - \- * - :py:obj:`SUBTITLE_STYLE ` - \- * - :py:obj:`WORD_GROUP_DURATION_SEC ` - \- Classes ------- .. py:class:: 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", ) ``` .. rubric:: Overview .. list-table:: Methods :header-rows: 0 :widths: auto :class: summarytable * - :py:obj:`render `\ (src_video_path, dst_video_path, subtitles) - Render a sub-section of the specified subtitles onto the given video, splitting .. rubric:: Members .. py:method:: 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. :param src_video_path: The path to the input video file. :param dst_video_path: The path to the output video file. :param subtitles: The subtitles to render. Attributes ---------- .. py:data:: BG_PADDING_H_PX :value: 5 .. py:data:: SUBTITLE_STYLE .. py:data:: WORD_GROUP_DURATION_SEC :value: 3.0