如何在DirectShow.NET中逐步后退帧

本文关键字:DirectShow NET | 更新日期: 2023-09-27 18:24:28

我想应该用IMediaSeeking SetPositions来完成,但我不知道如何在里面定义参数。

如何在DirectShow.NET中逐步后退帧

DirectShow中没有用于后退的专用方法(例如用于前进的现有方法)。是的,您可以使用IMediaSeeking::SetPositions,但请注意,实现它的不是DirectShow本身,而是实际的底层过滤器,因此对重新定位的支持取决于过滤器和实现,并且可能仅限于,例如,逐步通过关键帧(拼接点)。DirectShow.NET是DirectShow的一个包装器,它也不会在DirectShow提供的步骤之上添加任何内容。

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#封装这些代码对您来说可能并不困难。希望这能有所帮助。