Opened 13 months ago
Last modified 12 months ago
#10659 open defect
Converting to ass subtitles results in overlap.
Reported by: | typological | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | undetermined |
Version: | unspecified | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
Summary of the bug:
When converting to ass subtitles from srt or vtt, there are some overlaps that weren't there, probably due to wrong rounding.
How to reproduce:
% ffmpeg -i sub.srt sub.ass ffmpeg version n6.0 Copyright (c) 2000-2023 the FFmpeg developers built with gcc 13.2.1 (GCC) 20230801
sub.srt (input):
1 00:00:29,566 --> 00:00:34,332 test 1 2 00:00:34,333 --> 00:00:38,833 test 2 3 00:00:38,833 --> 00:00:39,833 test 3
sub.ass (actual output):
... [Events] Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text Dialogue: 0,0:00:29.57,0:00:34.34,Default,,0,0,0,,test 1 Dialogue: 0,0:00:34.33,0:00:38.83,Default,,0,0,0,,test 2 Dialogue: 0,0:00:38.83,0:00:39.83,Default,,0,0,0,,test 3
sub.ass (expected output):
... [Events] Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text Dialogue: 0,0:00:29.57,0:00:34.33,Default,,0,0,0,,test 1 Dialogue: 0,0:00:34.33,0:00:38.83,Default,,0,0,0,,test 2 Dialogue: 0,0:00:38.83,0:00:39.83,Default,,0,0,0,,test 3
(note the 34, that should've been 33, at the first Dialogue line)
the same happens if I use sub.vtt as input with the command
ffmpeg -i sub.vtt sub.ass
with sub.vtt (input)
WEBVTT Kind: captions Language: en 00:00:29.566 --> 00:00:34.332 test 1 00:00:34.333 --> 00:00:38.833 test 2 00:00:38.833 --> 00:00:39.833 test 3
Attachments (1)
Change History (5)
by , 13 months ago
Attachment: | patch.diff added |
---|
comment:2 by , 13 months ago
Status: | new → open |
---|
00:00:34,332 is smaller than 00:00:34,333. That means that 0:00:34.34 should be smaller than 0,0:00:34.33, but it is not. It should probably be 0:00:34.32 though, smaller. But your idea is 0:00:34.33, looks normal.
I'm new to ffmpeg's codebase, I know the following patch is horrible, but it's a start.
Problem seems to be the following: ASS uses only 10ms precision. AVPackets store start time and duration and not end time; in this case, the first packet had a duration of 4766ms which gets rounded to 4770ms when converting to the ASS timebase. The start time also gets rounded upwards and this adds a + 1 to the end time that would not have happened had the end time been rounded to 10ms itself.
This patch makes ASS subtitles a special case, and uses a rescale_ts function that rounds duration + start, then subtracts the start.
not sure what are the possible issues that could appear from this change.