如何使用Directshow修剪视频!? [英] How to trim the video using Directshow!?

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

问题描述

我正在使用大多数常用控件创建视频播放器,另外我想通过从用户获取开始时间和结束时间来添加剪裁选项。根据该视频必须从原始文件中剪切并将修剪后的视频保存在新的输出文件中。我通过从我的应用程序运行命令提示符来使用ffmpeg进行修剪和合并。有没有办法使用directshow来做到这一点!?

如果是这样我必须要做的事情!?

我使用的是avi和mp4容器。



谢谢和问候,

SurjithKumar.J

I am creating the video player with most of the common controls and additionally i want to add the trimming options by getting the start time and end time from the user. According to that the video has to cut from the original file and save the trimmed video in the new output file. I did the trimming and merging using the ffmpeg by running the command prompt from my application. Is there any way to do it using the directshow!?
If it so what i have to do!?
I am using avi and mp4 container.

Thanks & regards,
SurjithKumar.J

推荐答案

请参阅此CodeProject文章: DirectShow视频和音频修剪 [ ^ ]。



我不会亲自使用DirectShow。我更喜欢使用开源库或实用程序FFmpeg或libavcodec: http://en.wikipedia.org/wiki/Ffmpeg [ ^ ],

http://ffmpeg.org/ [ ^ ],

http://en.wikipedia.org/wiki/Libavcodec [ ^ ],

http://libav.org/ [ ^ ]。



这是我所知道的最好的图书馆和实用程序集。我可以通过使用命令行界面以编程方式运行可用的实用程序(FFmpeg.exe)来使用。



可选,您可以嵌入为图书馆。使用C ++显然是可能的,因为库是用C编写的。如果你需要.NET功能,你也可以这样做:你仍然可以使用非托管库,在C ++ / CLI混合模式(托管+非托管)项目中使用它。您可以在托管的ref类中公开您需要的功能;然后你可以使用这些类作为通常的.NET程序集引用生成的模块。



使用.NET和没有C ++ / CLI,它可能更复杂,因为它需要使用P / Invoke。同时,您可以找到合适的包装器。请参阅:

http://www.ffmpeg-csharp.com/ [ ^ ],

http://sourceforge.net/projects/sharpffmpeg/ [ ^ ],

http://vbffmpegwrapper.codeplex.com/ [ ^ ]。



毕竟,尝试找一些: http://bit.ly/VpboUJ [ ^ ]。



如果你想工作在你自己的包装但不知道如何,问一个问题,我会给你基本的想法(使用P / Invoke或C ++ / CLI混合模式项目)。



祝你好运,

-SA
Please see this CodeProject article: DirectShow Video and Audio Trimming[^].

I wouldn't personally use DirectShow. I would prefer using open-source library or utility FFmpeg or libavcodec: http://en.wikipedia.org/wiki/Ffmpeg[^],
http://ffmpeg.org/[^],
http://en.wikipedia.org/wiki/Libavcodec[^],
http://libav.org/[^].

This is the best library and utility set I ever knew. I could be used just by running the available utility (FFmpeg.exe), programmatically or not, using command-line interface.

Optionally, you can embed is as a library. It's apparently possible with C++, as the library is written on C. Same thing if you need .NET functionality: you can still use the unmanaged library, using it in your C++/CLI mixed-mode (managed + unmanaged) project. You can expose just the functionality you need, in managed "ref" classes; then you can use these classes referencing the resulting module as a usual .NET assembly.

With .NET and without C++/CLI, it can be more complex as it would require using P/Invoke. At the same time, you can find appropriate wrapper. Please see:
http://www.ffmpeg-csharp.com/[^],
http://sourceforge.net/projects/sharpffmpeg/[^],
http://vbffmpegwrapper.codeplex.com/[^].

After all, try to find some more: http://bit.ly/VpboUJ[^].

If you wish to work at such wrapper by yourself but don't know how, ask a question, I'll give you the basic ideas (using P/Invoke or C++/CLI "mixed-mode" project).

Good luck,
—SA


在没有任何额外过滤器实现的情况下在directshow中进行修剪的最简单方法就是通过<$ c $设置有趣的起始停止位置c> SetPositions 方法 IMediaSeeking 界面,然后再启动图表。



问候,

Maxim。
The easiest way to do trim in directshow without any additional filters implementation it's just to set interesting start stop positions via SetPositions method of IMediaSeeking interface before starting the graph.

Regards,
Maxim.


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

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