Opened 6 months ago

Last modified 6 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)

patch.diff (1.7 KB ) - added by typological 6 months ago.

Download all attachments as: .zip

Change History (5)

by typological, 6 months ago

Attachment: patch.diff added

comment:1 by typological, 6 months ago

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.

Last edited 6 months ago by typological (previous) (diff)

comment:2 by Balling, 6 months ago

Status: newopen

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.

Last edited 6 months ago by Balling (previous) (diff)

comment:3 by Balling, 6 months ago

So when will you send a patch?

comment:4 by typological, 6 months ago

Sorry, got busy with others things. Sent.

Note: See TracTickets for help on using tickets.