简体   繁体   English

为Visual Studio开发构建FFMPEG

[英]Building FFMPEG for Visual Studio development

I'm trying to use ffmpeg in Visual Studio 2013 C++ software (ultimately as part of an OpenCV project) - but right now I'm just trying to get basic FFMPEG functionality. 我正在尝试在Visual Studio 2013 C ++软件中使用ffmpeg(最终作为OpenCV项目的一部分)-但现在我只是在尝试获取基本的FFMPEG功能。 In general, when building in Visual Studio, I build 64--bit software with Multi-threaded DLL runtime libraries. 通常,在Visual Studio中进行构建时,我会使用多线程DLL运行时库来构建64位软件。 I have built ffmpeg using the general instructions for 'Native Windows compilation using ... MinGW-w64' at http://ffmpeg.org/platform.html#Windows (I provide a more detailed set of steps I followed below...). 我使用http://ffmpeg.org/platform.html#Windows上的 “使用... MinGW-w64进行本机Windows编译”的一般说明来构建ffmpeg(我在下面提供了一组更详细的步骤... )。

After building the ffmpeg software on my system, I tried to create a simple 'hello world' project in Visual Studio 2013. Specifically, I tried to implement the initial tutorial file presented at http://dranger.com/ffmpeg/tutorial01.html . 在系统上构建完ffmpeg软件之后,我尝试在Visual Studio 2013中创建一个简单的“ hello world”项目。具体地说,我尝试实现了位于http://dranger.com/ffmpeg/tutorial01.html的初始教程文件。 。 Upon building the project, I get the error: 构建项目后,出现错误:

c:\\msys64\\usr\\local\\ffmpeg\\libavutil\\common.h(45): fatal error C1083: Cannot open include file: 'libavutil/avconfig.h': No such file or directory c:\\ msys64 \\ usr \\ local \\ ffmpeg \\ libavutil \\ common.h(45):致命错误C1083:无法打开包含文件:'libavutil / avconfig.h':没有这样的文件或目录

The following are the detailed steps I took to build ffmpeg and create my basic Visual Studio project: 以下是构建ffmpeg并创建基本的Visual Studio项目时所采取的详细步骤:

============ Building ffmpeg =============== ============建立ffmpeg ===============

  1. Downloaded and intalled msys2-x86_64-20160205.exe from http://msys2.github.io http://msys2.github.io下载并安装了msys2-x86_64-20160205.exe
  2. Ran update-core to update the Msys2 install update-core来更新Msys2安装
  3. Ran pacman -Suu (twice) to complete the update (following the instructions about updating shortcuts, etc.) 运行pacman -Suu (两次)以完成更新(按照有关更新快捷方式等的说明进行操作)
  4. Then I quit out of the MSys2 shell and opened the MinGW-w64 Win64 Shell. 然后我退出MSys2 Shell,并打开MinGW-w64 Win64 Shell。 In this new shell: 在这个新外壳中:
  5. Installed the following packages using pacman -S <package-name> The list of packages I installed is: make, pkg-config, diffutils, mingw-w64-x86_64-yasm, mingw-w64-x86_64-gcc, mingw-w64-x86_64-SDL, git 使用pacman -S <package-name>安装了以下软件包:我安装的软件包列表为:make,pkg-config,diffutils,mingw-w64-x86_64-yasm,mingw-w64-x86_64-gcc,mingw-w64-x86_64 -SDL,git
  6. Then I cd'd into cd /usr/local 然后我进入cd /usr/local
  7. Ran git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
  8. I wanted to build the ffmpeg library 'out-of-tree' of this MSys64 folder. 我想建立这个MSys64文件夹的ffmpeg库“树外”。 So, in the regular file system of my Windows machine I created a folder at C:\\ffmpeg 因此,在Windows计算机的常规文件系统中,我在C:\\ ffmpeg创建了一个文件夹
  9. Back in the Win64 Shell, I cd'd to this new folder: cd /c/ffmpeg 回到Win64 Shell,我将其cd /c/ffmpeg到这个新文件夹: cd /c/ffmpeg
  10. Then ran /usr/loca/ffmpeg/configure --enable-shared 然后运行/usr/loca/ffmpeg/configure --enable-shared
  11. Then make -r 然后make -r
  12. And, finally make install 并且,最后make install

Now, if I had to guess, my 'flaw' was in the options I used when calling the 'configure' script of ffmpeg. 现在,如果我不得不猜测,我的“缺陷”就在调用ffmpeg的“配置”脚本时使用的选项中。 Do I need to use particular options so that I can take the ffmpeg libraries built here and use them as dynamic (DLL) libraries in Visual Studio? 我是否需要使用特定的选项,以便可以使用此处构建的ffmpeg库并将它们用作Visual Studio中的动态(DLL)库?

========== Configuring my Visual Studio Project ============ ===========配置我的Visual Studio项目============

Here's how I created a simple hello world project in Visual Studio to see if ffmpeg is working. 这是我在Visual Studio中创建一个简单的hello world项目的方法,以查看ffmpeg是否正常工作。

  1. I created a new Visual C++ 'Empty Project' in Visual Studio 2013 我在Visual Studio 2013中创建了一个新的Visual C ++``空项目''
  2. I then configured the project properties as follows: 然后,我将项目属性配置如下:

    a. 一种。 In C/C++ => General => Additional Include Directories, I put 在C / C ++ =>常规=>其他包含目录中,我把

    C:\\msys64\\usr\\local\\ffmpeg C:\\ msys64 \\ usr \\ local \\ ffmpeg

    b. b。 In Linker=>General => Additional Library Directories, I pointed to each of the built library folders (basically I pointed at all of the libraries that were built to ensure I was not inadvertently missing the critical one). 在Linker => General => Additional Library Directories中,我指向了每个已构建的库文件夹(基本上,我指向所有已构建的库,以确保我不会无意中丢失关键的一个)。 The list is as follows: 列表如下:

    • C:\\ffmpeg\\libavcodec C:\\ ffmpeg \\ libavcodec
    • C:\\ffmpeg\\libavdevice C:\\ ffmpeg \\ libavdevice
    • C:\\ffmpeg\\libavfilter C:\\ ffmpeg \\ libavfilter
    • C:\\ffmpeg\\libavformat C:\\ ffmpeg \\ libavformat
    • C:\\ffmpeg\\libavutil C:\\ ffmpeg \\ libavutil
    • C:\\ffmpeg\\libswresample C:\\ ffmpeg \\ libswresample
    • C:\\ffmpeg\\libswscale C:\\ ffmpeg \\ libswscale
    • C:\\ffmpeg C:\\ ffmpeg

    c. C。 In Linker=> Input => Additional Dependencies, I pointed to the particular libraries (again - I pointed to all of the ones present). 在Linker => Input => Additional Dependencies中,我指出了特定的库(同样,我指出了所有存在的库)。 The list is: 清单是:

    • avcodec.lib avcodec.lib
    • avdevice.lib avdevice.lib
    • avfilter.lib avfilter.lib
    • avformat.lib avformat.lib
    • avutil.lib avutil.lib
    • swresample.lib swresample.lib
    • swscale.lib swscale.lib
  3. I then created a new source file called 'tut01.c' and copied/pasted the code from http://dranger.com/ffmpeg/tutorial01.c 然后,我创建了一个名为“ tut01.c”的新源文件,并从http://dranger.com/ffmpeg/tutorial01.c复制/粘贴了代码

  4. Then hit F7 and got the error specified above about not finding avconfig.h 然后按F7键,得到上面指定的关于找不到avconfig.h的错误

The above is my best guess as to the steps I need to follow to get this working in Windows (btw, it's Windows 10, 64-bit) & Microsoft Visual Studio 2013. What should I change to get this basic program to build and run? 以上是我在Windows(btw,它是Windows 10,64位)和Microsoft Visual Studio 2013上运行时需要遵循的步骤的最佳猜测。为使该基本程序得以构建和运行,我应该进行哪些更改? ?

@halfelf, thanks for the responses. @halfelf,感谢您的答复。 They caused me to take another look at my files and I realize I was pointing at the wrong location for the include (and lib) files. 他们使我重新审视了我的文件,我意识到我指向了包含(和lib)文件的错误位置。 Turns out that, upon building ffmpeg, it places in lateral folders /usr/local/include and /usr/local/bin , I guess, a more complete set of include and library files, respectively (including avconfig.h!) I updated my Visual Studio project properties to point at these folders which solved that problem. 事实证明,在构建ffmpeg时,它将放置在横向文件夹/usr/local/include/usr/local/bin ,我想分别是一套更完整的包含文件和库文件(包括avconfig.h!)。我的Visual Studio项目属性指向这些解决了该问题的文件夹。

But subsequently, I ran into a new problem of 'PIX_FMT_RGB24' not being identified. 但是随后,我遇到了一个新问题,即“ PIX_FMT_RGB24”未被识别。 However, I think this is related to the tutorial file I'm using being out of date. 但是,我认为这与我正在使用的教程文件有关。 I can delete those (and related) lines and the code will build and execute (though it does not do much since the 'money' lines of code are removed). 我可以删除那些(和相关的)行,并且代码将生成并执行(尽管由于删除了“金钱”行的代码,所以并不会执行太多操作)。 But at least base features of ffmpeg appear to be working. 但是,至少ffmpeg的基本功能似乎可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM