<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Expertenfrage!! Wieso geht das nicht?]]></title><description><![CDATA[<p>Hi @all C++ Cracks,</p>
<p>ich schreibe grade ein Programm mit dem ich ein Videobild (z.B. Webcam oder TV-Karte) streamen möchte. Mein Problem ist allerdings, das ich es nicht hinbekomme den Stream zeitgleich in einem Vorschaufenster laufen zu lassen.<br />
Soll heißen.<br />
Die Streamvorschau (alleine) funktioniert.<br />
Den Stream senden (alleine) funktioniert.<br />
Erst Vorschau an, dann Stream senden: Stream senden funktioniert nicht.<br />
Erst Senden, dann Vorschau an: Vorschauf funktioniert nicht.</p>
<p>Die Skripte habe ich aus der Windows Encoder SDK.<br />
Für die Vorschau habe ich jetzt mal anstatt der normalen Encoder-Komponente eine DirektX-Komponente genommen und lasse diese in einem Thread laufen.<br />
Klappt aber auch nicht so wie ich es will. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<p>Ich poste mal die beiden Funktionen.<br />
Als erstes die Vorschau:</p>
<pre><code class="language-cpp">hr = CoInitialize(NULL);
	pEncoder= NULL;
	if ( SUCCEEDED ( hr ) )
	{
		hr = CoCreateInstance(CLSID_WMEncoder,
			NULL,
			CLSCTX_INPROC_SERVER,
			IID_IWMEncoder,
			(void**) &amp;pEncoder);
	}	

	if ( SUCCEEDED( hr ) )
	{
		hr = pEncoder-&gt;Load(CComBSTR(&quot;stream.wme&quot;));	// Hier die *.wme laden. 
	}

	// Initialize the encoding session.

	if ( SUCCEEDED( hr ) )
	{
		hr = pEncoder-&gt;PrepareToEncode(VARIANT_TRUE);
	}

    if ( SUCCEEDED( hr ) )
    {
        hr = pEncoder-&gt;Start();
	}

	MsgSenden(&quot;Die Übertragung hat begonnen!&quot;,FALSE);
	Programmabbruch();
</code></pre>
<p>Und hier die Vorschau (dies ist die Version aus der Encoder SDK)</p>
<pre><code class="language-cpp">hrVS = CoInitialize(NULL);

	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = CoCreateInstance(CLSID_WMEncoder,
			NULL,
			CLSCTX_INPROC_SERVER,
			IID_IWMEncoder,
			(void**) &amp;pEncoderVS);
	}

	// Retrieve a pointer to an IWMEncSourceGroupCollection interface.
	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pEncoderVS-&gt;get_SourceGroupCollection(&amp;pSrcGrpCollVS);
	}

	// Add a source group to the collection.
	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pSrcGrpCollVS-&gt;Add(CComBSTR(&quot;SG_1&quot;), &amp;pSrcGrpVS);
	}

	// Add a video source and an audio source.
	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pSrcGrpVS-&gt;AddSource(WMENC_VIDEO, &amp;pSrcVidVS);
	}

	// Specify the sources.
	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pSrcVidVS-&gt;SetInput(CComBSTR(&quot;Device://&quot;+m_strVideo));
	}

	// Specify the output.
	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pEncoderVS-&gt;get_Broadcast(&amp;pBrdCstVS); 
	}

	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pBrdCstVS-&gt;put_PortNumber(WMENC_PROTOCOL_HTTP, 8080);
	}

	// Select the 5th profile from the collection and set it into the source group.
	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pEncoderVS-&gt;get_ProfileCollection(&amp;pProCollVS);
	}

	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pProCollVS-&gt;Item(4, &amp;pProVS); 
	}

	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pSrcGrpVS-&gt;put_Profile(CComVariant(pProVS));
	}

	// Retrieve a pointer to a preview object.
	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = CoCreateInstance( CLSID_WMEncPreview,
			NULL,
			CLSCTX_INPROC_SERVER,
			IID_IWMEncDataView,
			(void**)&amp;pPreviewVS);
	}

	// Retrieve the preview collection.
	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pSrcVidVS-&gt;get_PreviewCollection( &amp;pPreviewCollVS );
	}

	// Add the postiew object to the data view collection. If you set the
	// cookie to -1, the encoder engine automatically generates a unique cookie.
	long lCookie = -1;
	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pPreviewCollVS-&gt;Add(pPreviewVS, &amp;lCookie);
	}

	// Continue configuring the encoder engine.
	// Initialize the encoder engine.
	// Hier tritt der Fehler auf, der Vorschau und streamen gleichzeitig nich möglich macht.
	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pEncoderVS-&gt;PrepareToEncode(VARIANT_TRUE);
	}

	// Zeichenbereich für Videovorschau
	CRect re;
	re.top = 20;
	re.bottom = re.top + 240 ;
	re.left = 550;
	re.right = re.left + 320;
	pVideo-&gt;Create(NULL,SS_ENHMETAFILE | WS_EX_TRANSPARENT,re,this,IDC_VIDEO);
	// Steuerelement für Videovorschau erzeugen

	// Handle von IDC_VIDEO übergeben.			
	HWND hControl = pVideo-&gt;GetSafeHwnd();
	pVideo-&gt;ShowWindow(TRUE);

	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pPreviewVS-&gt;SetViewSetting((DWORD) lCookie,
									 sizeof(hControl),
									(BYTE*)&amp;hControl);
	}

	// Start encoding.
	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pEncoderVS-&gt;Start();
	}

	// Start viewing the stream in a pop-up window.
	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pPreviewVS-&gt;Start(lCookie);
	}

	// Retrieve a pointer to an IWMEncDataView2 interface.
	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pPreviewVS-&gt;QueryInterface(IID_IWMEncDataView2, (void**)&amp;pPreview2VS);
	}

	// Set the view to available. 
	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pPreview2VS-&gt;put_ViewAvailable(lCookie, VARIANT_TRUE);
	}

	// Determine whether the view is available. 
	VARIANT_BOOL bIsViewAvailable;
	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pPreview2VS-&gt;get_ViewAvailable(lCookie, &amp;bIsViewAvailable);
	}

	// Setzen der Bildwiederholrate
	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pPreview2VS-&gt;put_FrameRateBalance(lCookie, VARIANT_TRUE);
	}

	// Prüfen ob die Bildwiederholrate stimmt
	VARIANT_BOOL bIsBalanced;
	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pPreview2VS-&gt;get_FrameRateBalance(lCookie, &amp;bIsBalanced);
	}

	// Prüfen ob Ansicht vorhanden ist 
	VARIANT_BOOL bIsRunning;
	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pPreview2VS-&gt;IsRunning(lCookie, &amp;bIsRunning);
	}
</code></pre>
<p>Wie Ihr seht habe ich sogar andere Variablen benutzt, wie beim Streamen<br />
pEncoderVS statt pEncoder usw.<br />
Aber wieso können die Funktionen nicht beide gleichzeitig laufen? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/72190/expertenfrage-wieso-geht-das-nicht</link><generator>RSS for Node</generator><lastBuildDate>Tue, 28 Apr 2026 08:30:36 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/72190.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 26 Apr 2004 10:31:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Expertenfrage!! Wieso geht das nicht? on Mon, 26 Apr 2004 10:31:00 GMT]]></title><description><![CDATA[<p>Hi @all C++ Cracks,</p>
<p>ich schreibe grade ein Programm mit dem ich ein Videobild (z.B. Webcam oder TV-Karte) streamen möchte. Mein Problem ist allerdings, das ich es nicht hinbekomme den Stream zeitgleich in einem Vorschaufenster laufen zu lassen.<br />
Soll heißen.<br />
Die Streamvorschau (alleine) funktioniert.<br />
Den Stream senden (alleine) funktioniert.<br />
Erst Vorschau an, dann Stream senden: Stream senden funktioniert nicht.<br />
Erst Senden, dann Vorschau an: Vorschauf funktioniert nicht.</p>
<p>Die Skripte habe ich aus der Windows Encoder SDK.<br />
Für die Vorschau habe ich jetzt mal anstatt der normalen Encoder-Komponente eine DirektX-Komponente genommen und lasse diese in einem Thread laufen.<br />
Klappt aber auch nicht so wie ich es will. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<p>Ich poste mal die beiden Funktionen.<br />
Als erstes die Vorschau:</p>
<pre><code class="language-cpp">hr = CoInitialize(NULL);
	pEncoder= NULL;
	if ( SUCCEEDED ( hr ) )
	{
		hr = CoCreateInstance(CLSID_WMEncoder,
			NULL,
			CLSCTX_INPROC_SERVER,
			IID_IWMEncoder,
			(void**) &amp;pEncoder);
	}	

	if ( SUCCEEDED( hr ) )
	{
		hr = pEncoder-&gt;Load(CComBSTR(&quot;stream.wme&quot;));	// Hier die *.wme laden. 
	}

	// Initialize the encoding session.

	if ( SUCCEEDED( hr ) )
	{
		hr = pEncoder-&gt;PrepareToEncode(VARIANT_TRUE);
	}

    if ( SUCCEEDED( hr ) )
    {
        hr = pEncoder-&gt;Start();
	}

	MsgSenden(&quot;Die Übertragung hat begonnen!&quot;,FALSE);
	Programmabbruch();
</code></pre>
<p>Und hier die Vorschau (dies ist die Version aus der Encoder SDK)</p>
<pre><code class="language-cpp">hrVS = CoInitialize(NULL);

	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = CoCreateInstance(CLSID_WMEncoder,
			NULL,
			CLSCTX_INPROC_SERVER,
			IID_IWMEncoder,
			(void**) &amp;pEncoderVS);
	}

	// Retrieve a pointer to an IWMEncSourceGroupCollection interface.
	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pEncoderVS-&gt;get_SourceGroupCollection(&amp;pSrcGrpCollVS);
	}

	// Add a source group to the collection.
	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pSrcGrpCollVS-&gt;Add(CComBSTR(&quot;SG_1&quot;), &amp;pSrcGrpVS);
	}

	// Add a video source and an audio source.
	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pSrcGrpVS-&gt;AddSource(WMENC_VIDEO, &amp;pSrcVidVS);
	}

	// Specify the sources.
	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pSrcVidVS-&gt;SetInput(CComBSTR(&quot;Device://&quot;+m_strVideo));
	}

	// Specify the output.
	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pEncoderVS-&gt;get_Broadcast(&amp;pBrdCstVS); 
	}

	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pBrdCstVS-&gt;put_PortNumber(WMENC_PROTOCOL_HTTP, 8080);
	}

	// Select the 5th profile from the collection and set it into the source group.
	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pEncoderVS-&gt;get_ProfileCollection(&amp;pProCollVS);
	}

	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pProCollVS-&gt;Item(4, &amp;pProVS); 
	}

	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pSrcGrpVS-&gt;put_Profile(CComVariant(pProVS));
	}

	// Retrieve a pointer to a preview object.
	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = CoCreateInstance( CLSID_WMEncPreview,
			NULL,
			CLSCTX_INPROC_SERVER,
			IID_IWMEncDataView,
			(void**)&amp;pPreviewVS);
	}

	// Retrieve the preview collection.
	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pSrcVidVS-&gt;get_PreviewCollection( &amp;pPreviewCollVS );
	}

	// Add the postiew object to the data view collection. If you set the
	// cookie to -1, the encoder engine automatically generates a unique cookie.
	long lCookie = -1;
	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pPreviewCollVS-&gt;Add(pPreviewVS, &amp;lCookie);
	}

	// Continue configuring the encoder engine.
	// Initialize the encoder engine.
	// Hier tritt der Fehler auf, der Vorschau und streamen gleichzeitig nich möglich macht.
	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pEncoderVS-&gt;PrepareToEncode(VARIANT_TRUE);
	}

	// Zeichenbereich für Videovorschau
	CRect re;
	re.top = 20;
	re.bottom = re.top + 240 ;
	re.left = 550;
	re.right = re.left + 320;
	pVideo-&gt;Create(NULL,SS_ENHMETAFILE | WS_EX_TRANSPARENT,re,this,IDC_VIDEO);
	// Steuerelement für Videovorschau erzeugen

	// Handle von IDC_VIDEO übergeben.			
	HWND hControl = pVideo-&gt;GetSafeHwnd();
	pVideo-&gt;ShowWindow(TRUE);

	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pPreviewVS-&gt;SetViewSetting((DWORD) lCookie,
									 sizeof(hControl),
									(BYTE*)&amp;hControl);
	}

	// Start encoding.
	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pEncoderVS-&gt;Start();
	}

	// Start viewing the stream in a pop-up window.
	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pPreviewVS-&gt;Start(lCookie);
	}

	// Retrieve a pointer to an IWMEncDataView2 interface.
	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pPreviewVS-&gt;QueryInterface(IID_IWMEncDataView2, (void**)&amp;pPreview2VS);
	}

	// Set the view to available. 
	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pPreview2VS-&gt;put_ViewAvailable(lCookie, VARIANT_TRUE);
	}

	// Determine whether the view is available. 
	VARIANT_BOOL bIsViewAvailable;
	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pPreview2VS-&gt;get_ViewAvailable(lCookie, &amp;bIsViewAvailable);
	}

	// Setzen der Bildwiederholrate
	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pPreview2VS-&gt;put_FrameRateBalance(lCookie, VARIANT_TRUE);
	}

	// Prüfen ob die Bildwiederholrate stimmt
	VARIANT_BOOL bIsBalanced;
	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pPreview2VS-&gt;get_FrameRateBalance(lCookie, &amp;bIsBalanced);
	}

	// Prüfen ob Ansicht vorhanden ist 
	VARIANT_BOOL bIsRunning;
	if ( SUCCEEDED( hrVS ) )
	{
		hrVS = pPreview2VS-&gt;IsRunning(lCookie, &amp;bIsRunning);
	}
</code></pre>
<p>Wie Ihr seht habe ich sogar andere Variablen benutzt, wie beim Streamen<br />
pEncoderVS statt pEncoder usw.<br />
Aber wieso können die Funktionen nicht beide gleichzeitig laufen? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/508943</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/508943</guid><dc:creator><![CDATA[Trikor]]></dc:creator><pubDate>Mon, 26 Apr 2004 10:31:00 GMT</pubDate></item></channel></rss>