2012-02-14 60 views

回答

2

在DirectShow中沒有專門的方法退後一步(因爲這種方法存在用於逐步前進)。是的,你可以使用IMediaSeeking::SetPositions,但是請注意,它不是DirectShow本身實現它的人,而是實際的底層過濾器,因此支持重新定位取決於過濾器和實現,並且可能受限於例如逐步關鍵幀拼接點)。 DirectShow.NET在DirectShow上是一個包裝器,它也不會在DirectShow提供的步驟上添加任何東西。

+0

好的,我知道,但你可能有一些很好的例子來尋找前進和後退? – Saint 2012-02-15 07:26:37

+0

你可以用'IVideoFrameStep :: Step'尋求前進,這個工作很好。至於後退,最簡單的方法就是在時間之前設定一定的毫秒數。也許可以將一個緩存過濾器放入管道中,這樣它就可以保持框架並協助向後準確地後退,但聽起來像是一件複雜的事情,只是爲了能夠做出這樣一種[理所當然]簡單的事情。 – 2012-02-15 08:55:00

+0

在Windows SDK中沒有C#的示例,因此尋找示例的最佳位置是http://directshownet.sourceforge.net/ – 2012-02-16 06:38:25

0
IBasicVideo     *pBasicVideo=NULL;//Interface to the Ibasic Video 
HRESULT      hr; 
REFTIME      pavgfrt=0;//Get the reftime variable 
REFERENCE_TIME  pnowrt=0;//Get the reference time variable 
pBasicVideo->get_AvgTimePerFrame(&pavgfrt); 
pBasicVideo->get_AvgTimePerFrame(&pavgfrt);//Get the avg time per frame in seconds 

pSeek->GetCurrentPosition(&pnowrt);//Get the current time in the unit of 100 nanoseconds 
REFERENCE_TIME temp=pnowrt;//store it in a temp variable 
REFERENCE_TIME temp1=(REFERENCE_TIME)(pavgfrt*10000000);//convert avg time into the format of current time 
pnowrt=temp+temp1;//Add to framestep forward and subtract to framestep backward 
pSeek->SetPositions(&pnowrt,AM_SEEKING_AbsolutePositioning, NULL,AM_SEEKING_NoPositioning);//Set the seeking position to the new time 
pnowrt=0;//Reset the time variable 

這適用於C++。用C#包裝這些代碼對你來說可能並不困難。希望這可以幫助。