[Ffmpeg-devel] video streaming (with UDP protocol): decode_slice_header error decoding raw h264

Giovanni Gualdi gualdi.giovanni
Wed May 10 10:25:29 CEST 2006


Hi all,

(I posted this message on users mailing list too, but this is list fits
better, sorry for duplicate).

I am working on ffmpeg (with Mingw) in order to do 
UDP streaming of raw h264 video.

I have a problem in the decoding part, can anyone give a hint?

First of all I applied the changes to the ffmpeg code posted in the thread
	[Ffmpeg-devel] [PATCH] MingW RTSP support  
	(March 2006, ffmpeg developers mailinglist)
(in order to enable the network support with mingw).

Then, I did a little modification to udp.c: I needed to add a call to
WSAStartup() inside the function udp_open() in order to successfully open
the socket.
Ffmpeg can be now compiled with mingw, obtaining the dlls of libavcodec,
libavformat and libavutils.

At this point I wrote an application that uses these dlls and tries to open
and listen from the uri ?udp://@?localport=2500?.
(on the other side, I wrote a little udp streamer that opens a raw ?.264?
video (ffplay successfully reads it), and streams it on udp, at chunks of
1472 bytes each).

The first steps of the application are the following ones (that I basically
copied from the official ffmpeg documentation):

      [...]

	// Register all formats and codecs
	av_register_all();

	char uri[] = "udp://@?localport=2500";

	h264_fmt = av_find_input_format("h264");

	i=av_open_input_file(&pFormatCtx, uri, h264_fmt, 0, NULL);

	if(i!=0)
		return -1;

	// Retrieve stream information
	if(av_find_stream_info(pFormatCtx)<0)
		return -1; // Couldn't find stream information

	// Find the first video stream
	videoStream=-1;
	for(i=0; i<pFormatCtx->nb_streams; i++)
	
if(pFormatCtx->streams[i]->codec->codec_type==CODEC_TYPE_VIDEO)
		{
			videoStream=i;
			break;
		}

	if(videoStream==-1)
		return -1; // Didn't find a video stream

	// Get a pointer to the codec context for the video stream
	pCodecCtx=pFormatCtx->streams[videoStream]->codec;

      [...]

 
av_find_stream_info is blocking until it reads data from the udp channel. 
As soon as it starts reading data, it gives a bunch of:

[h264 @ 10226008] non existing PPS reference
[h264 @ 10226008] decode_slice_header error

(as if it is not finding the keyframe, right?)
And then, when some upd packets have been received, it returns successfully.

_______But the problem is this________
the AVCodecContext that I get from the opened stream seems to be rubbish,
(width=0, height=0,...): and this makes everything crash badly when I go
further in frame allocation and so on.

(REMARK1: I am sure that no packets have been lost in the udp communication)
(REMARK2: If I open the raw h264 file from file system instead of getting
the same data from UDP streaming, this code works great, with no
decode_slice_header error at all).

What am I doing wrong?
Should I repeat the av_find_stream_info() until I get valuable CodecContext?

Any .02euros hint is welcome,
Thanks in advance
Gio

--------------------------------------------------
Ing. Giovanni Gualdi
Dipartimento di Scienze e Metodi dell'Ingegneria
Universita' di Modena e Reggio Emilia
Cell. 339 1337328? Office 059 2056270
email: gualdi.giovanni at unimore.it
URL: http://imagelab.ing.unimo.it
-------------------------------------------------- 






More information about the ffmpeg-devel mailing list