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
And I see that frameTimeStamp values show dramatic jumps to negative or positive values...[ i keeep those values as int64 ]
#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
}
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?