Log in

View Full Version : problem about develop ts demultiplexer filter (Solved)


silenceboy
9th February 2006, 15:39
I made a mpeg2 ts paser lib which supporting DVB, and use it to develop a MPEG2 TS Push Demultiplexer filter (DShow), refering to MS MPEG2 Demultiplexer described in MSDN.
It can work roughly. But there are still many details cann't be found from documents and open source codes.

I tested in GraphEdit:
MS DVB-T Network provider->DVB Tuner->DVB Capture->TS Push Demuxer->A/V MPEG decoder->VMR/Audio Renderer
(Use AudioRenderer as reference clock.)

Problem:

1. I use TIF filter to connect to TIF pin of MS Demuxer's, it will automatically map several PIDs to that pin. However, when I do so with my demuxer, nothing was mapped, so I have to do it manually. Why?

2. Suppose there is only one program including one video ES and one Audio ES. How could I use their PCR and PTS/DTS for IReferenceClock and Video/Audio output IMediaSample? How could I solve lipSync issue?
I set start and end time of output IMediaSample to NULL, it can preview, but lipSync. I set start time to PTS (converted to REFERENCETIME) and end time to PTS + 1, still lipSync.

silenceboy
7th March 2006, 03:36
Finally, 3 weeks hard work and overtimes, solved.
Tested with BDA structure and TS File Source 2.1.1.8.
My TS Push demuxer can work fine, although still cannot match the functionality of MS Demuxer and MainConcept Push Demuxer.

For problem 1, I just simply set needed PIDs to TIF pin.

For problem 2, till now, I still don't understand what it means in sections in MS MSDN/MPEG-2 Support in DirectShow/Using the MPEG-2 Demultiplexer/Demux Clock Behavior.

Although I impl. local IReferenceClock, in actual use, I don't use it, but use that from Audio Renderer. And I still don't know how to use PCR for local ref clock after tring several combinations/methods, so use system clock instead.

MS SDK said "The demux also translates PES PTS values into DirectShow reference times, and uses these values to time stamp the media samples." I think it is impossible only using PTS for time stamp of media samples. should combine with stream time. So, I figure it out a simple solution, so far it works fine, but I haven't tested long time previewing yet, and don't consider time shift.
Here it is:
Current sample time stamp = (REFERENCE_TIME)((Current PTS - Base PCR) * (1000 / 9)) + (stream time when got base PCR)
(1000 / 9) is short for "(NANOSECONDS / 100) / 90000 Hz".
Base PCR is set when start running. Maybe I should reset it periodically.

silenceboy
7th March 2006, 03:44
BTW: Remember the following words when you do your Push Demuxer. Forgetting it is the origin of many weird things!

DShow SDK/Writing DirectShow Filters/Data Flow for Filter Developers/Delivering Samples, "Live sources, such as capture filters, should not send data while paused."