How to set profile to high when encoding with h264_mf Media Foundation?


I am on a Windows laptop with intel ivybridge HD4000 iGPU, hardware encoding with h264_qsv doesn’t work since it supports only skylake and above. I can however use h264_mf to encode videos without problems with

h264_mf under Codec tab

and under Other tab I use the following,


Except there is no control over encoding profile, main, base, high etc… I notice that in the view log there is a line


which means it encodes videos with constrained base profile, is there a way to set

MF_MT_MPEG2_PROFILE=100, which corresponds to encoding with high profile?


What does MPEG-2 profile have to do with H.264? You should be able to control the profile using vprofile=high. But I suspect the quality of this early generation H.264 hardware encoder is not very good and suggest to just use x264 instead.

Thank you. I tried vprofile=high before posting but it was of no use. The log showed this

[h264_mf @ 000002550f483c00] [Eval @ 000000840a5fec90] Undefined constant or missing '(' in 'high'
[h264_mf @ 000002550f483c00] Unable to parse option value "high"

and the videos were still encoded with constrained baseline profile. My use case on this old laptop is for initial fast editing, so export speed is more important than quality. I have a desktop for exporting in libx264 for final archiving.

The mpeg-2 line I quoted above came from the full log, part of which looks like this,

[h264_mf @ 000002550f483c00] MF 0 attributes:
[h264_mf @ 000002550f483c00]    MFT_ENUM_HARDWARE_URL_Attribute='XXXXXXX-2F73-48c7-97F7-F6FA17651651'
[h264_mf @ 000002550f483c00]    MFT_FRIENDLY_NAME_Attribute='Intel� Quick Sync Video H.264 Encoder MFT'
[h264_mf @ 000002550f483c00]    {3aecb0cc-035b-4bcc-8185-xxxxxxxxxx}='VEN_8086'
[h264_mf @ 000002550f483c00]    {4276c9b1-759d-4bf3-9cd0-0d7xxxxxxxx}=<blob size 64: 38 9B 71 4E 56 31 32 61 39 AE 42 BA 67 FF 47 CC C1 3E ED 76 69 64 73 00 00 10 00 80 00 00 AA 00 38 9B 71 4E 56 31 32 00 00 10 00 80 00 00 AA 00 38 9B 71 >
[h264_mf @ 000002550f483c00]    {53476a11-3f13-49fb-ac42-xxxxxxxx}=1
[h264_mf @ 000002550f483c00]    MFT_TRANSFORM_CLSID_Attribute={4be8d3c0-0515-4a37-ad55-xxxxxxxxx}
[h264_mf @ 000002550f483c00]    {88a7cb15-7b07-4a34-9128-xxxxxxxxxxx}=7
[h264_mf @ 000002550f483c00]    {8eae8cf3-a44f-4306-ba5c-xxxxxxxxxx}=<blob size 32: 9B 71 48 32 36 34 00 00 10 00 80 00 00 AA 00 38 9B 71 >
[h264_mf @ 000002550f483c00]    {9359bb7e-6275-46c4-xxxxxxxx}=4
[h264_mf @ 000002550f483c00]    {ceabba49-506d-4757-xxxxx}={f79eac7d-e545-4387-bdee-d647d7bde42a}
[h264_mf @ 000002550f483c00]    {f81a699a-649a-497d-8c73-xxxxxx}=1
[h264_mf @ 000002550f483c00] activate MFT 0
[h264 @ 000002550f5ad940] Reinit context to 1280x720, pix_fmt: yuv420p
[h264 @ 000002550f5dde40] Reinit context to 1280x720, pix_fmt: yuv420p
[h264 @ 000002550f66d000] Reinit context to 1280x720, pix_fmt: yuv420p
[AVIOContext @ 000002550f64c040] Statistics: 163840 bytes read, 0 seeks
[h264 @ 000002550f5ad940] Reinit context to 1280x720, pix_fmt: yuv420p
[producer avformat] audio: total_streams 1 max_stream 1 total_channels 2 max_channels 2
[chain avformat-novalidate] input.mp4
    checking VFR: pkt.duration 512
[link swresample] 2(stereo) f32le 44100Hz -> 2(stereo) f32le 48000Hz
[h264_mf @ 000002550f483c00] MFT attributes
[h264_mf @ 000002550f483c00]    ff_MF_SA_D3D11_AWARE=1
[h264_mf @ 000002550f483c00]    MFT_ENUM_HARDWARE_URL_Attribute='AA243E5D-2F73-48c7-97F7-xxxxxxx'
[h264_mf @ 000002550f483c00]    {3aecb0cc-035b-4bcc-8185-xxxxxx}='VEN_8086'
[h264_mf @ 000002550f483c00]    {53476a11-3f13-49fb-ac42-xxxxxxx}=1
[h264_mf @ 000002550f483c00]    MFT_TRANSFORM_CLSID_Attribute={4be8d3c0-0515-4a37-ad55-xxxxx}
[h264_mf @ 000002550f483c00]    {e3f2e203-d445-4b8c-9211-xxxxxx}=869843
[h264_mf @ 000002550f483c00]    {f34b9093-05e0-4b16-993d-xxxxxxx}=2814827077178409
[h264_mf @ 000002550f483c00]    {f81a699a-649a-497d-8c73-xxxxxx}=1
**[h264_mf @ 000002550f483c00] MFT name: 'Intel� Quick Sync Video H.264 Encoder MFT'**
**[h264_mf @ 000002550f483c00] MFT supports ICodecAPI.**
**[h264_mf @ 000002550f483c00] input types:**
**[h264_mf @ 000002550f483c00] (need to set output type 1)**
**[h264_mf @ 000002550f483c00] output types:**
**[h264_mf @ 000002550f483c00] output type 0:**
**[h264_mf @ 000002550f483c00]    MF_MT_MAJOR_TYPE=MFMediaType_Video**
**[h264_mf @ 000002550f483c00]    MF_MT_SUBTYPE=MFVideoFormat_H264**
**[h264_mf @ 000002550f483c00] picking output type 0.**
**[h264_mf @ 000002550f483c00] setting output type:**
**[h264_mf @ 000002550f483c00]    MF_MT_FRAME_SIZE=5497558139600 (1280x720)**
**[h264_mf @ 000002550f483c00]    MF_MT_AVG_BITRATE=200000**
**[h264_mf @ 000002550f483c00]    MF_MT_MAJOR_TYPE=MFMediaType_Video**
**[h264_mf @ 000002550f483c00]    MF_MT_MPEG2_PROFILE=66**
[h264_mf @ 000002550f483c00]    MF_MT_FRAME_RATE=107374182401 (25:1)
[h264_mf @ 000002550f483c00]    MF_MT_INTERLACE_MODE=2
[h264_mf @ 000002550f483c00]    MF_MT_SUBTYPE=MFVideoFormat_H264

So it seems to me that profile setting is hardcoded and from the shotcut gui I have no idea of how to set the profile to high.

Also, ffmpeg does not have a param named ‘profile’ for h264_mf, I am not sure if this is related. The mpeg-2 line in the log may be due to low level interaction between intel graphics driver and ffmpeg?

$ ffmpeg -h encoder=h264_mf
ffmpeg version N-114117-g4027c2e1d0-20240312 Copyright (c) 2000-2024 the FFmpeg
  built with gcc 13.2.0 (crosstool-NG
  configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-conf
ig=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw
32 --enable-gpl --enable-version3 --disable-debug --disable-w32threads --enable-
pthreads --enable-iconv --enable-libxml2 --enable-zlib --enable-libfreetype --en
able-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-libharfb
uzz --enable-libvorbis --enable-opencl --disable-libpulse --enable-libvmaf --dis
able-libxcb --disable-xlib --enable-amf --enable-libaom --enable-libaribb24 --en
able-avisynth --enable-chromaprint --enable-libdav1d --enable-libdavs2 --enable-
libdvdread --enable-libdvdnav --disable-libfdk-aac --enable-ffnvcodec --enable-c
uda-llvm --enable-frei0r --enable-libgme --enable-libkvazaar --enable-libaribcap
tion --enable-libass --enable-libbluray --enable-libjxl --enable-libmp3lame --en
able-libopus --enable-librist --enable-libssh --enable-libtheora --enable-libvpx
 --enable-libwebp --enable-lv2 --enable-libvpl --enable-openal --enable-libopenc
ore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg -
-enable-libopenmpt --enable-librav1e --enable-librubberband --enable-schannel --
enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwol
ame --enable-libuavs3d --disable-libdrm --enable-vaapi --enable-libvidstab --ena
ble-vulkan --enable-libshaderc --enable-libplacebo --enable-libx264 --enable-lib
x265 --enable-libxavs2 --enable-libxvid --enable-libzimg --enable-libzvbi --extr
a-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-
ldexeflags= --extra-libs=-lgomp --extra-version=20240312
  libavutil      59.  1.100 / 59.  1.100
  libavcodec     61.  1.100 / 61.  1.100
  libavformat    61.  0.100 / 61.  0.100
  libavdevice    61.  0.100 / 61.  0.100
  libavfilter    10.  0.100 / 10.  0.100
  libswscale      8.  0.100 /  8.  0.100
  libswresample   5.  0.100 /  5.  0.100
  libpostproc    58.  0.100 / 58.  0.100
Encoder h264_mf [H264 via MediaFoundation]:
    General capabilities: dr1 delay hybrid
    Threading capabilities: none
    Supported pixel formats: nv12 yuv420p
h264_mf AVOptions:
  -rate_control      <int>        E..V....... Select rate control mode (from -1
to INT_MAX) (default default)
     default         -1           E..V....... Default mode
     cbr             0            E..V....... CBR mode
     pc_vbr          1            E..V....... Peak constrained VBR mode
     u_vbr           2            E..V....... Unconstrained VBR mode
     quality         3            E..V....... Quality mode
     ld_vbr          4            E..V....... Low delay VBR mode
     g_vbr           5            E..V....... Global VBR mode
     gld_vbr         6            E..V....... Global low delay VBR mode
  -scenario          <int>        E..V....... Select usage scenario (from -1 to
INT_MAX) (default default)
     default         -1           E..V....... Default scenario
     display_remoting 1            E..V....... Display remoting
     video_conference 2            E..V....... Video conference
     archive         3            E..V....... Archive
     live_streaming  4            E..V....... Live streaming
     camera_record   5            E..V....... Camera record
     display_remoting_with_feature_map 6            E..V....... Display remoting
 with feature map
  -quality           <int>        E..V....... Quality (from -1 to 100) (default
  -hw_encoding       <boolean>    E..V....... Force hardware encoding (default f