ffmpeg 7.0 + vs2022 +windows编译

2 篇文章 0 订阅

后面有总结:

安装msys2
打开 (这一步非常重要不然就得指定vs的环境)

x64 Native Tools Command Prompt for VS 2022

运行
在x64 Native Tools Command Prompt for VS 2022命令行中切换到msys2安装目录中
打开

msys2_shell.cmd

运行 安装

pacman -S diffutils make pkg-config yasm
$ pacman -S diffutils make pkg-config yasm
warning: diffutils-3.10-1 is up to date -- reinstalling
warning: make-4.4.1-2 is up to date -- reinstalling
warning: pkgconf-2.1.1-1 is up to date -- reinstalling
warning: yasm-1.3.0-3 is up to date -- reinstalling
resolving dependencies...
looking for conflicting packages...

Packages (4) diffutils-3.10-1  make-4.4.1-2  pkgconf-2.1.1-1  yasm-1.3.0-3

Total Installed Size:  5.36 MiB
Net Upgrade Size:      0.00 MiB

:: Proceed with installation? [Y/n] y
(4/4) checking keys in keyring                               [###############################] 100%
(4/4) checking package integrity                             [###############################] 100%
(4/4) loading package files                                  [###############################] 100%
(4/4) checking for file conflicts                            [###############################] 100%
(4/4) checking available disk space                          [###############################] 100%
:: Processing package changes...
(1/4) reinstalling diffutils                                 [###############################] 100%
(2/4) reinstalling make                                      [###############################] 100%
(3/4) reinstalling pkgconf                                   [###############################] 100%
(4/4) reinstalling yasm                                      [###############################] 100%
:: Running post-transaction hooks...
(1/1) Updating the info directory file...

之后切换到ffmpeg源码目录下:
下载源码:
https://github.com/FFmpeg/FFmpeg.git

切换到目录下

执行:

./configure --prefix=/usr/local/ffmpeg --enable-gpl --enable-nonfree --enable-shared --disable-ffprobe --toolchain=msvc

关闭ffprobe方式:
下面有不关闭。

$ ./configure --prefix=/usr/local/ffmpeg --enable-gpl --enable-nonfree --enable-shared --disable-ffprobe --toolchain=msvc
cl.exe is unable to create an executable file.
If cl.exe is a cross-compiler, use the --enable-cross-compile option.
Only do this if you know what cross compiling means.
C compiler test failed.

If you think configure made a mistake, make sure you are using the latest
version from Git.  If the latest version fails, report the problem to the
ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.libera.chat.
Include the log file "ffbuild/config.log" produced by configure as this will help
solve the problem.

这个报错是因为没有指定 用vs环境变量编译,要么打开上面的x64 Native Tools Command Prompt for VS 2022
要么手动添加环境变量或指定到msys2中。
建议打开

完事之后:

Enabled indevs:
dshow                   gdigrab                 lavfi                   vfwcap

Enabled outdevs:

License: nonfree and unredistributable

多线程编译:

数字8、根据cpu内核自行决定

make -j 8 && make install

报错:

E:\A\program\github\FFmpeg\config.h(1): warning C4828: 文件包含在偏移 0x21d 处开始的字符,该字符在当前源字符集中无效(代码页 65001)。
fftools/opt_common.c(206): error C2001: 常量中有换行符
fftools/opt_common.c(206): fatal error C1907: 无法从以前的错误中恢复;正在停止编译
make: *** [ffbuild/common.mak:81: fftools/opt_common.o] Error 2
make: *** Waiting for unfinished jobs....
LD      libavcodec/avcodec-61.dll
  正在创建库 libavcodec/avcodec.lib 和对象 libavcodec/avcodec.exp

在fftools/opt_common.c(206)
注释掉

    //av_log(NULL, level, "%sbuilt with %s\n", indent, CC_IDENT);


C:\msys64\usr\local\ffmpeg
下有所有的库

编译带不关闭ffprobe

$ ./configure --prefix=/usr/local/ffmpeg--enable-gpl --toolchain=msvc

报错:

前源字符集中无效(代码页 65001)。
fftools/ffprobe.c(434): warning C4267: “=”: 从“size_t”转换到“int”,可能丢失数据
fftools/ffprobe.c(653): warning C4267: “函数”: 从“size_t”转换到“int”,可能丢失数据
fftools/ffprobe.c(2624): warning C4267: “函数”: 从“size_t”转换到“int”,可能丢失数据
fftools/ffprobe.c(2625): warning C4267: “函数”: 从“size_t”转换到“int”,可能丢失数据
fftools/ffprobe.c(4082): warning C4129: “A”: 不可识别的字符转义序列
fftools/ffprobe.c(4082): warning C4129: “p”: 不可识别的字符转义序列
fftools/ffprobe.c(4082): warning C4129: “g”: 不可识别的字符转义序列
fftools/ffprobe.c(4082): warning C4129: “F”: 不可识别的字符转义序列
fftools/ffprobe.c(4082): warning C4129: “w”: 不可识别的字符转义序列
fftools/ffprobe.c(4082): warning C4129: “s”: 不可识别的字符转义序列
fftools/ffprobe.c(4082): fatal error C1001: 内部编译器错误。
(编译器文件“D:\a\_work\1\s\src\vctools\Compiler\CxxFE\sl\p1\c\preprocessor.cpp”,第 3705)
 要解决此问题,请尝试简化或更改上面所列位置附近的程序。
如果可以,请在此处提供重现步骤: https://developercommunity.visualstudio.com
请选择 Visual C++
“帮助”菜单上的“技术支持”命令,或打开技术支持帮助文件来获得详细信息。
make: *** [ffbuild/common.mak:81: fftools/ffprobe.o] Error 2
make: *** Waiting for unfinished jobs....

关闭 ffprobe.c 4082行代码:

//print_str("compiler_ident", CC_IDENT);

静态库编译:

./configure --prefix=/usr/local/ffmpeg --enable-gpl --enable-nonfree --toolchain=msvc --enable-static

静态库添加debug调试信息:–extra-cflags=“-g”
msvc是-Zi

./configure --prefix=/usr/local/ffmpeg --enable-gpl --enable-nonfree --toolchain=msvc --enable-static --extra-cflags="-Zi"
./configure --prefix=/usr/local/ffmpeg --enable-gpl --enable-nonfree --toolchain=msvc --enable-static --extra-cflags="-g"

编译 FFmpeg 通常需要一些步骤和配置,特别是在 Windows 环境下。下面是一个整理后的步骤,以便在 Windows 中使用 Visual Studio 2022 编译 FFmpeg:

前提条件:

  • 安装 Visual Studio 2022。
  • 安装 MSYS2。
  • 下载 FFmpeg 源代码。

步骤:

  1. 安装 MSYS2

    • 打开 x64 Native Tools Command Prompt for VS 2022。
    • 执行 msys2_shell.cmd
  2. 安装必要的依赖项

    pacman -S diffutils make pkg-config yasm
    
  3. 下载 FFmpeg 源代码

    git clone https://github.com/FFmpeg/FFmpeg.git
    
  4. 配置 FFmpeg

    cd FFmpeg
    ./configure --prefix=/usr/local/ffmpeg --enable-gpl --enable-nonfree --enable-shared --disable-ffprobe --toolchain=msvc
    

    如果想要开启 ffprobe,可以使用下面的配置:

    ./configure --prefix=/usr/local/ffmpeg --enable-gpl --enable-nonfree --toolchain=msvc
    

    若要编译静态库并添加调试信息,可以使用以下配置:

    ./configure --prefix=/usr/local/ffmpeg --enable-gpl --enable-nonfree --toolchain=msvc --enable-static --extra-cflags="-g"
    
  5. 编译 FFmpeg

    make -j 8 && make install
    
  6. 处理可能的错误

    • 如果编译时出现错误,可以根据错误信息调整配置或修复代码。
    • 例如,在 fftools/ffprobe.c 中的某些行可能需要注释掉以避免错误。
    • 根据具体情况,可能需要修改其他文件或配置。
  7. 验证安装

    • 确保编译完成且没有错误。
    • C:\msys64\usr\local\ffmpeg 下应该可以找到所有生成的库文件。

通过这些步骤,你应该能够在 Windows 环境中成功编译 FFmpeg。记得根据具体情况调整配置和处理可能的错误。

  • 3
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
要使用MSYS2和VS2015编译FFmpeg,你可以按照以下步骤进行操作: 1. 首先,你需要下载并安装MSYS2。你可以从官方网站https://www.msys2.org/下载MSYS2安装程序。 2. 安装完成后,打开MSYS2的命令行界面,并运行以下命令来安装必要的工具:pacman -S make gcc diffutils 3. 为了避免和MSVC的link.exe程序冲突,你需要将C:\msys64\usr\bin\link.exe重命名为C:\msys64\usr\bin\link_orig.exe。 4. 下载YASM(The Yasm Modular Assembler),你可以从官方网站https://www.tortall.net/projects/yasm/wiki/Download下载YASM。将下载的yasm--win64.exe重命名为yasm.exe,并将其拷贝至MSYS2的安装目录(比如C:\msys64)。 5. 现在你可以下载FFmpeg的源代码。你可以从官方GitHub仓库https://github.com/FFmpeg/FFmpeg下载FFmpeg的源码。 6. 打开MSYS2的命令行界面,并切换到FFmpeg源码所在的目录。 7. 运行以下命令来配置FFmpeg编译选项:./configure --toolchain=msvc --arch=x86_64 --enable-yasm --enable-asm --enable-shared --disable-static 8. 配置完成后,你可以运行make命令来开始编译FFmpeg。请注意,编译过程可能会比较耗时,请耐心等待。 9. 编译完成后,你可以使用编译好的库来进行你的项目开发。 总结一下,使用MSYS2和VS2015编译FFmpeg的步骤包括安装MSYS2、安装必要的工具、重命名link.exe、下载YASM、下载FFmpeg源码、配置编译选项、运行make命令进行编译。希望以上信息对你有帮助。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [使用msys64+vs2019在编译ffmpeg](https://download.csdn.net/download/ihmhm12345/13116875)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [使用MSYS2 + VS2022编译FFmpeg](https://blog.csdn.net/powang2011/article/details/122724685)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

磊磊cpp

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值