C# Directshow H.264 Encoding Parameters

C# Directshow H.264 Encoding Parameters

This is for anyone who is developing in c# directshow using the h264 encoder provided by intel.

The parameters used to set the quality of the encoder can be very annoying as I get really wacky results.

Instead of writing a thousand lines of code to create the parameter structures you can literally do this in about 12 lines of code. Here goes:

RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\\Intel\\Media SDK Sample Filters\\H264 Encoder", true);

key.SetValue("Level", 40);

key.SetValue("RCControl.bitrate", 21000);

key.SetValue("PCControl", 1);

key.SetValue("Preset", 0);

key.SetValue("Profile", 100);

key.SetValue("PSControl.GopPicSize", 200);

key.SetValue("PSControl.GopRefDist", 3);

key.SetValue("PSControl.NumSlice", 1);

key.SetValue("RCControl.rc_method", 1);

key.SetValue("TargetUsage", 4);

key.Dispose();

Everything is stored in the registry and as long as you set these values before creating the encoder object then the encoder will use these settings.

Much more convenient!

Cheers,
Marty

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hi Marty,
Thanks for contributing to the community.

-Tony

Leave a Comment

Please sign in to add a comment. Not a member? Join today