[Live-devel] Presentaition time problem at H264 streams

6.45 6.45.Vapuru 6.45.vapuru at gmail.com
Sat Dec 17 05:19:14 PST 2011


Hi

I modify the OpenRtspClient so that

-- Now instead of writing frames to file I collect them in a queue
with incoming presenttaion times
-- Then give the h264 frames to MP4 muxer [ Geraint Davies MP4 mux filter]
-- Finally write muxed data to file...

So I can able to save h264 stream into MP4 container...
But the problem is that, some of the recorded data [NOT all of them]
has wrong values for time duration:
Suppose that a 10 minute record seems that it was 12 h stream...
VLC play the 10 minute that play last  frame for the remaing time.

It seems that i set   sample times wrong into the Muxer...
Then i debug and see that there is positive and negative dramatic
jumps at time stamps...

Here is  how i set time stamps:

-- Firts i take presentationTime from
H264VideoFileSink::afterGettingFrame1 function
-- Then calculate the firstPresentaionTime [ at the beginning]
-- Then collect other timestamps

#define TIMEVAL_TO_REFERENCE_TIME(x) ((__int64)(x.tv_sec * 1000000) +
x.tv_usec) * 10

void  H264VideoFileSink::afterGettingFrame1(unsigned frameSize, struct
timeval presentationTime)
{

    // At the beginning [ just for once calculate firstPresentaionTime ]
	
	firstPresentaionTime = TIMEVAL_TO_REFERENCE_TIME(presentationTime);
	
	// for the other frames collect frames timestamps
	
	frameTimeStamp = TIMEVAL_TO_REFERENCE_TIME(presentationTime) -
firstPresentationTime

}

frameTimeStamp values show dramatic jumps to negative or positive
values...[ i keeep those values as int64 ]

What my cause this?

-- Or is it  agood idea to use this "presentationTime"  for a MP4 Muxer?
-- Where the "presentationTime" is calculated at library?
-- Is it possible that   H264VideoFileSink::afterGettingFrame1 method
"presentationTime" values may be wrong?
-- Anybody record h264 stream in  a mp4 contianer and wanted to share
his/her experience?

Best Wishes
Novalis Vapuru

PS:

By the way i can able to re-write OpenRtspClient in a more OO-way.Each
client has its own envr and scheduler...
So i can start many of them programatically in a multithreaded way...
Just simple as

  string rtspUrl = "xxxxx";

  New_OO_OpenRtspClient* client = new   New_OO_OpenRtspClient(rtspUrl);

  client->Start();
  client->Shutdown();

 But I think there is still some memory leaks at my Shutdown
method...Some sources not "cleanup"...

 Hope, for the next release we will see more OO way written
OpenRtspClient example at Live555...


More information about the live-devel mailing list