[Ffmpeg-devel] problem of decoding mpeg4 ps stream with libavformat and libavcodec

楚材 keweixiao
Sun Aug 20 05:52:22 CEST 2006


Hi,
    I had wrote a program to decode video stream received from network. But I found that MPEG2 PS/TS and MPEG4 TS stream could be demuxed  and decoded successfully, only MPEG4 PS stream couldn't be played rightly. the function av_find_stream_info() can detecte the parameter nb_streams
is 2,but the video parameter is wrong,for examp the picture width is 1,height is 71,bit_rate is 2400 etc. I use the functions av_open_input_stream() but av_open_input_file() to open the received data. can av_open_input_file() be used to open a received steam data?Is anyone else had come into contact with this problem? How can I use the ffmpeg to decode the mpeg4 PS stream? thanks!	

my code is:
	AVProbeData   pd;
	ByteIOContext ByteIOCtx;
	//wait for full data received from the network
	pd.buf = new unsigned char[MIN_PROBE_SIZE];
	pd.buf_size = MIN_PROBE_SIZE;
	pd.filename = "";
	int hr = fifo_read(&pThis->m_recvBuffer,pd.buf,MIN_PROBE_SIZE,NULL);
	AVInputFormat* fmt = av_probe_input_format(&pd,1);
	if(!fmt)
	{
		TRACE("av_probe_input_format error!\n");
		delete [] pd.buf;
		pd.buf_size = 0;
		return FALSE;
	}
	TRACE("video format:%s\n",fmt->long_name);
	delete [] pd.buf;

	fmt->flags |= AVFMT_NOFILE;

	init_put_byte(&ByteIOCtx,pThis->m_pReadBuffer,FILE_READ_SIZE,0,pThis,IORead,NULL,IOSeek);

	AVFormatContext* pFormatCtx = NULL;

	if(av_open_input_stream(&pFormatCtx,&ByteIOCtx,"",fmt,NULL) < 0)
	{
		TRACE("av_open_input_stream error!\n");
		return FALSE;
	}

	if(av_find_stream_info(pFormatCtx) < 0)
	{
		TRACE("av_find_stream_info error!\n");
		return FALSE;
	}
 				
--------------
Crazy Kevin
2006-08-20





More information about the ffmpeg-devel mailing list