3
votes

I'm writing an application which records PC's screen in realtime and encodes it with Media Foundation h264 codec. The quality of a resulting video stays high if a picture on the screen doesn't have many dynamic changes. If a picture has many dynamic changes (fast scrolling of a web page, for example) then video quality becomes very low. This sounds like a low bitrate problem, but reference OSX recording application works fine with the same settings.

Codec configuration:

  • 25 fps
  • 1364 x 768 resolution
  • baseline profile
  • 1.2 MBit bitrate

To maximize quality, I configured codec with the following parameters:

  • CODECAPI_AVEncCommonRateControlMode = eAVEncCommonRateControlMode_Quality
  • CODECAPI_AVEncCommonQuality = 100
  • CODECAPI_AVEncAdaptiveMode = eAVEncAdaptiveMode_FrameRate
  • CODECAPI_AVEncMPVGOPSize = 10

Unfortunately, this doesn't help much. The only setting that has the real effect is bitrate.

An example video, that demonstrates the problem: https://www.dropbox.com/s/b26odaeyaygxigo/10-22-2016_15.08.17.mp4?dl=1

1
Hi, are you sure that the problem is Media Foundation h264 encoder? What is the source of PC's-Desktop screens?Evgeny Pereguda
PC's screen is captured using IDirect3DSurface9 and then is fed to IMFSinkWriter as is. There is no reason why any compression artifacts should appear in this pipeline not in the encoder.lost_guadelenn
Hi, I think that the problem with encoder. You set low bit rate for resolution almost FULL HD. You compare OSX h264 and Media Foundation h264 encoder, but it is two DIFFERENT companies. Specification h264 guaranty that video from encoders of OSX h264 and Media Foundation h264 can be played but IT DOES NOT guaranty the same quality. More over, video and audio encoders from Microsoft is known with poor quality and poor optimization - for example - h265 encoder in Windows 10 - it is workable only in x64, but in x86 it throws out exception and crashes application.Evgeny Pereguda
Just set more bit rate.Evgeny Pereguda

1 Answers

0
votes

you need to set bit rate and quality by this step:

VARIANT controlModeVar;
InitVariantFromUInt32(eAVEncCommonRateControlMode_GlobalVBR,
&controlModeVar);
hr = CodeApi->SetValue(&CODECAPI_AVEncCommonRateControlMode, 
&controlModeVar);
VARIANT quality;
InitVariantFromUInt32(BitRate, &quality);
hr = CodeApi->SetValue(&CODECAPI_AVEncCommonMeanBitRate, 
&quality);

InitVariantFromUInt32(eAVEncCommonRateControlMode_Quality, 
&controlModeVar);
hr = CodeApi->SetValue(&CODECAPI_AVEncCommonRateControlMode, 
&controlModeVar);
InitVariantFromUInt32(H264QualityLevel, &quality);
hr = CodeApi->SetValue(&CODECAPI_AVEncCommonQuality, &quality);

the min os require windows8.