On Fri, 27 Jan 2017 16:02:23 +0200 (EET)
Martin Storsjö <[email protected]> wrote:

> On Fri, 27 Jan 2017, Peter Große wrote:
> 
> > The dash_write function drops data, if no IOContext is initialized.
> > This might happen when a subordinate muxer calls avio_flush().
> > Using a dynamic buffer fixes that.
> >
> 
> This patch at least needs a mention of what muxer would do that.
> 
> Currently, the only subordinate muxer you can use is the mp4 one, and that 
> one (with the configured options) doesn't flush except when told to.

Ah ok.

> > +    // re-open buffer
> > +    ret = avio_open_dyn_buf(&os->ctx->pb);
> > +    return ret;  
> 
> The intermediate variable feels a little superfluous here

Agreed.

> >         av_dict_set(&opts, "movflags", "frag_custom+dash+delay_moov", 0);
> > -        if ((ret = avformat_write_header(ctx, &opts)) < 0) {
> > -             goto fail;
> > -        }
> > +        if ((ret = avformat_write_header(ctx, &opts)) < 0)
> > +            goto fail;
> > +
> > +        if ((ret = flush_dynbuf(os, &range_length)) < 0)
> > +            goto fail;
> > +
> > +        if (!c->single_file)
> > +            ff_format_io_close(s, &os->out);
> > +
> > +        os->pos = os->init_range_length = range_length;  
> 
> This isn't correct. See c5e7ea13d2d4da0c5da91973a547afff6fe9e011. We 
> intentionally defer writing the init segment until we have passed the 
> first segment of packets into the muxer, to handle the cases where the 
> init segments depend on knowledge from the actual first few packets.
> 
> (Proper edit lists for handling b-frame delay needs to know the timestamp 
> of the first packet, and for AC3, the moov box takes a copy of the full 
> first packet.)
> 
> For using the webm muxer, you probably might need to have this behaviour 
> conditional on the kind of muxer.

So how do you avoid spilling actual packets into the init segment?
Is it that av_write_frame only writes to the file, what was flushed before
using avio_flush?

This code resulted from dealing with matroskaenc having his own idea when to
flush and start new clusters.

So my first idea would to the move the "writing out the init segment" code to a
function and call it conditionally depending on the muxer.
If webm, call it in write_header. Then in dash_flush call it, if
os->init_range_length is zero.

> > +        // write chunk header
> > +        write_styp(os->ctx->pb);  
> 
> Doesn't this miss writing the styp header for the first segment?

Yes. In earlier versions of the code dash_flush was called with the init
segment still to be written. So it made sense to only write it after the first
one.

Regards
Peter

Attachment: pgpK3DNfA_lrm.pgp
Description: OpenPGP digital signature

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to