{"id":6436,"date":"2014-04-18T05:22:27","date_gmt":"2014-04-18T05:22:27","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/18\/asf-profile-configurations-fails-collection-of-common-programming-errors\/"},"modified":"2014-04-18T05:22:27","modified_gmt":"2014-04-18T05:22:27","slug":"asf-profile-configurations-fails-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/18\/asf-profile-configurations-fails-collection-of-common-programming-errors\/","title":{"rendered":"Asf profile configurations fails.-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn Hello,I am trying to set profile on asfwriter , my code below. it fails what is wrong?<\/p>\n<pre>IWMProfile *currentProfile;  \n\n        hr = profileManager-&gt;LoadProfileByID(WMProfile_V80_28856VideoMBR, &amp;currentProfile);\n        if (FAILED(hr))\n        {\n                Msg(TEXT(\"Failed to ConfigureFilterUsingProfileGuid !  hr=0x%x\"), hr);\n                return hr;\n        }\n        \/\/ Apply the configuration  \n\n\n        hr = mpWriterConfig-&gt;ConfigureFilterUsingProfile(currentProfile);  \n        if (FAILED(hr))  \/\/ Fails.\n        {\n                Msg(TEXT(\"Failed to ConfigureFilterUsingProfileGuid !  hr=0x%x\"), hr);\n                return hr;\n        }<\/pre>\n<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn1<\/p>\n<ul>\n<li>did you check this &#8220;You must add the WM ASF Writer filter to the filter graph before configuring the filter, and configure the filter before connecting it to any other filters.&#8221;<\/li>\n<li>you still have uninitialized fields, just break with the debugger on SetMediaType and check them in Watch debug window<\/li>\n<\/ul>\n<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn2<\/p>\n<p>it is E_FAIL.<\/p>\n<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn3 If you don&#8217;t find the reason why this exactly profile does not load, you might wish to try using version 9 profiles. You are obviously loading profile version 8 here and I am not sure it you explicitly initializing profile manager to certain version and if you at all added filter to your graph prior to your attempt to set it up. For version WM Format version 9 you don&#8217;t have predefined profiles accessible by ID. Instead you can generate a profile using WMF SDK utility (Profile Editor?) and load it as XML into your IWMProfile object, then use it to configure WM ASF Writer. The problem may also be that the profile you are trying to load is in some way incompatible with WM ASF Writer. Also make sure you are OK with this:<\/p>\n<blockquote><p>It is recommended to create a custom profile that uses the Windows Media 9 Series codecs, and configure the WM ASF Writer with the custom profile, as described in Configuring Profiles and Other ASF File Properties . You must add the WM ASF Writer filter to the filter graph before configuring the filter, and configure the filter before connecting it to any other filters.<\/p><\/blockquote>\n<p>http:\/\/alax.info\/blog\/tag\/directshow<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn4<\/p>\n<p>Possibly\u00a0you are rightt.\u00a0How do I load prx file, generated by WMGenProfile into my IWMProfile\u00a0 object? Do you have a code sample for this? it is realy helps. I googled but found nothing the way to do it.<\/p>\n<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn6<\/p>\n<p>I try to capture and send webcam view, Can&#8217;t I load profile directly from code, for only test purposes. i mean,creating prx content from code and loadprofile, i see some code snippets around but i can&#8217;t figure it out.<\/p>\n<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn8 Hello Roman, With the your help\u00a0and msdn , I came up with a code sequence below, i am still having E_FAIL from ConfigureFilterUsingProfile.<\/p>\n<pre> IWMProfileManager *profileManager;  \n        IWMStreamConfig * pWMStreamConfig; \n\n        hr = WMCreateProfileManager(&amp;profileManager);  \n        if (FAILED(hr))\n        {\n                Msg(TEXT(\"Failed to ConfigureFilterUsingProfileGuid !  hr=0x%x\"), hr);\n                return hr;\n        }\n\n        IWMProfile *pProfile;  \n        \n        hr = profileManager-&gt;CreateEmptyProfile(WMT_VER_9_0,  &amp;pProfile);\n        if (FAILED(hr))\n        {\n                Msg(TEXT(\"Failed to ConfigureFilterUsingProfileGuid !  hr=0x%x\"), hr);\n                return hr;\n        }\n        hr = pProfile-&gt;CreateNewStream(WMMEDIATYPE_Video, &amp;pWMStreamConfig);\n        if (FAILED(hr))\n        {\n                Msg(TEXT(\"Failed to ConfigureFilterUsingProfileGuid !  hr=0x%x\"), hr);\n                return hr;\n        }\n        IWMVideoMediaProps *pProps;\n        hr = pWMStreamConfig-&gt;QueryInterface(IID_IWMVideoMediaProps,(void**)&amp;pProps);\n        if (FAILED(hr))\n        {\n                Msg(TEXT(\"Failed to ConfigureFilterUsingProfileGuid !  hr=0x%x\"), hr);\n                return hr;\n        }\n        WM_MEDIA_TYPE wmt;\n        wmt.subtype = WMMEDIASUBTYPE_WMV3;\n        pProps-&gt;SetMediaType(&amp;wmt);\n        if (FAILED(hr))\n        {\n                Msg(TEXT(\"Failed to ConfigureFilterUsingProfileGuid !  hr=0x%x\"), hr);\n                return hr;\n        }\n\n        hr = mpWriterConfig-&gt;ConfigureFilterUsingProfile(pProfile); \/\/ Fails \n        if (FAILED(hr))\n        {\n                Msg(TEXT(\"Failed to ConfigureFilterUsingProfileGuid !  hr=0x%x\"), hr);\n                return hr;\n        }<\/pre>\n<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn9<\/p>\n<blockquote><p>Hello Roman, With the your help\u00a0and msdn , I came up with a code sequence below, i am still having E_FAIL from ConfigureFilterUsingProfile.<\/p>\n<pre>   WM_MEDIA_TYPE wmt; wmt.subtype = WMMEDIASUBTYPE_WMV3; pProps-&gt;SetMediaType(&amp;wmt);\n<br \/>\n<\/pre>\n<\/blockquote>\n<p>Well I doubt this is going to work, you need to fully initialize this. It has a number of fields and you are coming up with a stack junk and one member only initialized (subtype).<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn10 Hello Roman, according to your answer, i reviewed and\u00a0 initialized fields like in code snippet. But I can&#8217;t imagine how some fields should be initialized. I have commented them in code. Still having the error. I have borrowed some values from Profile Generator ( from SDK)\u00a0with Windows Media Codec 9 Selected.<\/p>\n<pre>   pProps-&gt;SetQuality(100);\n\n        WMVIDEOINFOHEADER vi;\n        vi.dwBitRate =100000;\n        \/\/vi.rcSource =  what should it to be,  it comes from webcam?   \n        \/\/vi.rcTarget  ?\n        vi.AvgTimePerFrame = 30;\n        \/\/vi.bmiHeader  ?  where to find which field what to be\n        \n        WM_MEDIA_TYPE wmt;\n        \n        wmt.subtype = WMMEDIASUBTYPE_WMV3;\n        wmt.majortype = WMMEDIATYPE_Video;\n        wmt.bFixedSizeSamples = false;\n        wmt.bTemporalCompression = true;\n        wmt.lSampleSize = 100; \/\/ no need actaully when  bFixedSizeSamples is false from msdn\n        wmt.pbFormat = (BYTE *)&amp;vi;\n        wmt.formattype = WMFORMAT_VideoInfo;\n        wmt.cbFormat = sizeof(vi);\n        wmt.pUnk = NULL;<\/pre>\n<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn12 No chance , i am stil having same error at the same point. My new configuration is :<\/p>\n<pre>   pProps-&gt;SetQuality(100);\n\n         VIDEOINFOHEADER VideoInfoHeader;\n        VideoInfoHeader.dwBitRate = 1000000000000000;\n        VideoInfoHeader.dwBitErrorRate =1;\n        VideoInfoHeader.AvgTimePerFrame = (REFERENCE_TIME) (1 * 1000 * 10000 \/10000000000000); \n            RECT rcDst2;\n            SetRect(&amp;rcDst2, 0, 0, 240, 200);\n        VideoInfoHeader.bmiHeader.biWidth = rcDst2.right; \n        VideoInfoHeader.bmiHeader.biHeight = rcDst2.bottom; \n        VideoInfoHeader.bmiHeader.biSizeImage = 0; \n                VideoInfoHeader.bmiHeader.biSize = sizeof(VideoInfoHeader.bmiHeader);\n        \n                VideoInfoHeader.bmiHeader.biPlanes = 1;\n                \n    WM_MEDIA_TYPE *pType = new WM_MEDIA_TYPE();\n            \n        pType-&gt;majortype =WMMEDIATYPE_Video;\n        pType-&gt;subtype  = WMMEDIASUBTYPE_WMV3;\n        pType-&gt;bFixedSizeSamples = FALSE;\n        pType-&gt;bTemporalCompression = TRUE;\n        pType-&gt;lSampleSize = 0;\n        pType-&gt;formattype = WMFORMAT_VideoInfo;\n        pType-&gt;pUnk = NULL;\n        pType-&gt;cbFormat = sizeof(VIDEOINFOHEADER);\n        pType-&gt;pbFormat = (BYTE*) &amp;VideoInfoHeader; \n\n        \n        pProps-&gt;SetMediaType(pType);\n        if (FAILED(hr))\n        {\n                Msg(TEXT(\"Failed to ConfigureFilterUsingProfileGuid !  hr=0x%x\"), hr);\n                return hr;\n        }\n        \n        hr = mpWriterConfig-&gt;ConfigureFilterUsingProfile(pProfile); \/\/ At this point E_FAIL error. \n        if (FAILED(hr))\n        {\n                Msg(TEXT(\"Failed to ConfigureFilterUsingProfileGuid !  hr=0x%x\"), hr);\n                return hr;\n        }<\/pre>\n<p>Can be cause of error something else? My computer running Windows 7 64 bit, can it be a problem for directshow? I have installed all the sdks required for WM and DShow.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn13<\/p>\n<ul>\n<li>did you check this &#8220;You must add the WM ASF Writer filter to the filter graph before configuring the filter, and configure the filter before connecting it to any other filters.&#8221;<\/li>\n<li>you still have uninitialized fields, just break with the debugger on SetMediaType and check them in Watch debug window<\/li>\n<\/ul>\n<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn14 Hello and Tahnk you Roman,I applied your first check , it is give error but with a -1072886842 result. I think, \u00a0it is an advance. My all capture code sequence and my watch window like below now with latest inits of variables.\u00a0 My Code sequence:<\/p>\n<pre><br \/>HRESULT hr;\n        IBaseFilter *pSrcFilter=NULL;\n        IBaseFilter *pASFWriter = NULL; \/\/ WM ASF File filter\n        IFileSinkFilter2 *pSink = NULL; \/\/ File sink object\n        IWMWriterAdvanced2 *pWMWA2 = NULL;\n        IServiceProvider *pProvider;\n        IConfigAsfWriter *mpWriterConfig = NULL;\n\n        \/\/ Get DirectShow interfaces\n        hr = GetInterfaces();\n        if (FAILED(hr))\n        {\n                Msg(TEXT(\"Failed to get video interfaces!  hr=0x%x\"), hr);\n                return hr;\n        }\n        hr = CoCreateInstance (CLSID_WMAsfWriter, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void **) &amp;pASFWriter);   \n\n        hr =  g_pGraph-&gt;AddFilter (pASFWriter, L\"ASF Writer\");   \n        if (FAILED(hr))\n        {\n                Msg(TEXT(\"Failed to CLSID_WMAsfWriter AddFilter!  hr=0x%x\"), hr);\n                return hr;\n        }\n\n        if (FAILED(hr))\n        {\n                Msg(TEXT(\"Failed to CLSID_WMAsfWriter!  hr=0x%x\"), hr);\n                return hr;\n        }\n\n        hr = pASFWriter-&gt;QueryInterface(IID_IConfigAsfWriter, (void**)&amp;mpWriterConfig);  \n        if (FAILED(hr))\n        {\n                Msg(TEXT(\"Failed to ConfigureFilterUsingProfileGuid !  hr=0x%x\"), hr);\n                return hr;\n        }        \n        IWMProfileManager *profileManager;  \n        IWMStreamConfig * pWMStreamConfig; \n\n        hr = WMCreateProfileManager(&amp;profileManager);  \n        if (FAILED(hr))\n        {\n                Msg(TEXT(\"Failed to ConfigureFilterUsingProfileGuid !  hr=0x%x\"), hr);\n                return hr;\n        }\n\n        IWMProfile *pProfile;  \n        \n        hr = profileManager-&gt;CreateEmptyProfile(WMT_VER_9_0,  &amp;pProfile);\n        if (FAILED(hr))\n        {\n                Msg(TEXT(\"Failed to ConfigureFilterUsingProfileGuid !  hr=0x%x\"), hr);\n                return hr;\n        }\n        hr = pProfile-&gt;CreateNewStream(WMMEDIATYPE_Video, &amp;pWMStreamConfig);\n        if (FAILED(hr))\n        {\n                Msg(TEXT(\"Failed to ConfigureFilterUsingProfileGuid !  hr=0x%x\"), hr);\n                return hr;\n        }\n        IWMVideoMediaProps *pProps;\n        hr = pWMStreamConfig-&gt;QueryInterface(IID_IWMVideoMediaProps,(void**)&amp;pProps);\n        if (FAILED(hr))\n        {\n                Msg(TEXT(\"Failed to ConfigureFilterUsingProfileGuid !  hr=0x%x\"), hr);\n                return hr;\n        }\n        pProps-&gt;SetQuality(100);\n\n         VIDEOINFOHEADER VideoInfoHeader;\n        VideoInfoHeader.dwBitRate = 1000000000000000;\n        VideoInfoHeader.dwBitErrorRate =1;\n        VideoInfoHeader.AvgTimePerFrame = (REFERENCE_TIME) (1 * 1000 * 10000 \/10000000000000); \n            RECT rcDst2;\n            SetRect(&amp;rcDst2, 0, 0, 240, 200);\n                        SetRect(&amp;VideoInfoHeader.rcSource,  0, 0,640,480);\n                        VideoInfoHeader.rcTarget = rcDst2;\n        VideoInfoHeader.bmiHeader.biWidth = rcDst2.right; \n        VideoInfoHeader.bmiHeader.biHeight = rcDst2.bottom; \n        VideoInfoHeader.bmiHeader.biSizeImage = 0; \n                VideoInfoHeader.bmiHeader.biSize = sizeof(VideoInfoHeader.bmiHeader);\n        VideoInfoHeader.bmiHeader.biXPelsPerMeter = 0;\n        VideoInfoHeader.bmiHeader.biYPelsPerMeter = 0;\n        VideoInfoHeader.bmiHeader.biClrImportant = 0;\n        VideoInfoHeader.bmiHeader.biClrUsed = 0;\n                VideoInfoHeader.bmiHeader.biPlanes = 1;\n                VideoInfoHeader.bmiHeader.biCompression =  0x56595559;\n\n    WM_MEDIA_TYPE *pType = new WM_MEDIA_TYPE();\n            \n        pType-&gt;majortype =WMMEDIATYPE_Video;\n        pType-&gt;subtype  = WMMEDIASUBTYPE_WMV3;\n        pType-&gt;bFixedSizeSamples = FALSE;\n        pType-&gt;bTemporalCompression = TRUE;\n        pType-&gt;lSampleSize = 0;\n        pType-&gt;formattype = WMFORMAT_VideoInfo;\n        pType-&gt;pUnk = NULL;\n        pType-&gt;cbFormat = sizeof(VIDEOINFOHEADER);\n        pType-&gt;pbFormat = (BYTE*) &amp;VideoInfoHeader; \n\n        \n        pProps-&gt;SetMediaType(pType);\n        if (FAILED(hr))\n        {\n                Msg(TEXT(\"Failed to ConfigureFilterUsingProfileGuid !  hr=0x%x\"), hr);\n                return hr;\n        }\n        \n        hr = mpWriterConfig-&gt;ConfigureFilterUsingProfile(pProfile);  \n        if (FAILED(hr))\n        {\n                Msg(TEXT(\"Failed to ConfigureFilterUsingProfileGuid !  hr=0x%x\"), hr);\n                return hr;\n        }\n        \/\/hr = mpWriterConfig-&gt;ConfigureFilterUsingProfileGuid(WMProfile_V40_250Video);\n\n        if (FAILED(hr))\n        {\n                Msg(TEXT(\"Failed to ConfigureFilterUsingProfileGuid !  hr=0x%x\"), hr);\n                return hr;\n        }\n\n        \n\n        hr = pASFWriter-&gt;QueryInterface(IID_IServiceProvider, (void**)&amp;pProvider);\n        if (SUCCEEDED(hr))\n        {\n                hr = pProvider-&gt;QueryService(IID_IWMWriterAdvanced2,\n                        IID_IWMWriterAdvanced2, (void**)&amp;pWMWA2);\n        }\n\n        if (FAILED(hr = pWMWA2-&gt;SetLiveSource(TRUE)))\n        {\n                printf (\"mpWriter2-&gt;SetLiveSource FAILED\\n\");\n                return hr;\n        } \n\n        IWMWriterFileSink*      m_pFileSink;\n\n        hr = WMCreateWriterFileSink( &amp;m_pFileSink );\n        if ( FAILED( hr ) )\n        {\n                _tprintf( _T( \"Could not create Writer File Sink (hr=0x%08x).\\n\" ), hr );\n                return hr;\n        }\n\n        m_pFileSink-&gt;Open (L\"test.asf\");\n        if ( FAILED( hr ) )\n        {\n                _tprintf( _T( \"Could not create Writer File Sink (hr=0x%08x).\\n\" ), hr );\n                return hr;\n        }\n\n        pWMWA2-&gt;AddSink(m_pFileSink);\n        if ( FAILED( hr ) )\n        {\n                _tprintf( _T( \"Could not create Writer File Sink (hr=0x%08x).\\n\" ), hr );\n                return hr;\n        }\n\n\n        \/\/ remove default sink... added back later dynamically\n        if (FAILED(hr = pWMWA2-&gt;RemoveSink(0)))\n        {\n                printf (\" mpWriter2-&gt;RemoveSink FAILED\\n\");\n                return hr;\n        } \n\n        pProvider-&gt;Release();\n\n        IWMWriterNetworkSink *mpNetSink = NULL;\n\n        if (FAILED(hr = WMCreateWriterNetworkSink(&amp;mpNetSink)))\n        {\n                printf (\"WMCreateWriterNetworkSink FAILED\\n\");\n                return hr;\n        } \n\n        DWORD dwPort = 1234;\n\n\n\n\n        if (FAILED(hr = mpNetSink-&gt;Open(&amp;dwPort)))\n        {\n                printf (\"Port open FAILED\\n\");\n                return hr;\n        } \n\n        WCHAR url[256];\n        DWORD url_len = 256;\n\n        hr = mpNetSink-&gt;GetHostURL(url, &amp;url_len);\n\n\n        if (FAILED(pWMWA2-&gt;AddSink(mpNetSink)))\n        {\n                printf (\"mpWriter2-&gt;AddSink FAILED\\n\");\n                return hr;\n        }\n\n\n\n        \/\/ Attach the filter graph to the capture graph\n        hr = g_pCapture-&gt;SetFiltergraph(g_pGraph);\n        if (FAILED(hr))\n        {\n                Msg(TEXT(\"Failed to set capture filter graph!  hr=0x%x\"), hr);\n                return hr;\n        }\n\n        \/\/ Use the system device enumerator and class enumerator to find\n        \/\/ a video capture\/preview device, such as a desktop USB video camera.\n        hr = FindCaptureDevice(&amp;pSrcFilter);\n        if (FAILED(hr))\n        {\n                \/\/ Don't display a message because FindCaptureDevice will handle it\n                return hr;\n        }\n\n        \/\/ Add Capture filter to our graph.\n        hr = g_pGraph-&gt;AddFilter(pSrcFilter, L\"Video Capture\");\n        if (FAILED(hr))\n        {\n                Msg(TEXT(\"Couldn't add the capture filter to the graph!  hr=0x%x\\r\\n\\r\\n\") \n                        TEXT(\"If you have a working video capture device, please make sure\\r\\n\")\n                        TEXT(\"that it is connected and is not being used by another application.\\r\\n\\r\\n\")\n                        TEXT(\"The sample will now close.\"), hr);\n                pSrcFilter-&gt;Release();\n                return hr;\n        }\n\n        \/\/ Render the preview pin on the video capture filter\n        \/\/ Use this instead of g_pGraph-&gt;RenderFile\n        hr = g_pCapture-&gt;RenderStream (&amp;PIN_CATEGORY_PREVIEW, &amp;MEDIATYPE_Video,\n                pSrcFilter, NULL, NULL);\n\n        hr = g_pCapture-&gt;RenderStream (&amp;PIN_CATEGORY_CAPTURE, &amp;MEDIATYPE_Video,\n                pSrcFilter, NULL, pASFWriter);\n\n        if (FAILED(hr))\n        {\n                Msg(TEXT(\"Couldn't render the video capture stream.  hr=0x%x\\r\\n\")\n                        TEXT(\"The capture device may already be in use by another application.\\r\\n\\r\\n\")\n                        TEXT(\"The sample will now close.\"), hr);\n                pSrcFilter-&gt;Release();\n                return hr;\n        }\n\n        \/\/ Now that the filter has been added to the graph and we have\n        \/\/ rendered its stream, we can release this reference to the filter.\n        pSrcFilter-&gt;Release();\n\n\n        \/\/ Set video window style and position\n        hr = SetupVideoWindow();\n        if (FAILED(hr))\n        {\n                Msg(TEXT(\"Couldn't initialize video window!  hr=0x%x\"), hr);\n                return hr;\n        }\n\n#ifdef REGISTER_FILTERGRAPH\n        \/\/ Add our graph to the running object table, which will allow\n        \/\/ the GraphEdit application to \"spy\" on our graph\n        hr = AddGraphToRot(g_pGraph, &amp;g_dwGraphRegister);\n        if (FAILED(hr))\n        {\n                Msg(TEXT(\"Failed to register filter graph with ROT!  hr=0x%x\"), hr);\n                g_dwGraphRegister = 0;\n        }\n#endif\n\n        \/\/ Start previewing video data\n        hr = g_pMC-&gt;Run();\n\n\n        if (FAILED(hr))\n        {\n                Msg(TEXT(\"Couldn't run the graph!  hr=0x%x\"), hr);\n                return hr;\n        }\n\n        \/\/ Remember current state\n        g_psCurrent = Running;\n\n        return S_OK;\n<\/pre>\n<p>My watch:<\/p>\n<pre>          hr      -1072886842     HRESULT\n-               pType   0x00908160 {majortype={...} subtype={...} bFixedSizeSamples=0 ...}      _WMMediaType *\n-               majortype       {73646976-0000-0010-8000-00AA00389B71}  _GUID\n                Data1   1935960438      unsigned long\n                Data2   0       unsigned short\n                Data3   16      unsigned short\n+               Data4   0x00908168 \"\u20ac\" unsigned char [8]\n-               subtype {33564D57-0000-0010-8000-00AA00389B71}  _GUID\n                Data1   861293911       unsigned long\n                Data2   0       unsigned short\n                Data3   16      unsigned short\n+               Data4   0x00908178 \"\u20ac\" unsigned char [8]\n                bFixedSizeSamples       0       int\n                bTemporalCompression    1       int\n                lSampleSize     0       unsigned long\n-               formattype      {CLSID_KsDataTypeHandlerVideo}  _GUID\n                Data1   89694080        unsigned long\n                Data2   50006   unsigned short\n                Data3   4558    unsigned short\n+               Data4   0x00908194 \"\u00bf\"   unsigned char [8]\n+               pUnk    0x00000000      IUnknown *\n                cbFormat        88      unsigned long\n+               pbFormat        0x0034f058 \"\" unsigned char *\n-               VideoInfoHeader {rcSource={...} rcTarget={...} dwBitRate=2764472320 ...}        tagVIDEOINFOHEADER\n-               rcSource        {top=0 bottom=480 left=0 right=640}     tagRECT\n                left    0       long\n                top     0       long\n                right   640     long\n                bottom  480     long\n-               rcTarget        {top=0 bottom=200 left=0 right=240}     tagRECT\n                left    0       long\n                top     0       long\n                right   240     long\n                bottom  200     long\n                dwBitRate       2764472320      unsigned long\n                dwBitErrorRate  1       unsigned long\n                AvgTimePerFrame 0       __int64\n-               bmiHeader       {biSize=40 biWidth=240 biHeight=200 ...}        tagBITMAPINFOHEADER\n                biSize  40      unsigned long\n                biWidth 240     long\n                biHeight        200     long\n                biPlanes        1       unsigned short\n                biBitCount      52428   unsigned short\n                biCompression   1448695129      unsigned long\n                biSizeImage     0       unsigned long\n                biXPelsPerMeter 0       long\n                biYPelsPerMeter 0       long\n                biClrUsed       0       unsigned long\n                biClrImportant  0       unsigned long\n<\/pre>\n<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn15<\/p>\n<blockquote><p>Hello and Tahnk you Roman, I applied your first check , it is give error but with a -1072886842 result. I think, \u00a0it is an advance. My all capture code sequence and my watch window like below now with latest inits of variables.\u00a0 tagVIDEOINFOHEADER &#8211; rcSource {top=0 bottom=480 left=0 right=640} tagRECT left 0 long top 0 long right 640 long bottom 480 long &#8211; rcTarget {top=0 bottom=200 left=0 right=240} tagRECT left 0 long top 0 long right 240 long bottom 200 {biSize=40 biWidth=240 biHeight=200 &#8230;}<\/p><\/blockquote>\n<p>Error code is 0xC00D0BC6 &#8220;The Profile is invalid.&#8221;, so you passed previous problem and stumbled on a new one. This time you have something wrong in the profile. I am not sure what exactly causes this, but you have a mismatch in mentioned resolutions, this may be the problem.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn16 Hello Roman,I bypassed all my custom profile and used a system stock profile , now it gives me 0xc00d1b5e error,<\/p>\n<pre>hr = mpWriterConfig-&gt;ConfigureFilterUsingProfileGuid(WMProfile_V40_250Video);<\/pre>\n<p>i googled this error and i found NS_E_NOMATCHING_ELEMENT description. What does it mean?\u00a0<\/p>\n<p>also with matched resolutions ,my custom profile gave the same error : 0xC00D0BC6.<\/p>\n<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn17 hello Roman,<\/p>\n<p>With WMProfile_V70_56VideoWebServer profile\u00a0, passed config problem, but my graph didn&#8217;t run giving 0x8007007b error.<\/p>\n<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn18<\/p>\n<blockquote><p>hello Roman,<\/p>\n<p>With WMProfile_V70_56VideoWebServer profile\u00a0, passed config problem, but my graph didn&#8217;t run giving 0x8007007b error.<\/p>\n<\/blockquote>\n<p>It is ERROR_INVALID_NAME &#8220;The filename, directory name, or volume label syntax is incorrect.&#8221; did you provide file name to the filter so that it knows where it is expected to write to?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn19 I used this code to define filename:<\/p>\n<pre> m_pFileSink-&gt;Open (L\"test.asf\");\n        if ( FAILED( hr ) )\n        {\n                _tprintf( _T( \"Could not create Writer File Sink (hr=0x%08x).\\n\" ), hr );\n                return hr;\n        }<\/pre>\n<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn20 Don&#8217;t add an extra file sink explicitly, that will make a mess.<\/p>\n<p>Instead, set the initial filename with IFileSinkFilter::SetFileName(). \u00a0Once the name is set then you can remove the default sink and add a network sink.<\/p>\n<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn21 With your lights, my final code, and it gives\u00a0E_FAIL error with code 0x80004005 at the media control run. I returned to first error , but with a more accurate code I think.<\/p>\n<p>At this line hr = g_pMC-&gt;Run(); \/\/ E_FAIL 0x80004005<\/p>\n<p>it fails.<\/p>\n<pre>      HRESULT hr; IBaseFilter *pSrcFilter=NULL; IBaseFilter *pASFWriter = NULL; \/\/ WM ASF File filter IFileSinkFilter2 *pSink = NULL; \/\/ File sink object IWMWriterAdvanced2 *pWMWA2 = NULL; IServiceProvider *pProvider; IConfigAsfWriter *mpWriterConfig = NULL; \/\/ Get DirectShow interfaces hr = GetInterfaces(); if (FAILED(hr)) { Msg(TEXT(\"Failed to get video interfaces! hr=0x%x\"), hr); return hr; } hr = CoCreateInstance (CLSID_WMAsfWriter, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void **) &amp;pASFWriter); hr = g_pGraph-&gt;AddFilter (pASFWriter, L\"ASF Writer\"); if (FAILED(hr)) { Msg(TEXT(\"Failed to CLSID_WMAsfWriter AddFilter! hr=0x%x\"), hr); return hr; } hr = pASFWriter-&gt;QueryInterface(IID_IConfigAsfWriter, (void**)&amp;mpWriterConfig); if (FAILED(hr)) { Msg(TEXT(\"Failed to ConfigureFilterUsingProfileGuid ! hr=0x%x\"), hr); return hr; } hr = mpWriterConfig-&gt;ConfigureFilterUsingProfileGuid(WMProfile_V70_56VideoWebServer); if (FAILED(hr)) { Msg(TEXT(\"Failed to ConfigureFilterUsingProfileGuid ! hr=0x%x\"), hr); return hr; } hr = pASFWriter-&gt;QueryInterface(IID_IServiceProvider, (void**)&amp;pProvider); if (SUCCEEDED(hr)) { hr = pProvider-&gt;QueryService(IID_IWMWriterAdvanced2, IID_IWMWriterAdvanced2, (void**)&amp;pWMWA2); } if (FAILED(hr = pWMWA2-&gt;SetLiveSource(TRUE))) { printf (\"mpWriter2-&gt;SetLiveSource FAILED\\n\"); return hr; } IFileSinkFilter *pFileSink; hr = pASFWriter-&gt;QueryInterface(IID_IFileSinkFilter , (void**)&amp;pFileSink); if (FAILED(hr)) { Msg(TEXT(\"Failed to ConfigureFilterUsingProfileGuid ! hr=0x%x\"), hr); return hr; } AM_MEDIA_TYPE am_media_type; ZeroMemory(&amp;am_media_type, sizeof(am_media_type)); am_media_type.majortype = MEDIATYPE_Video; am_media_type.subtype = MEDIASUBTYPE_RGB24; am_media_type.formattype = FORMAT_VideoInfo; hr = pFileSink-&gt;SetFileName(L\"test.asf\", &amp;am_media_type); if (FAILED(hr)) { Msg(TEXT(\"Failed to SetFileName ! hr=0x%x\"), hr); return hr; } \/\/ remove default sink... added back later dynamically if (FAILED(hr = pWMWA2-&gt;RemoveSink(0))) { printf (\" mpWriter2-&gt;RemoveSink FAILED\\n\"); return hr; } pProvider-&gt;Release(); IWMWriterNetworkSink *mpNetSink = NULL; if (FAILED(hr = WMCreateWriterNetworkSink(&amp;mpNetSink))) { printf (\"WMCreateWriterNetworkSink FAILED\\n\"); return hr; } DWORD dwPort = 1234; if (FAILED(hr = mpNetSink-&gt;Open(&amp;dwPort))) { printf (\"Port open FAILED\\n\"); return hr; } WCHAR url[256]; DWORD url_len = 256; hr = mpNetSink-&gt;GetHostURL(url, &amp;url_len); if (FAILED(pWMWA2-&gt;AddSink(mpNetSink))) { printf (\"mpWriter2-&gt;AddSink FAILED\\n\"); return hr; } \/\/ Attach the filter graph to the capture graph hr = g_pCapture-&gt;SetFiltergraph(g_pGraph); if (FAILED(hr)) { Msg(TEXT(\"Failed to set capture filter graph! hr=0x%x\"), hr); return hr; } \/\/ Use the system device enumerator and class enumerator to find \/\/ a video capture\/preview device, such as a desktop USB video camera. hr = FindCaptureDevice(&amp;pSrcFilter); if (FAILED(hr)) { \/\/ Don't display a message because FindCaptureDevice will handle it return hr; } \/\/ Add Capture filter to our graph. hr = g_pGraph-&gt;AddFilter(pSrcFilter, L\"Video Capture\"); if (FAILED(hr)) { Msg(TEXT(\"Couldn't add the capture filter to the graph! hr=0x%x\\r\\n\\r\\n\") TEXT(\"If you have a working video capture device, please make sure\\r\\n\") TEXT(\"that it is connected and is not being used by another application.\\r\\n\\r\\n\") TEXT(\"The sample will now close.\"), hr); pSrcFilter-&gt;Release(); return hr; } \/\/ Render the preview pin on the video capture filter \/\/ Use this instead of g_pGraph-&gt;RenderFile hr = g_pCapture-&gt;RenderStream (&amp;PIN_CATEGORY_PREVIEW, &amp;MEDIATYPE_Video, pSrcFilter, NULL, NULL); hr = g_pCapture-&gt;RenderStream (&amp;PIN_CATEGORY_CAPTURE, &amp;MEDIATYPE_Video, pSrcFilter, NULL, pASFWriter); if (FAILED(hr)) { Msg(TEXT(\"Couldn't render the video capture stream. hr=0x%x\\r\\n\") TEXT(\"The capture device may already be in use by another application.\\r\\n\\r\\n\") TEXT(\"The sample will now close.\"), hr); pSrcFilter-&gt;Release(); return hr; } \/\/ Now that the filter has been added to the graph and we have \/\/ rendered its stream, we can release this reference to the filter. pSrcFilter-&gt;Release(); \/\/ Set video window style and position hr = SetupVideoWindow(); if (FAILED(hr)) { Msg(TEXT(\"Couldn't initialize video window! hr=0x%x\"), hr); return hr; } #ifdef REGISTER_FILTERGRAPH \/\/ Add our graph to the running object table, which will allow \/\/ the GraphEdit application to \"spy\" on our graph hr = AddGraphToRot(g_pGraph, &amp;g_dwGraphRegister); if (FAILED(hr)) { Msg(TEXT(\"Failed to register filter graph with ROT! hr=0x%x\"), hr); g_dwGraphRegister = 0; } #endif <br \/>     \/\/ Start previewing video data\n        hr = g_pMC-&gt;Run(); \/\/ E_FAIL 0x80004005\n\n\n        if (FAILED(hr))\n        {\n                Msg(TEXT(\"Couldn't run the graph!  hr=0x%x\"), hr);\n                return hr;\n        }\n\n        \/\/ Remember current state\n        g_psCurrent = Running;\n\n        return S_OK;<\/pre>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>msdn Hello,I am trying to set profile on asfwriter , my code below. it fails what is wrong? IWMProfile *currentProfile; hr = profileManager-&gt;LoadProfileByID(WMProfile_V80_28856VideoMBR, &amp;currentProfile); if (FAILED(hr)) { Msg(TEXT(&#8220;Failed to ConfigureFilterUsingProfileGuid ! hr=0x%x&#8221;), hr); return hr; } \/\/ Apply the configuration hr = mpWriterConfig-&gt;ConfigureFilterUsingProfile(currentProfile); if (FAILED(hr)) \/\/ Fails. { Msg(TEXT(&#8220;Failed to ConfigureFilterUsingProfileGuid ! hr=0x%x&#8221;), hr); return [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6436","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6436","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=6436"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6436\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=6436"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=6436"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=6436"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}