LEADTOOLS Support
General
General Questions
Re: Using DVR Module in C++ as a circular buffer
This topic and its replies were posted before the current version of LEADTOOLS was released and may no longer be applicable.
#1
Posted
:
Wednesday, April 18, 2012 4:14:03 AM(UTC)
Groups: Registered
Posts: 11
Hello,
I am currently developing an application that takes in an RTSP based H264 video stream, stores it in a DVR buffer, and (when developed) will retrieve a certain amount of video from the buffer when an event is fired. For example, when an event is fired, I want to combine 1 minute of video leading up to the event, and record 1 minute of video after, so that what lead up to the event and what happened after is recorded.
This application is written in C++, it uses IltmmConvert to access the RTSP video stream, ILMDVRSink to buffer the video, and a standard LeadTools::Multimedia::PlayCtrl to play the buffered video.
The problem I have is keeping track of where about in the buffer the video is up to, for if the buffer has been recording for 10 hours and an event is fired, how would I calculate the exact point within the buffer to extract the 1 minute buffer and after of the event?
Also another thing to consider is that I'm using the DVR as a circular buffer (as I don't want to continually record weeks of footage to be able to find a specific few minutes within the buffer when an event fires), this means that event videos may overlap the end of the buffer and start recording at the beginning again, so I can't just use the video stream bitrate to calculate how much video has been recorded in order to work out where it's currently at (as suggested in
http://support.leadtools...rums/40557/ShowPost.aspx).
Finally, I've consulted the DVR project in "LEADTOOLS 17.5\Examples\Ltmm\Cpp\DVR" to see how it keeps track of a recorded video stream within the DVR buffer, and it seems to be done through the use of ILMMpgDmx. However I've had great difficulty understanding this, and so if this is the only way of doing the calculations I need, could somebody explain the required steps required to implement it.
Thank you in advance for any assistance anyone can provide.
#2
Posted
:
Wednesday, April 18, 2012 8:12:32 AM(UTC)
Groups: Registered
Posts: 256
If you're asking about properties like CurrentStreamPTS used in the demo to determine the stream position, they are documented in our Multimedia Filters help file in the topic for the ILMMpgDmx Interface.
About the calculations, the position is in PTS (Presentation time stamp) unit, which has a resolution of 90kHz.
That's why the PTSToString() function in the demo divides by 90000 to convert to seconds, or by 90 to convert to milliseconds.
#3
Posted
:
Thursday, April 26, 2012 4:37:27 AM(UTC)
Groups: Registered
Posts: 11
Thank you for clarification on the PTS unit.
Having looked at the examples and library help resources, as well as clarifying the objectives of this project, it seems that I need a method of keeping track of the buffer position without using a PlayCtrl.
As explained, I use a ConvertCtrl to capture the RTSP stream, and save this to a DVR buffer created using the ILMDVRSink interface.
What I need is a way that can keep track of the position of the buffer, so that when needed I can use a second ConvertCtrl to extract a set amount of time leading up to and recorded after an event.
I'd prefer to not use the PlayCtrl CurrentStreamPTS approach because I do not need to display the video while it is being recorded; I just need to record event video's as accurately as possible.
Do you know of any other methods to which I could achieve this? Bearing in mind that the buffer will be a circular buffer (and so overwritten eventually), so I can't just set a timer and extract from the beginning up to the current time.
#4
Posted
:
Monday, April 30, 2012 7:00:58 AM(UTC)
Groups: Registered
Posts: 256
Iain,
To use the members of the ILMMpgDmx Interface such as CurrentStreamPTS, you do not necessarily need our Play control. You can use them with our Convert control.
Please see help topic "Programming with the LEADTOOLS DVR Module". It contains details about the buffers and locations within them.
If this doesn't answer your question, please give me more details about your requirements.
#5
Posted
:
Thursday, May 3, 2012 3:47:51 AM(UTC)
Groups: Registered
Posts: 11
Daoud,
I have read the section you suggested, and have produced the following code to access the current PTS value:
pin_ptr pinnedMpeg2TDeMux = &pMpeg2TDeMux;
double curPts = 0.0;
hr = convertToDVRCtrl->GetSubObject(ltmmConvert_Object_Splitter, &punk);
if (punk != NULL)
{
hr = punk->QueryInterface(IID_ILMMpgDmx, (void**) pinnedMpeg2TDeMux);
if (FAILED(hr))
{
AddError("punk->QueryInterface() for ILMMpg2MxT failed");
}
else
{
pMpeg2TDeMux->get_CurrentStreamPTS(&curPts);
}
}
Note: punk, hr and convertToDVRCtrl are declared earlier in the application (and convertToDVRCtrl is instantiated and StartConvert() has been called to initiate the conversion from the RTSP source to the DVR buffer).
When executed, convertToDVRCtrl->GetSubObject() returns a value to hr of -2147467259 and fails to provide the demultiplexer, do you have any idea how tor resolve this?
#6
Posted
:
Thursday, May 3, 2012 7:19:36 AM(UTC)
Groups: Registered
Posts: 256
Iain,
Have you verified that the correct demux (splitter) is being used? You can force that using the IltmmConvert::put_PreferredMPEG2Splitter() method.
If that doesn't solve it, I'm afraid that this code is not enough for me to get a complete idea of what might be causing this problem. Can you please provide me with a working sample project (NOT your full application) that demonstrates the issue in a ZIP or RAR file?
Please note that if you wish to attach the project here, please do NOT use the preview feature.
LEADTOOLS Support
General
General Questions
Re: Using DVR Module in C++ as a circular buffer
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.