LEADTOOLS Support
General
General Questions
KLV Callback when using MultiStreamTarget and MultiStreamSource
This topic and its replies were posted before the current version of LEADTOOLS was released and may no longer be applicable.
#1
Posted
:
Tuesday, January 4, 2011 2:51:19 PM(UTC)
Groups: Registered
Posts: 4
I am trying to concatenate multiple MPEG files into a single, continuous stream and output this to a network location.
I have adapted the example from
https://www.leadtools.com/help/leadtools/v17/dh/multimedia/mm/leadtools.multimedia~leadtools.multimedia.multistreamsource~deliversample.html.
The final target is a network stream instead of a file. The input file is an MPEG-TS file with KLV data.
I also adapted the sample code for the KLVBuilder and added that to the second ConvertCtrl object (the one that has MultiStreamSource and Network target).
First, I added the KlvBuilder code to the ConcateFile method and I was able to inject purley synthetic KLV data. This worked perfectly.
Then I created an ILMMpgDmxCallback and added it to the first ConvertCtrl (mpeg file and MutliStreamTarget).
When I invoke StartConvert, it will read the MPEG file(s) and stream it to the TCP/UDP targets. However, the callback doesn't even invoked until the end of the first file. It doesn't invoke the callback at all.
Is there an example of how to use the Combine AVI's example with a KLV callback?
Edited by moderator Wednesday, September 23, 2020 10:09:34 AM(UTC)
| Reason: Fixed link
#2
Posted
:
Tuesday, January 4, 2011 9:06:13 PM(UTC)
Groups: Registered
Posts: 4
I figured out that by calling Application.DoEvents() within the ConcateFile loop, the callback method was gets invoked as expected. It appears when using the ConvertCtrl without a form, it still uses WinForm events and needs the calling thread to pump events.
From within my ILMMpgDmxCallback DataAvailable method, I am using the KlvBuilder object and writing the private data to the multiplexer to the second ConvertCtrl object (where target is the network). The method invokes without error. I am calculating the PTS as seconds, setting the flags as shown in the example, and then writing the KlvBuilder data to the stream as private data.
This all *appears* to work on the server side.
On the client side:
The KLV packets do not appear to be received by the client viewer. The PMT shows that a private data PES stream should be available. I have attached a callback to the splitter on the client's PlayCtrl. The ILMMpgDmxCallback object on the client side is never being called. It seems like the KLV packets aren't actually being injected into the stream.
Any suggestions on what may be preventing the KLV packets from being injected into the stream?
#3
Posted
:
Wednesday, January 5, 2011 7:29:01 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
Can you try to play the steam using our MPEG-2 Transport demo shipped with our toolkit? If yes, does it work correctly?
Also, can you try to play the stream on the same machine that has LEADTOOLS installed on, does it work with your application?
#4
Posted
:
Wednesday, January 5, 2011 10:30:41 AM(UTC)
Groups: Registered
Posts: 4
When I play it with the MPEG-2 Transport demo, it will play the video but it still does not pick up any KLV data.
When I run everything on the same machine, the KLV data still does not come through.
#5
Posted
:
Wednesday, January 5, 2011 11:42:17 AM(UTC)
Groups: Registered
Posts: 4
I've tracked down the problem to what I think is a PTS problem on the WritePrivateData method.
If I put an arbitrary offset on the PTS value I'm using, it will output KLV data on some test datasets. However, this arbitrary offset varies from file to file. What I've discovered is if the PTS value is too far behind or even a little ahead of the video sample stop time, it won't write the KLV data.
The KlvBuilder examples uses a completely made-up PTS value based on the duration of the video so I'm not sure what I'm supposed to be doing.
Is there an example of how to use the PTS value from the DataAvailable method and use that to write data using the WritePrivateData method?
I have tried several ways to calculate a PTS and none of them seem to generate a usable PTS. The WritePrivateData method will fail silently if the PTS is invalid.
I've tried:
pts = PtsFromDataAvailable (and removed the PTS_Seconds flag).
pts = (PtsFromDataAvailable - ILMMpgDmx.StartStreamPTS).
Tried the above by converting to seconds as well.
ptsSeconds = (double)MediaSample_StopTime / TimeSpan.TicksPerSecond;
I've also tried just using wall-clock elapsed from the start of the conversion.
None of these values product values that WriteKlvData will take. I am fairly certain I am using the wrong PTS value, but I do not know what is the "right" way to retrieve the PTS value.
#6
Posted
:
Thursday, January 6, 2011 3:08:48 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
Can you try the project available on this forum post that captures UDP stream and converts the stream to a file with KLV data:
http://support.leadtools.com/SupportPortal/CS/forums/36776/ShowPost.aspx#36776
If it works, try to implement the same approach in your code and then try to read the data on your client side.
LEADTOOLS Support
General
General Questions
KLV Callback when using MultiStreamTarget and MultiStreamSource
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.