Subtitles¶
- class av.subtitles.stream.SubtitleStream[source]¶
Bases:
Stream- decode(packet: Packet | None = None) list[AssSubtitle] | list[BitmapSubtitle][source]¶
- decode2(packet: Packet) SubtitleSet | None[source]¶
- class av.subtitles.subtitle.SubtitleSet¶
Bases:
objectA
SubtitleSetcan contain manySubtitleobjects.Wraps AVSubtitle.
- static create(bytes text: bytes, int start: int, int end: int, int pts: int = 0, int subtitle_format: int = 1) 'SubtitleSet'¶
Create a SubtitleSet for encoding.
- Args:
- text: The subtitle text in ASS dialogue format
(e.g. b”0,0,Default,,0,0,0,,Hello World”)
start: Start display time as offset from pts (typically 0) end: End display time as offset from pts (i.e., duration) pts: Presentation timestamp in stream time_base units subtitle_format: Subtitle format (default 1 for text)
- Note:
All timing values should be in stream time_base units. For MKV (time_base=1/1000), units are milliseconds. For MP4 (time_base=1/1000000), units are microseconds.
- Returns:
A SubtitleSet ready for encoding
- end_display_time¶
- format¶
- pts¶
Same as packet pts, in av.time_base.
- rects¶
- start_display_time¶
- class av.subtitles.subtitle.Subtitle¶
Bases:
objectAn abstract base class for each concrete type of subtitle. Wraps AVSubtitleRect
- type¶
- class av.subtitles.subtitle.AssSubtitle¶
Bases:
SubtitleRepresents an ASS/Text subtitle format, as opposed to a bitmap Subtitle format.
- ass¶
Returns the subtitle in the ASS/SSA format. Used by the vast majority of subtitle formats.
- dialogue¶
Extract the dialogue from the ass format. Strip comments.
- text¶
Rarely used attribute. You’re probably looking for dialogue.