1/02/2022

DirectX GraphEdit Decoding H.264 from AverMedia C874 USB HD

When you build a Graph Edit "Graph" for MPEG2 you often have a WDM capture device driver filter with an Output Pin.

The Output Pin streams video as a multiplexed Audio and Compressed Video format. To turn it back into something you can view you have to Demultiplex it and Decode it using separate workflows from the Demux filter.

DirectX and Windows offer several filters.

The "MPEG-2 Demultiplexer" normally has one Input - MPEG-2 Stream and no pins.

The MPEG-2 Multiplex format is generic and it is used by other A/V streams besides MPEG2, it can be used for MPEG4. Breaking apart the audio from the video works that same way.

1. put a source filter on the graph, perhaps coming from the hardware capture device.

2. put the [ MPEG-2 Demultiplexer ] filter on the graph, right click and configure this filter with one pin


Output Pins

---

New Output Pin

 Name: PSI

Media Type:  MPEG-2 PSI

>> Create ->

 

PID Mappings

---

PID

0x0000

Pin

PSI

MPEG2 PSI Sections

>> [Map]


Press [OK] to close the Properties Dialog box

Hit the Orobus (two arrows chasing each other in a circle) button to "Refresh" the graph and expose the pin you just created

Uisng Graph Edit 64 bit (be sure its 64 bit Graph Edit or Directshow filters will not open and crash Graph Edit) go to the Diret Show filters and put the PSI Parser filter on the graph

Connect the PSI pin from [MPEG-2 Demultiplexer] ->[ PSI Parser]

Execute ('Run') the Graph, while it is running > Right click on PSI Parser filter

[PSI Parser Properties]

Programs Contained in the Transport Stream:

Program Number

PMT PID

(click on the first program number, a list of the PID Stream type Contents, will appear below)

The KEY to using this is the First colum [PID] is in "Decimal" format.

 

You have to convert that Number form Decimal into Hex format to go back to MPEG-2 Demultiplexer and appropriately map PIDs to Elementrary streams coming out the the Output pins.

You can do all of this "live" while the Graph is running.

Example:

 

Mean PIDs in DEC

4113 0x1b ISO/IEC-14496-10/H.264 AVC Video

4352 0x3  ISO/IEC 11172-3 Audio

 

Mean PIDs in HEX

0x1100 MpegVideo Elementary Stream (A/V only)

0x1011 MpegAudio Elementary Stream (A/V only)


https://docs.microsoft.com/en-us/windows/win32/directshow/overview-of-mpeg-2-systems

https://stackoverflow.com/questions/16362132/why-do-i-get-these-artifacts-when-using-microsoft-mpeg-ts-demultiplexer-and-h-26

https://docs.microsoft.com/en-us/windows/win32/directshow/microsoft-mpeg-2-video-decoder

https://stackoverflow.com/questions/4618695/using-microsoft-dtv-dvd-video-decoder-to-play-h264-video

http://www.gdcl.co.uk/mpeg4/

https://github.com/RenderHeads/UnityPlugin-AVProVideo/issues/205

https://en.wikipedia.org/wiki/MPEG_transport_stream


Once the pins are created, you can hit the Orobus (two arrows chasing each other) and stop the Graph, right click on the pins and "render" them based on their content type and mostly if you have the right filters and merits the Graph will build itself.

 

 




The Microsoft DTV-DVD decoder can work starting with Windows 7, its not the best, but its free.