3

My application do encoding of captured frame from GDI or DXGI method. currently i am doing encoding with help x264 library.
AFAIK x264 is software based library, i want to do encoding with help of GPU, so it can save CPU cycles and hope speed also will be faster.
After searching, I found a H.264 Video Encoder MFT which is doing h264 encoding.
But couple of questions are answered for me.
1) is It faster than x264 encoding library?
2) can bitmap frame be encoded with help this MFT?
- i have seen only MFVideoFormat_I420, MFVideoFormat_IYUV, MFVideoFormat_NV12, MFVideoFormat_YUY2, MFVideoFormat_YV12 these formats are supported
3) is it hardware accelerated(mean it's using CPU or GPU)?
- Initially my understanding was it uses GPU but i get confused after reading this post MFT Encoder (h264) High CPU utilization.
4) can H.264 Video Encoder MFT be used stand alone without using sink writer, as i have to sent data on network?
5) is there any other alternative in windows?

It might be some questions are very silly, please feel free to edit.

oguz ismail
  • 1
  • 16
  • 47
  • 69
anurudh
  • 338
  • 1
  • 4
  • 15
  • I found in some other question that for using hardware encoder have to set flag MFT_ENUM_FLAG_HARDWARE. I hope it will detect hardware automatically. – anurudh Feb 19 '16 at 08:47
  • I found one alternate option but it's a third party implementation. I am lookking similar to [H.264/AVC Wrapper](http://www.mainconcept.com/products/sdks/gpu-acceleration-sdk/h264avc-wrapper.html) lib for windows. – anurudh Feb 19 '16 at 08:50

1 Answers1

2

Media Foundation H.264 Video Encoder is software encoder. From my [subjective] experience it slower than x264 and, perhaps more important, x264 offers wider range of settings, specifically when it comes to choose modes on the speed over quality end of the range. Either way, stock MS encoder is not hardware accelerated.

However, there might be other MFTs available (typically installed with respective hardware drivers) that do hardware accelerated H.264 encoding. You can discover them by enumerating MFTs, perhaps most popular is Intel Quick Sync Video (QSV) Encoder.

HardwareVideoEncoderTransform app does the enumeration and provides you with relevant details:

enter image description here

Typical input is NV12, some offer other input choices (such as e.g. 32-bit RGB). If you need other formats, you will have to pre-convert the input.

Hardware backed encoders CPU consumption is low, and their efficiency depends on the hardware implementation. Yes, you can use them standalone, entirely standalone or wrapped as DirectShow filter and included in normal DirectShow pipeline.

Alternate H.264 encoders are typically SDK based, or wrappers over those SDKs in DirectShow/MFT form factors because vendors package their implementation in well-known forms already familiar to multimedia developers.

Roman R.
  • 68,205
  • 6
  • 94
  • 158
  • Thanks @Roman R. Actually I got confused as i have read many places that H264 encoder in Hardware accelerated. Please refer http://stackoverflow.com/questions/31236646/how-to-use-hardware-h-264-encoder-in-windows-media-foundation, http://stackoverflow.com/questions/23251666/where-is-the-clsid-for-media-foundation-h264-encoder and [Encoding H.264 video using hardware MFTs](http://alax.info/blog/1586). – anurudh Feb 25 '16 at 12:35
  • My understanding was media foundation H264 Encoder uses Hardware based Encoder internally. – anurudh Feb 25 '16 at 12:36
  • When it comes to H.264 encoding, Media Foundation sees the MFT choices and picks a suitable one. It would typically prefer HW over stock SW implementation. If you're planning to use MFTs directly, you will have to decide which one to take. The one from MS is SW only. – Roman R. Feb 25 '16 at 12:38
  • what does mean **"Media Foundation sees the MFT choices and picks a suitable one"**, who will do it. let say i am using using my application which is simply calling X264 API, so we have to write logic to choose the hardware MFT over software one or any such thing already implemented in windows. It might be a stupid question but i get confused a bit. – anurudh Feb 25 '16 at 12:48
  • can you please also suggest the name of alternatives? – anurudh Feb 25 '16 at 12:57
  • I mean that when you deal with MFTs directly, you can use software MFT or you can use hardware MFT - you are the one who decides which one to take. When however H.264 encoding is a part of Media Foundation topology and it picks the encoder, it does the selection itself: it sees encoder merits and picks "most appropriate" for the job. You are trying to work with MFT here, your taking stock [H.264 Video Encoder MFT](https://msdn.microsoft.com/en-us/library/windows/desktop/dd797816) will take you to software only encoding. You need another MFT to encode through hardware. – Roman R. Feb 25 '16 at 12:58
  • Alternate MFTs from Intel, Nvidia, AMD respectively are: Intel® Quick Sync Video H.264 Encoder MFT, NVIDIA H.264 Encoder MFT, AMDh264Encoder. – Roman R. Feb 25 '16 at 12:59
  • Hi Roman. FYI your tool crashes (Win10 x64) and I can't successfully login to WordPress (WTF?) to comment with more info. If you're interested my email is firstname underscore lastname at hotmail dot com – Simon Mourier Dec 06 '18 at 10:28
  • (the tool is fixed, links posted above are in good standing and point to fixed build) – Roman R. Dec 06 '18 at 11:59