遇事先百度,对,我就是这么干的,不过很多文章不适合我的情况;
我的电脑环境(win10、VS2019),无论是什么VS,没什么差距;
找了很多文档,目前断定window不能直接编译ffmpeg,那么就要在windows构建linux环境;
1,构建linux环境;
构建环境有3种方案,wsl(ubuntu子系统)、cygwin、msys,那么坑来了,选型时肯定哪个简单选哪个,wsl这个在windows store里(搜索ubuntu),但是这个方法由于su无法继承当前用户的环境变量,也找了很多方法改变su的环境变量,还是无法找到cl.exe,如果不适用su,又无法使用apt;
后来选了msys,总算通过了。
a,下载MSYS2,地址:https://www.msys2.org/
b,安装:无脑下一步
c,启动MSYS2:进入安装目录,启动 msys2_shell.cmd
d,下载依赖:
安装make: pacman -S make
安装yasm: pacman -S yasm
安装diffutils: pacman -S diffutils
安装pkg-config: pacman -S pkg-config
安装git: pacman -S git(如果已有源码不需要安装)
2,配置环境
a,关闭之前的msys2_shell.cmd
b,根据情况打开vs命令

c,用vs命令打开msys2.exe
d,设置环境变量:
export PATH="/c/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.16.27023/bin/HostX64/x64":$PATH
这个要根据自己的VS路径设置;
3,下载源码
Download FFmpeg,这两处都可以下载,
然后CD到源码目录

4,配置
./configure --toolchain=msvc --arch=x86_64 --enable-x86asm --enable-shared --enable-w32threads --disable-doc --disable-static --prefix=output --enable-optimizations
configure介绍
#!/bin/sh ... #帮组选项 Help options: --help print this message --quiet Suppress showing informative output --list-decoders show all available decoders --list-encoders show all available encoders --list-hwaccels show all available hardware accelerators --list-demuxers show all available demuxers --list-muxers show all available muxers --list-parsers show all available parsers --list-protocols show all available protocols --list-bsfs show all available bitstream filters --list-indevs show all available input devices --list-outdevs show all available output devices --list-filters show all available filters #标准选项 #--disable 代表关闭状态 ;--enable 代表开启状态 Standard options: --logfile=FILE log tests and output to FILE [ffbuild/config.log] --disable-logging do not log configure debug information --fatal-warnings fail if any configure warning is generated #我们最终编译好的动态静态库位置,必须设置 --prefix=PREFIX install in PREFIX [$prefix_default] --bindir=DIR install binaries in DIR [PREFIX/bin] --datadir=DIR install data files in DIR [PREFIX/share/ffmpeg] --docdir=DIR install documentation in DIR [PREFIX/share/doc/ffmpeg] --libdir=DIR install libs in DIR [PREFIX/lib] --shlibdir=DIR install shared libs in DIR [LIBDIR] --incdir=DIR install includes in DIR [PREFIX/include] --mandir=DIR install man page in DIR [PREFIX/share/man] --pkgconfigdir=DIR install pkg-config files in DIR [LIBDIR/pkgconfig] --enable-rpath use rpath to allow installing libraries in paths not part of the dynamic linker search path use rpath when linking programs (USE WITH CARE) --install-name-dir=DIR Darwin directory name for installed targets Licensing options: --enable-gpl allow use of GPL code, the resulting libs and binaries will be under GPL [no] --enable-version3 upgrade (L)GPL to version 3 [no] --enable-nonfree allow use of nonfree code, the resulting libs and binaries will be unredistributable [no] Configuration options: #开启静态库 --disable-static do not build static libraries [no] #关闭动态库 --enable-shared build shared libraries [no #可以优化库的大小 --enable-small optimize for size instead of speed --disable-runtime-cpudetect disable detecting CPU capabilities at runtime (smaller binary) --enable-gray enable full grayscale support (slower color) --disable-swscale-alpha disable alpha channel support in swscale --disable-all disable building components, libraries and programs --disable-autodetect disable automatically detected external libraries [no] Program options: #我们不需要使用程序,不需要在Windows中执行,某.exe程序,我们只需要在代码中使用 [此命令操作的是下面三项] --disable-programs do not build command line programs #使用FFmpeg命令 --disable-ffmpeg disable ffmpeg build #播放器 --disable-ffplay disable ffplay build --disable-ffprobe disable ffprobe build Documentation options: --disable-doc do not build documentation --disable-htmlpages do not build HTML documentation pages --disable-manpages do not build man documentation pages --disable-podpages do not build POD documentation pages --disable-txtpages do not build text documentation pages #模块选项 Component options: #可以操控我们的摄像头-(Android中是不支持)) --disable-avdevice disable libavdevice build #audio video codec(编码 和 解码) --disable-avcodec disable libavcodec build #音视频格式生成和解析相关 --disable-avformat disable libavformat build #音频重采样(如果想把单声道,变成双声道) --disable-swresample disable libswresample build #对视频显示相关(对视频的缩放,放大 缩小) --disable-swscale disable libswscale build #后期处理,很少用,可以关闭掉 --disable-postproc disable libpostproc build #给视频加水印,加字幕,特殊效果 --disable-avfilter disable libavfilter build --enable-avresample enable libavresample build (deprecated) [no] --disable-pthreads disable pthreads [autodetect] --disable-w32threads disable Win32 threads [autodetect] --disable-os2threads disable OS/2 threads [autodetect] --disable-network disable network support [no] --disable-dct disable DCT code --disable-dwt disable DWT code --disable-error-resilience disable error resilience code --disable-lsp disable LSP code --disable-lzo disable LZO decoder code --disable-mdct disable MDCT code --disable-rdft disable RDFT code --disable-fft disable FFT code --disable-faan disable floating point AAN (I)DCT code --disable-pixelutils disable pixel utils in libavutil Individual component options: --disable-everything disable all components listed below --disable-encoder=NAME disable encoder NAME --enable-encoder=NAME enable encoder NAME #编码可以去关闭掉 --disable-encoders disable all encoders --disable-decoder=NAME disable decoder NAME --enable-decoder=NAME enable decoder NAME --disable-decoders disable all decoders --disable-hwaccel=NAME disable hwaccel NAME --enable-hwaccel=NAME enable hwaccel NAME --disable-hwaccels disable all hwaccels --disable-muxer=NAME disable muxer NAME --enable-muxer=NAME enable muxer NAME #混合封装(音视频等于 一段音频 一段视频 合并在一起 就是.mp4,不想这样就可以关闭) --disable-muxers disable all muxers --disable-demuxer=NAME disable demuxer NAME --enable-demuxer=NAME enable demuxer NAME --disable-demuxers disable all demuxers --enable-parser=NAME enable parser NAME --disable-parser=NAME disable parser NAME --disable-parsers disable all parsers --enable-bsf=NAME enable bitstream filter NAME --disable-bsf=NAME disable bitstream filter NAME --disable-bsfs disable all bitstream filters --enable-protocol=NAME enable protocol NAME --disable-protocol=NAME disable protocol NAME --disable-protocols disable all protocols --enable-indev=NAME enable input device NAME --disable-indev=NAME disable input device NAME --disable-indevs disable input devices --enable-outdev=NAME enable output device NAME --disable-outdev=NAME disable output device NAME --disable-outdevs disable output devices --disable-devices disable all devices --enable-filter=NAME enable filter NAME --disable-filter=NAME disable filter NAME --disable-filters disable all filters ...
5,编译
make install
生成目录 msys64\home\root\ffmpeg\output
据实际使用release和debug是同一套;
6,帮助文档