[FFmpeg-devel] Inconsistent behavior in dashenc.c when using custom avio function.

eSX nayuhz at gmail.com
Mon Dec 9 16:10:32 EET 2019

Hi ffmpeg
Recently I want to use dash format to serve a real-time stream video in C
I want to encode the video in memory and copy it out for some purpose.

I use an example code here:

The example code is fine for mp4 format( e.g. call open_video(width,
height, 60, 400000000, 0, 1, 1);), but the custom avio callback can not be
triggered when I just modify the "mp4" to "dash" in line 220.

I have read the code in dashenc.c, it seems that dashenc take over the avio
functions in dash_init():

        if (!c->single_file) {
            if ((ret = avio_open_dyn_buf(&ctx->pb)) < 0)
                return ret;
            ret = s->io_open(s, &os->out, filename, AVIO_FLAG_WRITE, &opts);
        } else {
            ctx->url = av_strdup(filename);
            ret = avio_open2(&ctx->pb, filename, AVIO_FLAG_WRITE, NULL,

User can only use existing IO functions defined in protocols.c.
Yes, of course, I can read the packet after
calling avcodec_receive_packet(), but the init segment or the file header
can't be retrieved from memory, becasue avformat_write_header() can not
trigger the custom avio callback function.

The behavior is inconsistent for each format, any ideas?



More information about the ffmpeg-devel mailing list