如何使用directshow向后播放视频!? [英] How to play the video backward using directshow!?

查看:87
本文介绍了如何使用directshow向后播放视频!?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建具有基本控件的视频播放器,我想添加反向播放控件。 IVideoFrameStep接口包含前进的方法,我找不到任何退步的接口。因此,我正在使用包含GetCurrentPosition和SetPosition方法的IMediaSeeking。

下面是我的Step Backward代码:

 LONGLONG pos; 
pSeek-> GetCurrentPosition(& pos);
pos- = FrameValue;
hr = pSeek-> SetPositions(& pos,AM_SEEKING_AbsolutePositioning,NULL,
AM_SEEKING_NoPositioning);
pControl->暂停();





如果我在循环中使用它,我可以向后播放视频,但是我不能暂停或停止视频直到它完成。



1)还有其他方法可以在DirectShow中向后播放视频!?



我使用VMR9作为渲染器过滤器,一次播放多个视频。视频顺利前进,但如果我使用上面提到的代码向后退一步就会出现问题。即使我正在渲染两个相同的视频,但是当向后退一步时框架是不同的,否则屏幕会在一个视频区域中随机变黑。



2)我需要做什么步骤框架回两个视频没有任何问题,我在调用后退控制时提到了!?



提前感谢你,

解决方案

反复调用IMediaSeeking: :SetPositions一次向后移动一帧帧将给你反向播放。它不太可能顺利,但我认为如果不编写多个自定义过滤器,它将是最好的。 

使用没有任何时间压缩的编解码器(如mjpeg或jpeg2000)对这种技术有很大帮助。对于常规的现代编解码器,降低分辨率和比特率会有所帮助。



我不确定AVI demux的股票将支持负利率任何格式,即使格式不使用时间压缩。当然,大多数其他demux过滤器都不支持负利率。因此,您可能需要一个自定义demux过滤器来执行此操作。如果这样做,请确保使用带索引的容器格式(例如mp4)。 

如果你使用没有时间压缩的格式(运动jpeg,i帧只有mpeg-2等),你将为帧压缩付出相当大的代价,以便能够反向播放。如果你想做得很好,请考虑一些DVD实现的方法。其中一些只通过播放i-frame而反向播放,因此你有1或2 fps。但是顶端实现将解码整个GOP(大约15帧),然后在解码前一个GOP时以相反的顺序渲染这些帧。这在开发方面和系统资源方面都很昂贵,但最终结果很好。



(改编自http://stackoverflow.com/q/1725534/1758762 [ ^ ])


我们的新 DirectShow源过滤器支持各种文件的反向播放,包括具有时间压缩的文件(H.264,MPEG-2等)。



我们能够实现这一目标通过在单个组件中实现读取,文件分割和解码,从而避免DirectShow复杂性,这对于具有时间压缩的文件的反向回放尤其成问题。


通过使用倒带来向后播放视频选项。

I am creating the video player which is having the basic controls and i want to add the reverse play control. IVideoFrameStep interface is containing the method for step forward, i couldn't find any interface for step backward. So for that am using IMediaSeeking which is containing GetCurrentPosition and SetPosition methods.
Below is my code for Step Backward:

LONGLONG pos;
pSeek->GetCurrentPosition(&pos);
pos-=FrameValue;
hr = pSeek->SetPositions(&pos,AM_SEEKING_AbsolutePositioning,NULL,
                         AM_SEEKING_NoPositioning);
pControl->Pause();



I can play the video backward if i use this in a loop, but i cant pause or stop the video until it completes.

1)Is there any other way to play the video backward in DirectShow!?

And am using VMR9 as a renderer filter for playing more than one video at a time. The video was step forward smoothly but if i use the above mentioned code for step backward am getting issues. Even though i am rendering two same videos the frame was differs when step backward or else the screen get black randomly in one video region.

2)What i have to do to step frame back the two videos without any issues which i was mentioned when the step back control was invoked!?

Thanking you in advance,

解决方案

Repeatedly calling IMediaSeeking::SetPositions to framestep backwards one frame at a time will give you reverse playback. It will be very unlikely to be smooth, but I think it's going to be the best you can achieve without writing multiple custom filters.

Using a codec without any temporal compression like mjpeg or jpeg2000 would help a lot with this technique. For regular modern codecs lowering the resolution and bitrate would help.


I'm not sure that the stock AVI demux will support negative rates for any format, even if the format does not use temporal compression. And certainly most other demux filters will not support negative rate. So you will probably need a custom demux filter to do this. If you do this, make sure you use a container format with an index (mp4 for example).

If you use a format without temporal compression (motion jpeg, i-frames only mpeg-2 etc), you will pay a considerable price in frame compression in order to be able to play in reverse. If you want to do this really well, consider the approach taken by some DVD implementations. Some of them play in reverse by playing only the i-frame, so you have 1 or 2 fps. But the top-end implementation will decode a whole GOP (approx 15 frames) and will then render these frames in reverse order while decoding the previous GOP. This is expensive in development terms and in system resources, but gets a good end result.


(Adapted from http://stackoverflow.com/q/1725534/1758762[^])


Our new DirectShow source filter supports reverse playback for all kinds of files, including those with temporal compression (H.264, MPEG-2, etc.).

We were able to achieve this by implementing reading, file splitting and decoding in a single component, thus avoiding DirectShow complexities, that become especially problematic for reverse playback of files with temporal compression.


to play a video backward by using rewind option.


这篇关于如何使用directshow向后播放视频!?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆