[FFmpeg-user] stream Media Information using ffmpeg probe with custom-io

kifayat ullah kifayat.ullah at yahoo.com
Fri Dec 5 10:52:41 CET 2014

 Hello,I am developing an application that has two separate parts, one for reading of packets and other one for using packets.I am using Live555 to read incoming packets from source. and after getting packets I want to pocess it using ffmpeg.Now in order to set different information need to initialize ffmpeg I need a ffmpeg prober to give me stream information.I am thinking to write a prober using custom io. in which I can send packet and it will return me stream info.I don't know where to start can you or somebody help me in right direction and also if you got some sample code that can help me in this regard, will be appreciated. Martin, as you have made these custom io changes in rtsp you probably are best person to ask this, I strongly believe you will reply me with right answer.
Here is my code that I am using.

//It is Read function That actually read packet data delivered from live555.
 static int Read_Packet(void *opaque, uint8_t *buf, int size)    {        PacketCollector* packetCollector = (PacketCollector*)opaque;        return packetCollector->read(buf,size);            }//GetStreamInfo is function used to get stream information, i.e Codec information.
void GetStreamInfo(){
const std::shared_ptr<AVIOContext> avioContext(avio_alloc_context(buffer.get(),             maxSize,             AVIO_FLAG_READ,             reinterpret_cast<void*>(m_src.get()),             &Read_Packet,             nullptr,              nullptr), &av_free);        AVInputFormat       *inputFormat    = NULL;        avioContext->seekable = 0;        avioContext->write_flag = 0;        if( av_probe_input_buffer2(avioContext.get() , &iFormat, "rtsp:", NULL, 0, 0 ) < 0 )        {            std::cerr << "failed to probe input buffer";        }
        const auto avFormat = std::shared_ptr<AVFormatContext>(avformat_alloc_context(), &avformat_free_context);        AVFormatContext* avFormatPtr = avFormat.get();        avFormat->pb = avioContext.get();        avFormatPtr->flags = AVFMT_FLAG_CUSTOM_IO |AVFMT_NOFILE  ;        AVDictionary* dect = NULL;        av_dict_set(&dect,"custom_io","1",AV_DICT_DONT_OVERWRITE);        ret = avformat_open_input(&avFormatPtr, "", iFormat, &dect);        if(ret < 0)        {            printf("%s", "unable to open more data");        }        else        {                printf("%s", "Open successfully.");                                av_dump_format(avFormatPtr,0, "", 0);                ret = avformat_find_stream_info(avFormatPtr,NULL);                if(ret < 0)                {                    printf("%s", "Unable to get stream info");                }                 av_dump_format(avFormatPtr,0, "", 0);        }
Please help and reply if you spot any thing wrong or some batter way to do same thing.

Many Thanks.Kifayat UllahP Think trees before printing this email.

More information about the ffmpeg-user mailing list