如何在Windows中使用openCV FFMPEG视频I / O而不是DirectShow? [英] how can I use the openCV FFMPEG video I/O rather than the DirectShow one in Windows?

查看:839
本文介绍了如何在Windows中使用openCV FFMPEG视频I / O而不是DirectShow?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我试图使用openCV videoWriter写一个视频:

So I'm trying to write a video using the openCV videoWriter as such:

writer=cv.CreateVideoWriter(path+"test_output.avi",-1,fps,(W,H),1)

提供FOURCC我提供-1为了看看我有什么编解码器可用。
结果是Microsoft RLE,Microsoft Video 1,Intel YUV和未压缩。

So instead of supplying the FOURCC I supplied -1 in order to see what codecs I have available. Result was Microsoft RLE, Microsoft Video 1, Intel YUV, and Uncompressed.

原因是当使用CMAKE为Visual Studio 10 x64配置openCV时,这是我在视频中的i / o:
视频I / O :DirectShow

The reason is that when configuring openCV using CMAKE for Visual Studio 10 x64, this is what I have in the video i/o: Video I/O: DirectShow

有没有办法切换到FFMPEG?我知道ffmpeg dll存在于\3dparty\ffmpeg。
我找到了Cmake FFMPEG标志,但没有发现任何。奇怪的是在opencv根目录下的CmakeLists.txt中:

Is there a way to switch this to FFMPEG? I know the ffmpeg dll is present in \3dparty\ffmpeg. I looked for Cmake FFMPEG flags but found none whatsoever. The weird thing is in the CmakeLists.txt in the opencv root under the video section:

if(UNIX AND NOT APPLE)
<FFMPEG stuff>
elseif(WIN32)
    status("  Video I/O:"        HAVE_VIDEOINPUT     THEN DirectShow ELSE NO)
endif()

所以在我看来,opencv自动切换到DirectShow,并且没有选择使用FFMpeg。
或者可以升级Driectshow来支持其他格式,如Divx或h264?
任何想法?

So it seems to me that opencv automatically switched to DirectShow and gives no choice of using FFMpeg. Or rather can one upgrade Driectshow to support other formats such as Divx or h264? Any ideas?

推荐答案

您寻找的答案在这里,它适用于32位和64位配置。我使用这个构建的FFMPEG。 http://ffmpeg.zeranoe.com/builds/win64/dev/ ffmpeg-git-1aeb88b-win64-dev.7z

The answer your looking for is here and it works for the 32 bit and 64 bit configurations. I used this build of FFMPEG. http://ffmpeg.zeranoe.com/builds/win64/dev/ffmpeg-git-1aeb88b-win64-dev.7z

1)下载OpenCV 2.3

1) Download OpenCV 2.3

2)打开根CMakeLists.txt并插入行集(HAVE_FFMPEG 1)

2) Open the root CMakeLists.txt and insert the line set(HAVE_FFMPEG 1)

3)下载 http://ffmpeg.zeranoe.com/builds/win64/dev/ffmpeg-git-1aeb88b-win64-dev.7z (或32位构建如果你喜欢它)

3) Download http://ffmpeg.zeranoe.com/builds/win64/dev/ffmpeg-git-1aeb88b-win64-dev.7z (or the 32 bit build if u fancy it)

4)编辑avformat.h找到在ffmpeg包含目录与#define INT64_C

4) Edit avformat.h found in the ffmpeg include dir with #define INT64_C

5)使用#define snprintf _snprintf

5) Edit cap_ffmpeg_impl.hpp from the highgui project with #define snprintf _snprintf

6从highgui项目中编辑cap_ffmpeg_impl.hpp,在Highgui项目属性中的C / C ++> Additional Include目录添加您刚刚下载的FFMPEG的include目录的路径

6) in your highgui project properties under C/C++>Additional Include Directories add path of the include directory of FFMPEG you just downloaded

7)在Linker> General> Additional Library Dependencies下的相同属性页面上添加lib目录的路径您刚刚下载的FFMPEG

7)On the same property page under Linker>General>Additional Library Dependencies add the path of the lib directory of FFMPEG you just downloaded

8)在Linker> Input> Additional dependencies下的同一个属性页面中,添加lib中所有ffmpeg库的名称(avformat.lib ,avscale.lib,avcore.lib等)

8)On the same property page under Linker>Input>Additional dependencies add ALL the names of the libraries of ffmpeg found in lib (avformat.lib, avscale.lib, avcore.lib etc)

9)构建highgui项目

9) build the highgui project

10) FFMPEG附带的.dll文件的路径到系统路径环境变量。

10) Add the path of the .dll files that came with FFMPEG to the System Path environment variable.

就是这样! 10个简单步骤);

That's it! 10 easy steps ;)

这篇关于如何在Windows中使用openCV FFMPEG视频I / O而不是DirectShow?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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