[Live-devel] MPEG4 streaming using ffmpeg as encoder

ssingh at neurosoft.in ssingh at neurosoft.in
Fri Oct 18 12:34:53 PDT 2013


Hi,

I spend almost last 3 days banging my head with RFCs and other 
documents. Here is what I want to achieve. I have raw BGRA frames and I 
want to stream them using live555. This is what I am doing

I created a subclass of FramedSource which is responsible to encode the 
raw BGRA frame into MPEG4 using ffmpeg and then copy it to fTo. the 
brief source code is given below:

Here the m_queue contains the AVPacket directly from ffmpeg which is 
output from av_encode_video function
/*****************************************************/
void MyStreamingDeviceSource::deliverFrame()
{

         EsUtil::getTimeOfDay(&fPresentationTime, NULL);

	AVPacket pkt;
	m_queue.getPacket(&pkt, 1);
	unsigned int newFrameSize = pkt.size;

	if(newFrameSize == 0) return;

	if(newFrameSize > fMaxSize)
	{
		fFrameSize = fMaxSize;
		fNumTruncatedBytes = newFrameSize - fMaxSize;
	}
	else
	{
		fFrameSize = newFrameSize;
	}
	memcpy(fTo, pkt.data, fFrameSize);
	av_free_packet(&pkt);
	FramedSource::afterGetting(this);
}
/*****************************************************/

My filter chain looks like this

Raw BGRA -> Encode to MPEG4 using ffmpeg -> MyStreamingDeviceSource -> 
MPEG4VideoStreamDiscreteFramer -> MPEG4ESVideoRTPSink

when i am doing that I am not getting anything in VLC and testRTCPClient 
and debugging just print some information after every 1-1.25 seconds. it 
just print "Sending REPORT" and "sending RTCP packet"

I suspect that I did not send the configuration data before sending the 
actual data. I saw that my AVPAcket has "00000001B6" in starting and I 
think i somehow need to send "00000001B0" to signal start of data.

I also noticed that when i encode using FFMpeg in codec->extradata I 
have some header information that has "00000001B0" in that but i dont 
know how to pack all this information to create a valid RTP packet and 
how frequently i need to send this header and encoded packets.

I might be doing something very wrong . Please help me in order to 
figure out how to send the FFMpeg encoded data using live555.

Thanks,
Caduceus


More information about the live-devel mailing list