[FFmpeg-devel] [PATCH] stop av_find_stream_info per packet dts

Michael Niedermayer michaelni
Sun Mar 15 05:16:51 CET 2009


On Sat, Mar 14, 2009 at 08:50:25PM -0700, Baptiste Coudurier wrote:
> Michael Niedermayer wrote:
> > On Sat, Mar 14, 2009 at 08:25:25PM -0700, Baptiste Coudurier wrote:
> >> Hi
> >>
> >> It seems stopping av_find_stream_info by packet duration causes a
> >> problem when a packet with long duration (still image, sub) is very long.
> >>
> >> Scenario:
> >> 1 video stream containing a single image with very long duration
> >> 1 video stream cfr.
> >>
> >> Demuxing will happen in this order since dts are in this order.
> >>
> >> av_find_stream_info will stop after the single image, while the next
> >> packet dts will still be < max analyze duration.
> >>
> >> I'd like your opinion on this I don't know if this might have side effects.
> > 
> > i think the idea is good but dts might not start at 0 (cut mpeg-ps/ts being
> > an example)
> > also before you write a patch that sums dts differences, this can break
> > with timestamp discontinuities.
> > maybe something like using the previous sum of durations for each stream
> > instead of the latest?
> > 
> 
> Like this ?
> 
> -- 
> Baptiste COUDURIER                              GnuPG Key Id: 0x5C1ABAAA
> Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
> checking for life_signs in -lkenny... no
> FFmpeg maintainer                                  http://www.ffmpeg.org

> Index: libavformat/utils.c
> ===================================================================
> --- libavformat/utils.c	(revision 17943)
> +++ libavformat/utils.c	(working copy)
> @@ -2017,6 +2017,7 @@
>      int64_t old_offset = url_ftell(ic->pb);
>      int64_t codec_info_duration[MAX_STREAMS]={0};
>      int codec_info_nb_frames[MAX_STREAMS]={0};
> +    int max_duration_reached;
>  
>      duration_error = av_mallocz(MAX_STREAMS * sizeof(*duration_error));
>      if (!duration_error) return AVERROR(ENOMEM);
> @@ -2172,9 +2173,15 @@
>               (st->codec->codec_id == CODEC_ID_MPEG4 && !st->need_parsing))*/)
>              try_decode_frame(st, pkt->data, pkt->size);
>  
> -        if (st->time_base.den > 0 && av_rescale_q(codec_info_duration[st->index], st->time_base, AV_TIME_BASE_Q) >= ic->max_analyze_duration) {
> +        max_duration_reached = 0;
> +        for(i=0;i<ic->nb_streams;i++) {
> +            st = ic->streams[i];
> +            if (st->time_base.den > 0 && av_rescale_q(codec_info_duration[i], st->time_base, AV_TIME_BASE_Q) >= ic->max_analyze_duration)
> +                max_duration_reached++;
> +        }
> +        if (max_duration_reached == ic->nb_streams)
>              break;
> -        }

no i meant to move the codec_info_duration check before the change that is

if(codec_info_nb_frames[st->index]>1){
    if (st->time_base.den > 0 && av_rescale_q(codec_info_duration[st->index], st->time_base, AV_TIME_BASE_Q) >= ic->max_analyze_duration)
        break;
    codec_info_duration[st->index] += pkt->duration;
}

a possible problem with your suggestion is that it might never reach
the break if some stream simply doesnt contain any (more) packets


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Breaking DRM is a little like attempting to break through a door even
though the window is wide open and the only thing in the house is a bunch
of things you dont want and which you would get tomorrow for free anyway
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090315/535a1375/attachment.pgp>



More information about the ffmpeg-devel mailing list