[Libav-user] [libav-user] demuxing of incoming rtp stream by means of libavformat and custom IO

Dmitry Volyntsev xeioexception at gmail.com
Fri Feb 24 08:30:17 CET 2012

I found out the answer by myself. May be it could be useful for other
ffmpeg newbies.

It is impossible to feed only rtp stream to libav for just depacketising
purpose without establishing rtsp input by means of libav

//! Demuxer will use avio_open, no opened file should be provided by the
#define AVFMT_NOFILE        0x0001

[rtp @ 0x8d2500] Custom AVIOContext makes no sense and will be ignored with

./libavformat/rtspenc.c:    .flags = AVFMT_NOFILE | AVFMT_GLOBALHEADER,
./libavformat/rtsp.c:    .flags = AVFMT_NOFILE,
./libavformat/rtspdec.c:    .flags = AVFMT_NOFILE,

     * I/O context.
     * decoding: either set by the user before avformat_open_input() (then
     * the user must close it manually) or set by avformat_open_input().
     * encoding: set by the user.
     * Do NOT set this field if AVFMT_NOFILE flag is set in

     * iformat/oformat.flags. In such a case, the (de)muxer will handle
     * I/O in some other way and this field will be NULL.
    AVIOContext *pb;

On Fri, Feb 17, 2012 at 6:48 PM, Dmitry Volyntsev
<xeioexception at gmail.com>wrote:

> Hi All!
> I have a question related to demuxing of incoming rtp stream by means of
> libavformat.
> 1) My program has it own event loop (libevent) and I can't easily
> integrate libavformat routines to reading from udp and tcp sockets
> straightforwardly
> 2) I already wrote custom IO routines and RTSP protocol negotiator
> (communicates with other side and requests streaming from RTSP server to
> local udp ports)
> What I tried to do:
>  ioBuffer_ = (unsigned char *)av_mallocz(_IO_BUFFER_SIZE
>                                                 +
>  ioContext_ = avio_alloc_context(ioBuffer_, _IO_BUFFER_SIZE,
>            0, ptr, my_read, NULL, NULL);
>  formatCtx_ = avformat_alloc_context();
>  formatCtx_->pb = ioContext_;
>  res = avformat_open_input(&formatCtx_, "spf-avs", NULL, NULL);
> my_read() - reads incoming raw RTP stream packets
> Unfortunately constantly returns AVERROR(EAGAIN)
> I just want to feed raw RTP data to libavformat for demuxing  purposes and
> just get the pure videodata back for further processing
> What should I do for to get it done?
> Thanks in advance!
> --
> Be happy,
> Best regards,
> Dmitry Volyntsev

Be happy,
Best regards,
Dmitry Volyntsev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20120224/47a22720/attachment.html>

More information about the Libav-user mailing list