[FFmpeg-devel] [PATCH] movie video source

Stefano Sabatini stefano.sabatini-lala
Sun Jan 30 00:32:25 CET 2011


On date Saturday 2011-01-29 17:25:41 -0500, Alexander Strange encoded:
> 
> On Jan 29, 2011, at 7:41 AM, Stefano Sabatini wrote:
> 
> > On date Friday 2011-01-28 20:49:55 +0100, Michael Niedermayer encoded:
[...]
> >>> +static int movie_get_frame(AVFilterLink *outlink)
> >>> +{
> >>> +    MovieContext *movie = outlink->src->priv;
> >>> +    AVPacket pkt;
> >>> +    int ret, frame_decoded;
> >>> +
> >>> +    if (movie->is_done == 1)
> >>> +        return 0;
> >>> +
> >>> +    while ((ret = av_read_frame(movie->format_ctx, &pkt)) >= 0) {
> >>> +        // Is this a packet from the video stream?
> >>> +        if (pkt.stream_index == movie->stream_index) {
> >>> +            avcodec_decode_video2(movie->codec_ctx, movie->frame, &frame_decoded, &pkt);
> >>> +
> >>> +            if (frame_decoded) {
> >>> +                /* FIXME: avoid the memcpy */
> >>> +                movie->picref = avfilter_get_video_buffer(outlink, AV_PERM_WRITE | AV_PERM_PRESERVE |
> >>> +                                                          AV_PERM_REUSE2, outlink->w, outlink->h);
> >>> +                av_image_copy(movie->picref->data, movie->picref->linesize,
> >>> +                              movie->frame->data,  movie->frame->linesize,
> >>> +                              movie->picref->format, outlink->w, outlink->h);
> >>> +
> >>> +                if        (movie->decoder_reorder_pts == 1) {
> >>> +                    movie->picref->pts = movie->frame->pkt_pts;
> >>> +                } else if (movie->decoder_reorder_pts == 0) {
> >> 
> >>> +                    movie->picref->pts = pkt.dts;
> >> 
> >> movie->frame->pkt_dts
> >> 
> > 
> > /* FIXME: use a PTS correction mechanism as that in 
> >   ffplay.c when an API will be available */
> > /* use pkt.dts if pts is not available */
> > movie->picref->pts = movie->frame->pkt_pts == AV_NOPTS_VALUE ?
> >    pkt.dts : movie->frame->pkt_pts;
> 
> Like he said, it's movie->frame->pkt_dts now, not pkt.dts. No
> difference yet, but pkt.dts won't be reliable after mt.

Fixed.

> BTW the missing part of guess_correct_pts(), which is the reason that I didn't move it outside cmdutils, is this part of ffmpeg.c:
>                     ist->next_pts = ist->pts = guess_correct_pts(&ist->pts_ctx, picture.reordered_opaque, ist->pts);
>                     if (ist->st->codec->time_base.num != 0) {
>                         int ticks= ist->st->parser ? ist->st->parser->repeat_pict+1 : ist->st->codec->ticks_per_frame;
>                         ist->next_pts += ((int64_t)AV_TIME_BASE *
>                                           ist->st->codec->time_base.num * ticks) /
>                             ist->st->codec->time_base.den;
>                     }
> 
> which, if the input pts is all AV_NOPTS_VALUE, advances the last
> returned time by the timebase and returns that. ffplay is missing
> this, so if frames get all the way through with AV_NOPTS_VALUE it
> ignores the stream's frame rate and just displays them at some
> default duration. Note that it probably works better using
> r_frame_rate instead of time_base.

Good, so we have many parts of FFmpeg which needs to share the same
code. Nicolas, you had some ideas regarding to this, do you have
something which can be shared?

As for the movie source, I suppose it should be safe to commit it in
the current incomplete form (but basically working for most inputs),
and try to work to some shared solution (ffplay.c, ffmpeg.c,
vsrc_movie.c, the lavfi example Nicolas was working on).

> I've forgotten a few details, which is maybe why I didn't finish the
> patch series.

BTW what else is missing for the -mt series integration?
-- 
FFmpeg = Fundamental and Fostering Merciless Plastic ExchanGer



More information about the ffmpeg-devel mailing list