help required fro using basemedia library for extracting h264 frames from TS

Feb 27, 2015 at 3:40 PM
Hi jclary,

I am trying to use the basemedia library to extract the h264 raw frames from Ts segments, i tried the ts viewer and Silverlight test client to understand the flow, but It is not firing any UnitReceived once i do demuxer.ProcessInput, I tried both file source and Udp source. I am totally stuck can you please help me to understand and use the same. If you have some sample code that would be great help for me.

I have one more question is this project still active, because the last update was in 2013.

Thanks for the help.
Regards,
Raghu
Coordinator
Feb 27, 2015 at 7:47 PM
I've been meaning to come back to this project for awhile. I went to work for a company developing very similar software and had to stop working on this to avoid legal complications. It would have been too easy for them to claim part ownership of this if I'd continued. Basically I used this code for a commercial product for my employer and couldn't contribute back the changes I made. That's no longer an issue but I've not had the time recently.

Have you been watching the console output in debug mode? It outputs quite a few details about what it is doing along the way that might tell you how far it's getting and where things are going wrong. Off the top of my head I'm not sure what the problem might be unless there's something unusual about the source.

Just to make sure... you do have to keep feeding it packets. Units are reassembled from multiple packets (dozens or hundreds, even) so there's not a 1:1 relationship between calls to the demuxer's ProcessInput and UnitReceived events. Also, it doesn't start paying attention to units from various streams until it sees program association information for them. In file sources, that's usually at or near the beginning of the file and may or may not be repeated frequently throughout but it depends on how it was created. I have seen some applications that use partial TS files without this information included because it's stored elsewhere. You'd have to add programs and streams manually in that case.

I can tell you that I just downloaded and extracted the full source, added a new debug entry to the OnUnitReceived method in TsStream.cs, changed the file source in MainWindow.cs of TsViewer to a random TS file I had lying around and ran it in debug mode. It's definitely attempting to fire the events even though the sample app doesn't currently subscribe to them. You have to watch the Programs collection for new programs, then watch each program for new streams and subscribe to them individually as they are added. TsViewer is obviously incomplete as it doesn't yet display the unit details so there wasn't any reason yet to subscribe to them. I wrote another application that uses that and does actually subscribe to them and use the contents so I'm pretty sure it should work. I can't release that code, however. I probably should go ahead and finish TsVeiwer, however.
Coordinator
Feb 27, 2015 at 8:12 PM
I should also mention it's very important you have an implementation of PortabilityFactory (like MpegTsPortabilityFactory.cs from TsViewer) in your application otherwise it won't use observable collections and you won't have any events when programs and streams are added.

If the minimum portability target was changed from .NET 4 to 4.5 (and SL4 to 5) that wouldn't be absolutely necessary as you could change the base PortabilityFactory implementation to return ObservableCollection<T> instead of List<T>. TsViewer would still have to override it because it needs a dispatching equivalent which can't be done in a portable library.