[FFmpeg-devel] [PATCH v1] avformat/flvenc: add add_keyframe_index option

Steven Liu lingjiujianke at gmail.com
Sat Nov 5 04:47:29 EET 2016


2016-11-04 23:04 GMT+08:00 Michael Niedermayer <michael at niedermayer.cc>:

> On Fri, Nov 04, 2016 at 10:47:35PM +0800, Steven Liu wrote:
> > 2016-11-04 22:38 GMT+08:00 Michael Niedermayer <michael at niedermayer.cc>:
> >
> > > On Fri, Nov 04, 2016 at 08:58:56PM +0800, Steven Liu wrote:
> > > > 2016-11-04 20:44 GMT+08:00 Michael Niedermayer
> <michael at niedermayer.cc>:
> > > >
> > > > > On Fri, Nov 04, 2016 at 11:24:06AM +0800, Steven Liu wrote:
> > > > > > Add keyframe index metadata
> > > > > > Used to facilitate seeking; particularly for HTTP pseudo
> streaming.
> > > > > >
> > > > > > Reviewed-by: Lou Logan <lou at lrcd.com>
> > > > > > Signed-off-by: Steven Liu <liuqi at gosun.com>
> > > [...]
> > > > > > +static int flv_append_keyframe_info(AVFormatContext *s,
> FLVContext
> > > > > *flv, double ts, int64_t pos)
> > > > > > +{
> > > > > > +    FLVFileposition *position = av_malloc(sizeof(
> FLVFileposition));
> > > > > > +
> > > > > > +    if (!position) {
> > > > > > +        av_log(s, AV_LOG_WARNING, "no mem for add keyframe
> > > index!\n");
> > > > > > +        return AVERROR(ENOMEM);
> > > > > > +    }
> > > > > > +
> > > > > > +    position->keyframe_timestamp = ts;
> > > > > > +    position->keyframe_position = pos;
> > > > > > +
> > > > > > +    if (flv->filepositions_count) {
> > > > > > +        flv->filepositions = position;
> > > > > > +        flv->head_filepositions = flv->filepositions;
> > > > > > +        position->next = NULL;
> > > > > > +    } else {
> > > > > > +        flv->filepositions->next = position;
> > > > > > +        position->next = NULL;
> > > > > > +        flv->filepositions = flv->filepositions->next;
> > > > > > +    }
> > > > > > +
> > > > > > +    flv->filepositions_count++;
> > > > > > +
> > > > > > +    return 0;
> > > > > > +}
> > > > >
> > > > > an array should be more space efficient than a linked list
> > > > >
> > > > array have max limit, if this is used in recording living stream to
> flv,
> > > > maybe linked list is better than array.
> > >
> > > on what platform can you allocate more linked list entries (which have
> > > much more overhead) than an array ?
> > >
> > No, maybe you misunderstand me.
> > I mean, this is a vector, if is use array[n], i cannot sure what size set
> > to [n],
>
> have you tried using av_add_index_entry() ?
>

Hi Michael,

    I have read the code, i saw all the use case using
 av_add_index_entry()  when demuxing,
    and i have not found list foreach API, i want add the keyframes'
*filepositions* and *times* value into
    a temp list(memory), and flush them at the end of the flv muxing.

1. read live streaming or file by sequence
2. if use add_keyframe_index option, add a mark flag at the position, use
to insert new context at the last step.
3. add the keyframes *offset* and *timestamp* into a list
4. if use add_keyframe_index option, shift the metadata data from mark flag
offset
5. insert the keyframes *offset* and *timestamp* from the list by sequence
6. free the list
7. end.

this patch is used to do this.

>
> [....]
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> During times of universal deceit, telling the truth becomes a
> revolutionary act. -- George Orwell
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>


More information about the ffmpeg-devel mailing list