This project is read-only.

Potential Media Encoder profile bug?

Mar 26, 2009 at 10:40 PM
Edited Mar 27, 2009 at 5:12 AM
Hello...

So I tried doing an auto-encode entry using the H.264 stuff. Everything worked as expected until I tested the
resulting file in QuickTime Player. It failed. I inspected the file and noticed that it was using a Windows Codec.

This was weird, because I verified I selected the "HardwareDeviceH264Small" item in the Auto Encode list and
I do have the full version of Expression Encoder 2 (tested and verified using the same source file encoded using
the UI AND custom code with the API).

I dug into it a little more and found what I think is causing the issue.

private VideoProfile GetVideoProfile(string profile) {
     try {
         return (VideoProfile)Enum.Parse(typeof(VideoProfiles), profile);
     } catch {
         return VideoProfiles.WebServerBroadband;
     }
}


Enum.Parse needs an Enum type, and typeof returns a system.type, right?

So, this code will always throw an exception, which will always be caught, thereby forcing the method to always return
WebServerBroadband.

I plopped the line (with some edits to match my functionality of course) in my quick-n-dirty code and
confirmed that this exceptions out.

Any thoughts?

-pete

EDIT: I think this can fix it (using reflection) ... worked in my test code, but haven't thrown it in the MES yet.

String defaultProfile = "WebServerBroadband";

PropertyInfo pinfo = typeof(VideoProfiles).GetProperty(profile) ?? typeof(VideoProfiles).GetProperty(defaultProfile);
return (VideoProfile)pinfo.GetValue(pinfo, null);