如何在 DirectShow.NET 中退帧?

发布于 2025-01-05 23:32:16 字数 72 浏览 0 评论 0原文

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

I suppose it should be done with IMediaSeeking SetPositions, but I don't know how define parameters inside.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

墨小墨 2025-01-12 23:32:16

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

There is no dedicated method to step back in DirectShow (as such existing for stepping forward). Yes you can use IMediaSeeking::SetPositions, however but note that it is not DirectShow itself who implement it, but actual underlying filters, so support for re-positioning depends on filters and implementation, and may be limited to, for example, stepping through key frames (splice points) only. DirectShow.NET is onyl a wrapper over DirectShow and it also does not add anything on top what DirectShow offers for stepping.

我很坚强 2025-01-12 23:32:16
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# 封装此代码对您来说可能并不困难。希望这有帮助。

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

This works for me in C++. Wrapping this code in C# may not be difficult for you. Hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文