[Libav-user] av_write_frame not returning...??

enpingado jorge at alumni.ufl.edu
Mon Aug 22 21:14:15 CEST 2011


I am taking RGB frames, converting to YUV, then encoding to H264.

finally i am trying to send this using rtp.



My program has a loop that is supposed to capture the RGB frame every 1/fps
, convert and send. At least that is my intent.

However, when i get my first encoded frame that is non-zero and i make my
call to av_write_frame() the program never seems to exit the av_wrtite_frame
call. it hangs will spitting out lots of small packets, forever...

There are packets flying out like mad, but VLC reports many errors and
doesnt show any video.

Some of the errors are things like duplicate sequence numbers, droppping
late packets....


Im not sure what is casue av_write_frame to freeze, unless i dont understand
how it is supposed to work.

1) Maybe i am not setting all timting params correctly?

Logically, i thought i could grab a frame, convert it and send it.  Is this
not true? 

My format context is:

avformat_alloc_output_context2(&g_formatContextPtr,NULL,"mpegts",NULL);

my encoder is :

avcodec_find_encoder(CODEC_ID_H264);

my output is:
 avio_open(&g_formatContextPtr->pb,"rtp://172.16.0.87:1234",URL_WRONLY);

Below is a snippet of data that is in the loop for grabbing frames and
sending it:

             AVPacket packet;
	av_init_packet(&packet);


	
	//checking if last encode was a key frame to set a flag?...
	if(g_c->coded_frame->key_frame)
		packet.flags |= AV_PKT_FLAG_KEY;		
	
	packet.data			=	g_outbuf;
	packet.size			=	out_size;
	packet.duration = 0;//i dont know what to set it to, its unknown so it
equals 0
	packet.stream_index =	g_streamPtr->index;
	packet.pts = 3600*g_fps_index;
	packet.pts	=	g_c->coded_frame->pts;
	

	DebugFilePrint("\nInfo - Pre- av_write_frame -    ");
	
	error_result = 	av_write_frame(g_formatContextPtr,&packet);

--
View this message in context: http://libav-users.943685.n4.nabble.com/av-write-frame-not-returning-tp3760977p3760977.html
Sent from the libav-users mailing list archive at Nabble.com.


More information about the Libav-user mailing list