Note that there are some explanatory texts on larger screens.

plurals
  1. POOffset parameter passed into IMediaFilter::Run
    text
    copied!<p>I was trying to play multiple graphs simultaneously with directshow. After doing some research, I found Geraint Davies' awesome solution at <a href="https://stackoverflow.com/questions/1299385/how-to-play-multiple-videos-in-sync-over-multiple-monitors-using-directshow">How to play multiple videos in sync over multiple monitors using directshow?</a></p> <blockquote> <ol> <li>Pick one graph as the master.</li> <li>Make sure the master has a clock. This is normally done when going active, but you can force it to happen earlier by calling SetDefaultSyncSource on the graph.</li> <li>Query the graphs for IMediaFilter, get the clock from the master graph using GetSyncSource and pass it to the other graphs using SetSyncSource.</li> <li>Pause all the graphs.</li> <li>Wait until GetState returns S_OK (the pause is complete).</li> <li>Get the time from the graph and add 10ms or so.</li> <li>Call IMediaFilter::Run on all graphs, passing this time (now + 10ms) as the parameter.</li> </ol> </blockquote> <p>The results turned out pretty good, the video looked in sync visually. However, something really bothered me when I was testing with IMediaFilter::Run.</p> <p>I tried to pass in a large offset value into IMediaFilter::Run such as (now + 1000ms), the video still seems to start immediately visually instead of delaying 1000ms before it starts.</p> <p>Is this behavior normal or I am doing something wrong?</p> <p><strong>Edit: Thank you for your quick reply, Roman R. I assume when you say "video time", you mean timestamp? I will check them out right away.</strong></p> <p><strong>Edit: The video doesn't only show the first frame, it just plays normally without any delay. I also posted some rough code of what I did. Hope someone can shed some light on it.</strong></p> <pre><code> CComQIPtr&lt;IMediaFilter&gt;pMasterF(m_pMasterGraphBuilder); CComQIPtr&lt;IMediaFilter&gt;pSlaveF(m_pSlaveGraphBuilder); IReferenceClock* pClock; HRESULT clkHR = pMasterF-&gt;GetSyncSource(&amp;pClock); // Get Master Clock pSlaveF-&gt;SetSyncSource(pClock); //Set slave to Master Clock pMasterF-&gt;Pause(); //Pause Master pSlaveF-&gt;Pause(); // Pause slave FILTER_STATE sFs; HRESULT hrcue; hrcue = pMasterF-&gt;GetState(0, &amp;sFs); while(hrcue == VFW_S_STATE_INTERMEDIATE) { // wait for master to cue data hrcue = pMasterF-&gt;GetState(0, &amp;sFs); if (hrcue == S_OK) break; Sleep(5); } FILTER_STATE ssFs; HRESULT hrcues; hrcues = pSlaveF-&gt;GetState(0, &amp;ssFs); while(hrcues == VFW_S_STATE_INTERMEDIATE) { // wait for slave cue data hrcue = pSlaveF-&gt;GetState(0, &amp;ssFs); if (hrcues == S_OK) break; Sleep(5); } REFERENCE_TIME refTime; HRESULT timeHR = pClock-&gt;GetTime(&amp;refTime); // get master ref time REFERENCE_TIME temp = refTime+100000000000000; // now + offset pMF-&gt;Run(temp); // run master pSF-&gt;Run(temp); // run slave </code></pre> <p>As you can see, I set some ridiculous offset. However, I still can't see any delay visually. Perhaps I got the "<strong>now</strong>" time wrong? </p> <p><strong>Edit: Thank you for responding, Geraint. I do found every IReferenceClock::GetTime call(pClock->GetTime) gives me a reference time with huge leap (probably due to huge offset I gave). Is that what you meant by the stream time jumping forward? How could I check if the Audio Renderer is providing the clock?</strong></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload