[Ffmpeg-devel] decoding rtp stream

Mark Lederman mark_led
Tue Jun 27 22:16:25 CEST 2006


Hello:

I?m trying to decode an h264 file from a udp stream. The problem I?m having
is queuing the udp packets up in a buffer and decoding them at the same
time. I?m running the stock decoding process from output_example.c in a
separate thread. My initialization code is also fairly stock and is listed
below. I run the initialization code one time and then decode a frame at a
time. Right now I?m giving the queue a big head start before I start
decoding. Essentially all I can do is play what is in the queue prior to
starting decoding. After that it gets ugly with the decoding process blowing
up one way or another with an access violation. You?ll notice in my
read_func(void* opaque, uint8_t* buf, int buf_size) all I do is return the
buf_size. Is there something more I need to do in there. How exactly does
that work? Does the decoder keep calling this callback when you call
av_read_packet(pFormatCtx, &packet)? The other thing is can I decode without
the format contect dll? I know the video is always going to be h264.

// Register all formats and codecs
av_register_all();

int err = init_put_byte(m_pIO, (uint8_t*) m_rtpData, len, 0, m_rtpData,
read_func, NULL, NULL);

m_pIO->is_streamed = 1;

m_pInputFormat = av_find_input_format("h264");
m_pInputFormat->flags |= AVFMT_NOFILE;

    // Open video file
    if(av_open_input_stream(&m_pFormatCtx, m_pIO, m_rtpData,
m_pInputFormat,NULL)!=0)
        return -1; // Couldn't open file
    // Retrieve stream information
    if(av_find_stream_info(m_pFormatCtx)<0)
        return -1; // Couldn't find stream information

int read_func(void* opaque, uint8_t* buf, int buf_size)
{
	return buf_size;
}

and so on?

I know the udp stack is working because I can save the packets to a file and
then play the file. So my question is how do I go about playing the packets
out as they come in? Is that possible? Examples? Any help would be
appreciated. Thanks in advance.






More information about the ffmpeg-devel mailing list