Encoding with DirectShow filters

2019-03-02 02:44发布

问题:

I'm working on encoding raw images into avi file on windows possibly using directshow filter. The type of codec used will be selected by user. I've already done a similar thing using video for windows (VFW) which was pretty as it provide simple api to compress the data and write it to a file. This time i want to do this using directshow framework to provide directshow support.

However while checking on MSDN I found there different types of filters for different codecs, so there is no single interface. http://msdn.microsoft.com/en-us/library/windows/desktop/dd375464(v=vs.85).aspx Do I need to switch between different filters each time I switch codec.

Also how DMO is different from Directshow as per MSDN they too can be used for encoding. http://msdn.microsoft.com/en-us/library/windows/desktop/ff819088(v=vs.85).aspx

So which should I use to support maximum number of codecs?

Please share you thoughts.

回答1:

Different codecs are available with different interfaces because over the course of API developments where have been several APIs.

  • there are Video for Windows VCM video encoders
  • there are video encoding DMOs
  • there are video encoding MFTs (some are possibly dual DMO/MFT objects)
  • there are video encoding DirectShow filters
    • DirectShow AVI Compressor Filter wraps VFW/VCM encoders and makes them available to DirectShow
    • DirectShow DMO Wrapper Filter makes suitable DMOs available to DirectShow

So the math is that in DirectShow you have most encoders available out of the box.

Other factors like codec specificity and applicability, encoding/container constraints, and the fact decent encoders are not typically freely available - this all seriously limits the use and value of approach when you design an app in a way that it can work with various video encoders of user choice, through standard well known interface/API.