[Live-devel] delay in sending MPEG4 frame using MPEG4VideoStreamDiscreteFramer

Mehran Ansari mehran at stretchinc.com
Tue Oct 4 19:41:53 PDT 2011


I am using Live555 library to send video streams of different CODEC types from an IP-Camera which produces H.264, MJPEG, and MPEG4 video stream.

I can successfully stream video one frame at a time as it is ready from my hardware encoder for H.264 and MJPEG but for MPEG4 it appears the video frames do not get sent out until some internal live555 buffer is full. When I use openRTSP client to receive MPEG4 video frames no matter what buffer size I set (-b), it always tells me that it received frames are larger than my buffer size.

I derived my class from MPEG4VideoStreamDiscreteFramer. 

each time doGetNextFrame() is called,

- I copy a complete MPEG4 frame (VOL, I, or P frame) to fTo, 
- fFrameSize = sizeof fTo buffer
- gettimeofday(&fPresentationTime,NULL) 
- fDurationInMicroseconds = 0 since frames are being read from an encoder as oppose to a file.
- call FramedSource::afterGetting(this)

In case my encoder did not have any video frame ready when doGetNextFrame() was called I call scheduleDelayedTask()

Doing the above, immediately one full frame can be displayed in VLC once it is connected or openRTSP. But then, it takes VLC sometimes up to 40 seconds to display the next few frames and stops due to frames being arrived late. For openRTSP, I keep getting the buffer is too small regardless of what buffer size I specify.

Is there anything in MPEG4 like H.264 that I need to set to tell live555 this is a complete MPEG4 frame and send it immediately. For H.264 I had to implement currentNALUnitEndsAccessUnit(), is there something similar for MPEG4?

I read over most of the messages in the forum and it seems that I am doing exactly what others are doing except I am having this delayed problem. Again, I can stream H.264 and MJPEG video frame with no problem.

One last thing, My encoder generate VOL frame separately from the I-Frame, which I use the same fPresentationTime for both VOL and the following I-frame but they are called twice to FramedSource::afterGetting()

Thanks for your help.
--Mehran


More information about the live-devel mailing list