[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
language.
I want to encode the video in memory and copy it out for some purpose.

I use an example code here:
https://gist.github.com/AlexVestin/15b90d72f51ff7521cd7ce4b70056dff

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,
&opts);
        }

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?

Thanks.



-- 
eSX


More information about the ffmpeg-devel mailing list