directshow 反向播放
我目前有一个可以正确播放的 DirectShow.NET 图表,但我希望它也能够反向播放(从末尾开始并向后播放到开头)。
我尝试过使用 IMediaSeeking::SetRate(double) 方法,但这只适用于正值。当我尝试使用负值时,它会崩溃。
帮助!
我正在使用 .avi 视频文件,但如果可以的话,我愿意尝试不同的格式。
I currently have a DirectShow.NET graph that properly plays but I would like it to also be able to play in reverse (start at the end and play backwards to the start).
I've tried playing around with the IMediaSeeking::SetRate(double) method but that only works for positive values. When I try with a negative value it crashes.
Help!
I'm using .avi video files but would be open to trying different formats if that would do the trick.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
实际上,我不确定现有的 AVI 解复用器是否支持任何格式的负速率,即使该格式不使用时间压缩。当然,大多数其他多路分配器过滤器不支持负速率。因此,您可能需要一个自定义的多路分配器过滤器来执行此操作。如果您这样做,请确保使用带有索引的容器格式(例如 mp4)。
如果您使用没有时间压缩的格式(运动 jpeg、仅 i 帧 mpeg-2 等),您将在帧压缩方面付出相当大的代价,以便能够反向播放。如果您想真正做到这一点,请考虑某些 DVD 实现所采用的方法。其中一些通过仅播放 i 帧来反向播放,因此您的帧率为 1 或 2 fps。但高端实现将解码整个 GOP(大约 15 帧),然后在解码前一个 GOP 的同时以相反的顺序渲染这些帧。这在开发方面和系统资源上是昂贵的,但得到了良好的最终结果。
G
Actually, 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.
G
您是否尝试过使用各种视频文件?由于时间压缩技术,许多文件只能向前播放(即文件中的信息)帧取决于前一帧中的信息)。
您可以使用 GSpot 检查您的文件并查看它是否包含任何 P 帧;如果是这样,您不太可能能够反向播放它。 AVI 是一个容器,其中的视频可以使用任何编解码器。
Have you tried with a variety of video files? Many files can only be played forwards due to temporal compression techniques (i.e. the information in a frame depends on information in the previous frames).
You can use GSpot to inspect your file and see if it contains any P-frames; if it does, you're unlikely to be able to play it in reverse. AVI is a container and the video inside it could use any codec.
重复调用 IMediaSeeking::SetPositions 一次向后退一帧将实现反向播放。它不太可能顺利,但我认为这将是您无需编写多个自定义过滤器即可实现的最佳效果。
使用没有任何时间压缩的编解码器(例如 mjpeg 或 jpeg2000)将对这项技术有很大帮助。对于常规的现代编解码器,降低分辨率和比特率会有所帮助。
您是否需要能够在任意时间反向播放任意文件?如果您可以预处理媒体文件,那么准备一个可以切换到的反向版本并不困难。如果您熟悉低级工具,Avisynth 可以做到这一点。
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.
Do you need to be able to reverse playback at any random time for any arbitrary file? If you can preprocess your media files, it wouldn't be hard to prepare a reversed version that you could switch to. Avisynth could do it if you're comfortable with low-level tools.