i have been trying to have a custom avio for write operations using
ffmpeg/libav to write remuxed packets to a cache instead of a file or
socket. read callbacks are working fine but write callback is never
invoked. I followed example of
https://gist.github.com/AlexVestin/15b90d72f51ff7521cd7ce4b70056dff
but to no avail. My code is as shown below for write callback function:

*int write_packet(void *opaque, uint8_t *buf, int buf_size) {*

*    cout << "in write_packet";*

*    outfile.open("segmentfile.ts", std::ios_base::app);*

*        if( !outfile ){*

        *cout** << "Opening file failed" ;*

*                return 0;*

*        }*

*        outfile << (uint8_t *)bd->buf;*

*    return buf_size;*

*}*


and registration is via :


*    avio_ctx_buffer = (uint8_t *)av_malloc(avio_ctx_buffer_size);*

*    if (!avio_ctx_buffer) {*

*        ret = AVERROR(ENOMEM);*

*        exit(1);*

*    }*

*    avio_ctx = avio_alloc_context(avio_ctx_buffer, avio_ctx_buffer_size,
1, &gbd, NULL, write_packet,NULL);*

*    if (!avio_ctx) {*

*        ret = AVERROR(ENOMEM);*

*        exit(1);*

*    }*

*    m_ofmt_ctx = avformat_alloc_context();*

*     AVOutputFormat* ofmt = av_guess_format(output_format_name.c_str(),
nullptr, nullptr);*

*    if(!ofmt) {*

        *cout** << "Output format not found " << output_format_name;*

*        return false;*

*    }*

    *cout** << "Creating all output contexts successful";*

*    m_ofmt_ctx->pb = avio_ctx;*

*    //m_ofmt_ctx->flags |= AVFMT_FLAG_CUSTOM_IO;*

*    m_ofmt_ctx->oformat = ofmt;*




I am thinking after this registration, any time there is a write function,
like av_interleaved_write_frame()* , *the callback must be called.But the
call invocation is not happening. Is there something i need to do other
than above registration to make write callback work?


I tried both having and removing "*m_ofmt_ctx->flags |=
AVFMT_FLAG_CUSTOM_IO;*"

but neither works.
-- 
Regards
Manoj
_______________________________________________
Libav-user mailing list
[email protected]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[email protected] with subject "unsubscribe".

Reply via email to