[MPlayer-dev-eng] [PATCH] Read normal duration when demuxing subtitles through lavf

Alexander Strasser eclipse7 at gmx.net
Fri Jul 27 11:14:55 CEST 2012


Hi Philip!

Philip Langdale wrote:
> Currently, mplayer only looks at convergence_duration when
> using lavf to demux subtitles. Some containers use the
> normal duration field for subtitles (eg: mov_text), so we
> should read that if the convergence_duration is not used.

  It is a bit messy, but as this is the state of things in 
FFmpeg there is not much else we can do about it now.

> Index: libmpdemux/demux_lavf.c
> ===================================================================
> --- libmpdemux/demux_lavf.c	(revision 35050)
> +++ libmpdemux/demux_lavf.c	(working copy)
> @@ -653,9 +653,14 @@
>          priv->last_pts= dp->pts * AV_TIME_BASE;
>          // always set endpts for subtitles, even if AV_PKT_FLAG_KEY is not set,
>          // otherwise they will stay on screen to long if e.g. ASS is demuxed from mkv
> -        if((ds == demux->sub || (pkt.flags & AV_PKT_FLAG_KEY)) &&
> -           pkt.convergence_duration > 0)
> -            dp->endpts = dp->pts + pkt.convergence_duration * av_q2d(priv->avfc->streams[id]->time_base);
> +        if (ds == demux->sub || (pkt.flags & AV_PKT_FLAG_KEY)) {
> +            uint64_t duration = 0;
> +            if (pkt.convergence_duration > 0)
> +                duration = pkt.convergence_duration;
> +            else if (pkt.duration > 0)
> +                duration = pkt.duration;
> +            dp->endpts = dp->pts + duration * av_q2d(priv->avfc->streams[id]->time_base);
> +        }
>      }

  Why do you use uint64_t here? The fields seem to be int64_t and int
in FFmpeg.

  I assume the demuxers that use pkt.convergence_duration set it
exclusively and that there is no common code that would attempt to set
pkt.duration, as that would alter the meaning of the code.

  Looks good to me otherwise.

  Alexander


More information about the MPlayer-dev-eng mailing list