Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion av/subtitles/subtitle.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def dialogue(self):
i: cython.Py_ssize_t = 0
state: cython.bint = False
ass_text: bytes = self.ass
char, next_char = cython.declare(cython.char)
char, next_char = cython.declare(cython.uchar)
result: bytearray = bytearray()
text_len: cython.Py_ssize_t = len(ass_text)

Expand Down
10 changes: 10 additions & 0 deletions tests/test_subtitles.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,16 @@ def test_subtitle_set_create(self) -> None:
assert len(subtitle) == 1
assert cast(AssSubtitle, subtitle[0]).ass == text

def test_subtitle_dialogue_extended_chars(self) -> None:
"""Test handling of extended UTF-8 characters in subtitle dialogue."""
from av.subtitles.subtitle import SubtitleSet

text = "0,0,Default,,0,0,0,,♪ Hey, hey, hey ♪".encode("utf-8")
subtitle = SubtitleSet.create(text=text, start=0, end=2000, pts=0)
sub = cast(AssSubtitle, subtitle[0])

assert sub.dialogue == "♪ Hey, hey, hey ♪".encode("utf-8")

def test_subtitle_encode_mp4(self) -> None:
"""Test encoding subtitles to MP4 container."""
from av.subtitles.subtitle import SubtitleSet
Expand Down
Loading