如何使用EZrgb24过滤器 [英] How to use EZrgb24 filter

查看:129
本文介绍了如何使用EZrgb24过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在.avi视频的每一帧上应用诸如对比度,颜色变化,亮度之类的过滤器。

I'm trying to apply filter such as contrast, color change, brightness on every frame of a .avi video.

该视频在directshow.net和c#上播放正常。

The video is playing just fine with directshow.net and c#.

经过几个小时的研究,我发现buffercb不是

after a couple hours of research, I found out that buffercb was not the way to go to do the job.

显然,EZrgb24是一个过滤器,我可以将其添加到图形中,该过滤器可以完全满足我的要求。

Apparantly, EZrgb24 is a filter I can add to my graph that does exactly what I want.

但是,我无法正常工作。

However, I can't get it to work.

[DllImport("ole32.dll", EntryPoint = "CoCreateInstance", CallingConvention = CallingConvention.StdCall)]
    static extern UInt32 CoCreateInstance([In, MarshalAs(UnmanagedType.LPStruct)] Guid rclsid,
       IntPtr pUnkOuter, UInt32 dwClsContext, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid,
       [MarshalAs(UnmanagedType.IUnknown)] out object rReturnedComObject);



以下是有效的相关代码



Here is relevant code that works

        int hr = 0;

        IBaseFilter ibfRenderer = null;
        ISampleGrabber sampGrabber = null;
        IBaseFilter capFilter = null;
        IPin iPinInFilter = null;
        IPin iPinOutFilter = null;
        IPin iPinInDest = null;



        Type comType = null;
        object comObj = null;

        m_FilterGraph = new FilterGraph() as IFilterGraph2;

        try
        {
            // Get the SampleGrabber interface
            sampGrabber = new SampleGrabber() as ISampleGrabber;

            // Add the video source
            hr = m_FilterGraph.AddSourceFilter(_videoPath, "Ds.NET FileFilter", out capFilter);
            DsError.ThrowExceptionForHR(hr);

            // Hopefully this will be the video pin
            IPin iPinOutSource = DsFindPin.ByDirection(capFilter, PinDirection.Output, 0);

            IBaseFilter baseGrabFlt = sampGrabber as IBaseFilter;
            ConfigureSampleGrabber(sampGrabber);

            iPinInFilter = DsFindPin.ByDirection(baseGrabFlt, PinDirection.Input, 0);
            iPinOutFilter = DsFindPin.ByDirection(baseGrabFlt, PinDirection.Output, 0);

            // Add the frame grabber to the graph
            hr = m_FilterGraph.AddFilter(baseGrabFlt, "Ds.NET Grabber");
            DsError.ThrowExceptionForHR(hr);

            hr = m_FilterGraph.Connect(iPinOutSource, iPinInFilter);
            DsError.ThrowExceptionForHR(hr);

            // Get the default video renderer
            ibfRenderer = (IBaseFilter)new VideoRendererDefault();

            // Add it to the graph
            hr = m_FilterGraph.AddFilter(ibfRenderer, "Ds.NET VideoRendererDefault");
            DsError.ThrowExceptionForHR(hr);
            iPinInDest = DsFindPin.ByDirection(ibfRenderer, PinDirection.Input, 0);

            // Connect the graph.  Many other filters automatically get added here
            hr = m_FilterGraph.Connect(iPinOutFilter, iPinInDest);
            DsError.ThrowExceptionForHR(hr);


            SaveSizeInfo(sampGrabber);

            HERE WE WANT TO ADD THE EZRGB FILTER.



无效的代码



Code that doesnt work

            /*

            // { 8B498501-1218-11cf-ADC4-00A0D100041B }
            DEFINE_GUID(CLSID_EZrgb24,
            0x8b498501, 0x1218, 0x11cf, 0xad, 0xc4, 0x0, 0xa0, 0xd1, 0x0, 0x4, 0x1b);
             */
            unsafe
            {
                Guid IUnknownGuid = new Guid("00000000-0000-0000-C000-000000000046"); //Can it be written in more pretty style?

                Guid ezrgbclsid = new Guid(0x8b498501, 0x1218, 0x11cf, 0xad, 0xc4, 0x0, 0xa0, 0xd1, 0x0, 0x4, 0x1b);
                uint hr1 = CoCreateInstance(ezrgbclsid, IntPtr.Zero, (uint)(CLSCTX.CLSCTX_INPROC_HANDLER), ezrgbclsid, out x);//CLSCTX_LOCAL_SERVER

                IIPEffect myEffect = (IIPEffect)x;// as IIPEffect;

                if (hr1 != 0)
                {
                    int iError = Marshal.GetLastWin32Error();
                    Console.Write("CoCreateInstance Error = {0}, LastWin32Error = {1}", hr1, iError);

                }

                myEffect.put_IPEffect(1004, 0, 100); //for this filter, look at resource.h for what the int should be, in this case 1002 is the emboss effect

            }



我的诊断



我发现hr1中返回的int值是未注册的dll的十六进制值。
这对我来说意味着我的计算机上没有注册EZRGB。

My diagnostic

I found out that the int value returned in hr1, is the hexadecimal value for dll not registred. Which means to me that EZRGB is not registred on my computer.

在一些不起眼的网站上找到并下载了EZRGB.ax。

Found and downloaded EZRGB.ax on some obscure web site.

执行了以下命令:
cd Windows windowssyswow64
regsvr32 c:\ezrgb24.ax

executed the command : cd \windows\syswow64 regsvr32 c:\ezrgb24.ax

DllRegisterServer在c:\ezrgb24.ax中出现了一个消息框。

A message box appeared with DllRegisterServer in c:\ezrgb24.ax succeeded.

仍然不起作用。

我正在使用directshow.net,但是,这也被标记为两个directshow,因为我认为该解决方案适用于任何一种c#或c ++。

I am using directshow.net, however, this is also tagged both directshow as I feel the solution will work for either c# or c++.

推荐答案


  1. 使用可以使用 SampleCB 代替 BufferCB ;前者可让您访问进一步流式传输的数据,因此您可以对其进行修改

  2. 注册的典型问题是您构建了32位DLL,并尝试从64位开始使用它。位代码。位必须匹配。

  3. 您需要 CLSCTX_ALL CLSCTX_INPROC_SERVER

  1. Use can use SampleCB instead of BufferCB; the former provides you access to data which is streamed further, so you can modify it
  2. The typical problem with registration is that you build 32-bit DLL and you are trying to use it from 64-bit code. The bitnesses have to match.
  3. You need CLSCTX_ALL or CLSCTX_INPROC_SERVER

这篇关于如何使用EZrgb24过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆