- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
IKsPropertySet setProperty = pIntelMediaSDKH264Encoder as IKsPropertySet;
and thats as far as I got.
How can I set the property values that graphedit exposes in c#?
Note: C++ sample is ok as well, prefer C# but converting it is possible.
Thanks, cheers.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Martin,
The MediaSDK and its samples are developed and validated using C++. We have little or no experience using managed DirectShow, or using C# with our filters. The idea does sound compelling. If you get it working please share with the rest of us on the forum.
The filters implement their properties through the IConfigureVideoEncoder interface GetParms(), SetParams(). How these map to your environment is unclear from this side.
Does anyone out there reading this have any experience with this? Please speak up and help Martin out.
Thanks!
-Eric
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
you can access this interfaceby creating it's analong in managed code. Then you need todeclare your interface with attribute[ComImport], and use casting from previously created Com object(Encoder Filter in your case).
Here is an simple example. Also please set target platform in c# project settings to x86 if you are using 32 bits filters.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ah,I should have known to ask Eugene! Thanks Eugene.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
One last thing I'm hoping you can help me with. I'm not sure if I have the right GUID for IConfigureVideoEncoder as I get this error when trying to cast the encodefilter to the interface:
+ $exception {"Unable to cast COM object of type 'EncodeFilter' to interface type 'IConfigureVideoEncoder'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{6BABAF70-864B-486B-B471-CC4E9AFF931B}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE))."} System.Exception {System.InvalidCastException}
Any insight?
Cheers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[Guid("4CBE79AB-EEDA-4AB6-B8F2-80286BEDAC4A"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface IConfigureVideoEncoder
{
void SetParams(ref Params param);
void GetParams(ref Params param);
void GetRunTimeStatistics(ref Statistics param);
};
Works perfect.
Thanks again for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You are right, I used newer guid,weswitched to this one recently. We will either mention this in documentationo roll back changes, to maintain backward compatibility, so please check that again when new Mediasdk package will be available.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
One last issue, I'm not sure how to convert a line of c++ to c# as I'm sure why this is why I'm erroring. I forgot to mention that I'm working with the H264 Encoder but noticed in the documentation that it inherits from the video encoder anyways. I get a com exception when setting the parameters, this is what it currently looks like without the video encoder structures:
[Guid("4CBE79AB-EEDA-4AB6-B8F2-80286BEDAC4A"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface IConfigureVideoEncoder
{
void SetParams(ref Params param);
void GetParams(ref Params param);
void GetRunTimeStatistics(ref Statistics param);
};
[Guid("46F60C41-6809-432E-8D0E-293C34DECFDD"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface IConfigureH264Encoder : IConfigureVideoEncoder
{
};
And how I'm setting the parameters:
// Set up encoding parameters.
EncodeFilter enc = new EncodeFilter();
IConfigureH264Encoder configure = (IConfigureH264Encoder)enc;
Params param = new Params();
configure.GetParams(ref param);
configure.SetParams(ref param);
The part of code I'm not sure how to convert is this:
struct H264Params: IConfigureVideoEncoder::Params
I believe this is my last barrier, any suggestions?
Cheers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Martin,
since c# doesnt support structures inheritance you may declare parent structure Params as a first member of H264Params structure.
Actually as i mentioned interface that you are using changed, together with its guid, so in my first post you can see how it will look like in Beta5, there won't be any structures inheritance, as well as IConfigureH264Encoder interface.
I'm attaching whole c# console class that works, i checked that such layout of c# H264Params structure normally marshaled to unmanaged code and back.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I replaced the prior code with the proper structures for the H264 interface and all seemed well except when I set the parameters the function SetParams fails:
System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
I understand that its accessing unmanaged memory but not sure how to work around this as the error is a bit vague. Any ideas? Thanks!
Cheers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
in my first post I alreadymentioned that setparams internally resulted in calls to graph manager, and actually it has no checks for that zero pointer. So any attempts on filter that not in a filter graph will result in such exception.
Here is exact place
\beta4\samples\sample_dshow_plugins\video_enc_filter\src\mfx_video_enc_filter.cpp line : 1030
hr = m_pGraph->QueryInterface(IID_IFilterGraph, (void**)&pGraph);
So you may comment this line and rebuild/register h264 encoder filter, and see whether it helps.I didnt try to add filters to graph manager, but you may do it since it required to perform any processing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I did see the comment above that line your post, but wasn't sure if it was the cause. I am adding the filter to the graph prior to setting the parameters however It was being done before by using just the GUID to instantiate the filter... I figured because the EncodeFilter class has the same guid it shared the same instance.
Do I have to recreate the graph using the Class GUID and not a private field?
Currently it is being add like this:
private static Guid CLSID_IntelMediaSDKH264Encoder = new Guid("{71183C45-F4FA-4B10-9E04-F9040CB19139}"); //h264_enc_filter.dll
pIntelMediaSDKH264Encoder = (IBaseFilter)Activator.CreateInstance(Type.GetTypeFromCLSID(CLSID_IntelMediaSDKH264Encoder));
hr = pGraph.AddFilter(pIntelMediaSDKH264Encoder, "Intel Media SDK H.264 Encoder");
My problem is I can't put The comimport class into that structure. I'll keep at it, any more ideas are most grateful.
Thanks Eugene.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Cheers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Attached is an updated version (only lightly tested):
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page