[FFmpeg-devel] [PATCH 3/3] avformat/assdec: do not drop duplicate subtitles

wm4 nfxjfg at googlemail.com
Sun Sep 20 23:27:36 CEST 2015


On Sun, 20 Sep 2015 22:59:56 +0200
Clément Bœsch <u at pkh.me> wrote:

> On Sun, Sep 20, 2015 at 04:12:38PM +0200, wm4 wrote:
> > Duplicates are perfectly legitimate with this format.
> > ---
> >  libavformat/assdec.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/libavformat/assdec.c b/libavformat/assdec.c
> > index 5423c03..a9a2efa 100644
> > --- a/libavformat/assdec.c
> > +++ b/libavformat/assdec.c
> > @@ -125,6 +125,8 @@ static int ass_read_header(AVFormatContext *s)
> >      av_bprint_init(&line,   0, AV_BPRINT_SIZE_UNLIMITED);
> >      av_bprint_init(&rline,  0, AV_BPRINT_SIZE_UNLIMITED);
> >  
> > +    ass->q.keep_duplicates = 1;
> > +
> >      for (;;) {
> >          int64_t pos = get_line(&line, &tr);
> >          int64_t ts_start = AV_NOPTS_VALUE;
> 
> I'm not sure why ASS in particular but I guess it's fine, feel free to
> push
> 

Because ASS is a very well-defined format with precise semantics. Now
before everyone who really knows ASS breaks out in laughter: the format
is defined by a single software (VSFilter), and any deviations from
VSFilter can be considered bugs. An ASS consumer can't just make up its
own semantics. (I've had someone test this, and duplicate lines are
indeed rendered "stacked" in VSFilter and libass.)

On the other hand, other formats are very "loose" and it's better to
eliminate duplicates that are just artifacts caused by buggy muxers and
editors.

So I think this patch is very well justified.


More information about the ffmpeg-devel mailing list