一、编译经历
1、【第一次失败】基于windows11 + vs2022编译,总是卡住不动。
2、【第二次失败】基于ubantu进行交叉编译,各种报错,没搞定。
3、【第一次成功】基于虚拟机的win10 + vs2019,编译成功(未编译额外的库)。
二、第一次成功(未编译额外的库)
第一次编译成功,未编译任何比如x264的库等,后面再处理。使用Hyper-V运行的win10虚拟机,已经安装了vs2019。
1、参考文章
主要参考下面的文章,感谢博主。
2、下载mys2
MSYS2Software Distribution and Building Platform for Windowshttps://www.msys2.org/
3、安装插件
打开 msys2 执行下面的语句。安装了 make、gcc、 diffutils、 yasm 和 pkg-config 软件。
pacman -S make gcc diffutils yasm pkg-config
4、修改配置
打开 C:\msys64\msys2_shell.cmd (与你的安装路径相关,如果是默认安装是这个路径)
rem set MSYS2_PATH_TYPE=inherit这句更改成set MSYS2_PATH_TYPE=inherit然后保存,如下图所示。(rem 代表注释的意思)。把这句话打开的意思是使用 windows 环境变量。
5、设置编译器和链接器
(1)链接器设置
打开 msys2_shell.cmd 和 2.3是同一个文件,然后加一句(根据安装的 visual studio 版本和位置进行修改路径)
call “C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat”
(2)修改链接器
由于 msys 自带 link.exe 和 vs 中的链接器重名,需要将其改成其他名字。
(3)测试配置是否成功
6、进行编译
(1)编译设置
cd到ffmpeg的文件夹之后运行如下命令。
其中toolchain=msvc是指微软的vc开发,会生成dll。
--enable-share是生成动态库。
--prefix=build是生成目录。
./configure --toolchain=msvc --enable-shared --prefix=build
运行完上面这句话,会出现如下一长串,就是此次编译的ffmpeg的相关配置。
install prefix build
source path .
C compiler cl.exe
C library msvcrt
ARCH x86 (generic)
big-endian no
runtime cpu detection yes
standalone assembly yes
x86 assembler yasm
MMX enabled yes
MMXEXT enabled yes
3DNow! enabled yes
3DNow! extended enabled yes
SSE enabled yes
SSSE3 enabled yes
AESNI enabled yes
AVX enabled yes
AVX2 enabled yes
AVX-512 enabled yes
AVX-512ICL enabled yes
XOP enabled yes
FMA3 enabled yes
FMA4 enabled yes
i686 features enabled yes
CMOV is fast yes
EBX available no
EBP available no
debug symbols yes
strip symbols no
optimize for size no
optimizations yes
static no
shared yes
postprocessing support no
network support yes
threading support w32threads
safe bitstream reader yes
texi2html enabled no
perl enabled yes
pod2man enabled yes
makeinfo enabled no
makeinfo supports HTML no
xmllint enabled yes
External libraries:
mediafoundation schannel
External libraries providing hardware acceleration:
d3d11va dxva2
Libraries:
avcodec avfilter avutil swscale
avdevice avformat swresample
Programs:
ffmpeg ffprobe
Enabled decoders:
aac atrac1 evrc mp1 pcm_u8 text
aac_fixed atrac3 fastaudio mp1float pcm_vidc theora
aac_latm atrac3al ffv1 mp2 pcx thp
aasc atrac3p ffvhuff mp2float pfm tiertexseqvideo
ac3 atrac3pal ffwavesynth mp3 pgm tiff
ac3_fixed atrac9 fic mp3adu pgmyuv tmv
acelp_kelvin aura fits mp3adufloat pgssub truehd
adpcm_4xm aura2 flac mp3float pgx truemotion1
adpcm_adx av1 flic mp3on4 phm truemotion2
adpcm_afc avrn flv mp3on4float photocd truemotion2rt
adpcm_agm avrp fmvc mpc7 pictor truespeech
adpcm_aica avs fourxm mpc8 pixlet tscc2
adpcm_argo avui fraps mpeg1video pjs tta
adpcm_ct ayuv frwu mpeg2video ppm twinvq
adpcm_dtk bethsoftvid g723_1 mpeg4 prores txd
adpcm_ea bfi g729 mpegvideo prosumer ulti
adpcm_ea_maxis_xa bink gdv mpl2 psd utvideo
adpcm_ea_r1 binkaudio_dct gem msa1 ptx v210
adpcm_ea_r2 binkaudio_rdft gif msmpeg4v1 qcelp v210x
adpcm_ea_r3 bintext gremlin_dpcm msmpeg4v2 qdm2 v308
adpcm_ea_xas bitpacked gsm msmpeg4v3 qdmc v408
adpcm_g722 bmp gsm_ms msnsiren qdraw v410
adpcm_g726 bmv_audio h261 msp2 qoi vb
adpcm_g726le bmv_video h263 msrle qpeg vble
adpcm_ima_acorn brender_pix h263i mss1 qtrle vbn
adpcm_ima_alp c93 h263p mss2 r10k vc1
adpcm_ima_amv cavs h264 msvideo1 r210 vc1image
adpcm_ima_apc ccaption hap mszh ra_144 vcr1
adpcm_ima_apm cdgraphics hca mts2 ra_288 vmdaudio
adpcm_ima_cunning cdtoons hcom mv30 ralf vmdvideo
adpcm_ima_dat4 cdxl hdr mvc1 rawvideo vmnc
adpcm_ima_dk3 cfhd hevc mvc2 realtext vorbis
adpcm_ima_dk4 cinepak hnm4_video mvdv rl2 vp3
adpcm_ima_ea_eacs clearvideo hq_hqa mxpeg roq vp4
adpcm_ima_ea_sead cljr hqx nellymoser roq_dpcm vp5
adpcm_ima_iss cllc huffyuv notchlc rpza vp6
adpcm_ima_moflex comfortnoise hymt nuv rv10 vp6a
adpcm_ima_mtf cook iac on2avc rv20 vp6f
adpcm_ima_oki cpia idcin opus rv30 vp7
adpcm_ima_qt cri idf paf_audio rv40 vp8
adpcm_ima_rad cscd iff_ilbm paf_video s302m vp9
adpcm_ima_smjpeg cyuv ilbc pam sami vplayer
adpcm_ima_ssi dca imc pbm sanm vqa
adpcm_ima_wav dds imm4 pcm_alaw sbc wavpack
adpcm_ima_ws derf_dpcm imm5 pcm_bluray scpr wbmp
adpcm_ms dfa indeo2 pcm_dvd sdx2_dpcm webp
adpcm_mtaf dfpwm indeo3 pcm_f16le sga webvtt
adpcm_psx dirac indeo4 pcm_f24le sgi wmalossless
adpcm_sbpro_2 dnxhd indeo5 pcm_f32be sgirle wmapro
adpcm_sbpro_3 dolby_e interplay_acm pcm_f32le sheervideo wmav1
adpcm_sbpro_4 dpx interplay_dpcm pcm_f64be shorten wmav2
adpcm_swf dsd_lsbf interplay_video pcm_f64le simbiosis_imx wmavoice
adpcm_thp dsd_lsbf_planar ipu pcm_lxf sipr wmv1
adpcm_thp_le dsd_msbf jacosub pcm_mulaw siren wmv2
adpcm_vima dsd_msbf_planar jpeg2000 pcm_s16be smackaud wmv3
adpcm_xa dsicinaudio jpegls pcm_s16be_planar smacker wmv3image
adpcm_yamaha dsicinvideo jv pcm_s16le smc wnv1
adpcm_zork dss_sp kgv1 pcm_s16le_planar smvjpeg wrapped_avframe
agm dst kmvc pcm_s24be snow ws_snd1
aic dvaudio lagarith pcm_s24daud sol_dpcm xan_dpcm
alac dvbsub loco pcm_s24le sonic xan_wc3
alias_pix dvdsub m101 pcm_s24le_planar sp5x xan_wc4
als dvvideo mace3 pcm_s32be speedhq xbin
amrnb dxtory mace6 pcm_s32le speex xbm
amrwb dxv magicyuv pcm_s32le_planar srt xface
amv eac3 mdec pcm_s64be ssa xl
anm eacmv metasound pcm_s64le stl xma1
ansi eamad microdvd pcm_s8 subrip xma2
ape eatgq mimic pcm_s8_planar subviewer xpm
aptx eatgv mjpeg pcm_sga subviewer1 xsub
aptx_hd eatqi mjpegb pcm_u16be sunrast xwd
arbc eightbps mlp pcm_u16le svq1 y41p
argo eightsvx_exp mmvideo pcm_u24be svq3 ylc
ass eightsvx_fib mobiclip pcm_u24le tak yop
asv1 escape124 motionpixels pcm_u32be targa yuv4
asv2 escape130 movtext pcm_u32le targa_y216 zero12v
Enabled encoders:
a64multi asv2 hdr pcm_f64le phm targa
a64multi5 avrp hevc_mf pcm_mulaw ppm text
aac avui huffyuv pcm_s16be prores tiff
aac_mf ayuv jpeg2000 pcm_s16be_planar prores_aw truehd
ac3 bitpacked jpegls pcm_s16le prores_ks tta
ac3_fixed bmp ljpeg pcm_s16le_planar qoi ttml
ac3_mf cfhd magicyuv pcm_s24be qtrle utvideo
adpcm_adx cinepak mjpeg pcm_s24daud r10k v210
adpcm_argo cljr mlp pcm_s24le r210 v308
adpcm_g722 comfortnoise movtext pcm_s24le_planar ra_144 v408
adpcm_g726 dca mp2 pcm_s32be rawvideo v410
adpcm_g726le dfpwm mp2fixed pcm_s32le roq vbn
adpcm_ima_alp dnxhd mp3_mf pcm_s32le_planar roq_dpcm vc2
adpcm_ima_amv dpx mpeg1video pcm_s64be rpza vorbis
adpcm_ima_apm dvbsub mpeg2video pcm_s64le rv10 wavpack
adpcm_ima_qt dvdsub mpeg4 pcm_s8 rv20 wbmp
adpcm_ima_ssi dvvideo msmpeg4v2 pcm_s8_planar s302m webvtt
adpcm_ima_wav eac3 msmpeg4v3 pcm_u16be sbc wmav1
adpcm_ima_ws ffv1 msvideo1 pcm_u16le sgi wmav2
adpcm_ms ffvhuff nellymoser pcm_u24be smc wmv1
adpcm_swf fits opus pcm_u24le snow wmv2
adpcm_yamaha flac pam pcm_u32be sonic wrapped_avframe
alac flv pbm pcm_u32le sonic_ls xbm
alias_pix g723_1 pcm_alaw pcm_u8 speedhq xface
amv gif pcm_bluray pcm_vidc srt xsub
aptx h261 pcm_dvd pcx ssa xwd
aptx_hd h263 pcm_f32be pfm subrip y41p
ass h263p pcm_f32le pgm sunrast yuv4
asv1 h264_mf pcm_f64be pgmyuv svq1
Enabled hwaccels:
h264_d3d11va hevc_d3d11va mpeg2_d3d11va vc1_d3d11va vp9_d3d11va wmv3_d3d11va
h264_d3d11va2 hevc_d3d11va2 mpeg2_d3d11va2 vc1_d3d11va2 vp9_d3d11va2 wmv3_d3d11va2
h264_dxva2 hevc_dxva2 mpeg2_dxva2 vc1_dxva2 vp9_dxva2 wmv3_dxva2
Enabled parsers:
aac cook dvdsub hevc pnm vp8
aac_latm cri flac ipu qoi vp9
ac3 dca g723_1 jpeg2000 rv30 webp
adx dirac g729 mjpeg rv40 xbm
amr dnxhd gif mlp sbc xma
av1 dolby_e gsm mpeg4video sipr
avs2 dpx h261 mpegaudio tak
avs3 dvaudio h263 mpegvideo vc1
bmp dvbsub h264 opus vorbis
cavsvideo dvd_nav hdr png vp3
Enabled demuxers:
aa cdxl idcin kvag pcm_f64be smush
aac cine idf live_flv pcm_f64le sol
aax codec2 iff lmlm4 pcm_mulaw sox
ac3 codec2raw ifv loas pcm_s16be spdif
ace concat ilbc lrc pcm_s16le srt
acm data image2 luodat pcm_s24be stl
act daud image2_alias_pix lvf pcm_s24le str
adf dcstr image2_brender_pix lxf pcm_s32be subviewer
adp derf image2pipe m4v pcm_s32le subviewer1
ads dfa image_bmp_pipe matroska pcm_s8 sup
adx dfpwm image_cri_pipe mca pcm_u16be svag
aea dhav image_dds_pipe mcc pcm_u16le svs
afc dirac image_dpx_pipe mgsts pcm_u24be swf
aiff dnxhd image_exr_pipe microdvd pcm_u24le tak
aix dsf image_gem_pipe mjpeg pcm_u32be tedcaptions
alp dsicin image_gif_pipe mjpeg_2000 pcm_u32le thp
amr dss image_hdr_pipe mlp pcm_u8 threedostr
amrnb dts image_j2k_pipe mlv pcm_vidc tiertexseq
amrwb dtshd image_jpeg_pipe mm pjs tmv
anm dv image_jpegls_pipe mmf pmp truehd
apc dvbsub image_jpegxl_pipe mods pp_bnk tta
ape dvbtxt image_pam_pipe moflex pva tty
apm dxa image_pbm_pipe mov pvf txd
apng ea image_pcx_pipe mp3 qcp ty
aptx ea_cdata image_pfm_pipe mpc r3d v210
aptx_hd eac3 image_pgm_pipe mpc8 rawvideo v210x
aqtitle epaf image_pgmyuv_pipe mpegps realtext vag
argo_asf ffmetadata image_pgx_pipe mpegts redspark vc1
argo_brp filmstrip image_phm_pipe mpegtsraw rl2 vc1t
argo_cvg fits image_photocd_pipe mpegvideo rm vividas
asf flac image_pictor_pipe mpjpeg roq vivo
asf_o flic image_png_pipe mpl2 rpl vmd
ass flv image_ppm_pipe mpsub rsd vobsub
ast fourxm image_psd_pipe msf rso voc
au frm image_qdraw_pipe msnwc_tcp rtp vpk
av1 fsb image_qoi_pipe msp rtsp vplayer
avi fwse image_sgi_pipe mtaf s337m vqf
avr g722 image_sunrast_pipe mtv sami w64
avs g723_1 image_svg_pipe musx sap wav
avs2 g726 image_tiff_pipe mv sbc wc3
avs3 g726le image_vbn_pipe mvi sbg webm_dash_manifest
bethsoftvid g729 image_webp_pipe mxf scc webvtt
bfi gdv image_xbm_pipe mxg scd wsaud
bfstm genh image_xpm_pipe nc sdp wsd
bink gif image_xwd_pipe nistsphere sdr2 wsvqa
binka gsm ingenient nsp sds wtv
bintext gxf ipmovie nsv sdx wv
bit h261 ipu nut segafilm wve
bitpacked h263 ircam nuv ser xa
bmv h264 iss obu sga xbin
boa hca iv8 ogg shorten xmv
brstm hcom ivf oma siff xvag
c93 hevc ivr paf simbiosis_imx xwma
caf hls jacosub pcm_alaw sln yop
cavsvideo hnm jv pcm_f32be smacker yuv4mpegpipe
cdg ico kux pcm_f32le smjpeg
Enabled muxers:
a64 crc h263 mp3 pcm_s16le sox
ac3 dash h264 mp4 pcm_s24be spdif
adts data hash mpeg1system pcm_s24le spx
adx daud hds mpeg1vcd pcm_s32be srt
aiff dfpwm hevc mpeg1video pcm_s32le stream_segment
alp dirac hls mpeg2dvd pcm_s8 streamhash
amr dnxhd ico mpeg2svcd pcm_u16be sup
amv dts ilbc mpeg2video pcm_u16le swf
apm dv image2 mpeg2vob pcm_u24be tee
apng eac3 image2pipe mpegts pcm_u24le tg2
aptx f4v ipod mpjpeg pcm_u32be tgp
aptx_hd ffmetadata ircam mxf pcm_u32le truehd
argo_asf fifo ismv mxf_d10 pcm_u8 tta
argo_cvg fifo_test ivf mxf_opatom pcm_vidc ttml
asf filmstrip jacosub null psp uncodedframecrc
asf_stream fits kvag nut rawvideo vc1
ass flac latm obu rm vc1t
ast flv lrc oga roq voc
au framecrc m4v ogg rso w64
avi framehash matroska ogv rtp wav
avif framemd5 matroska_audio oma rtp_mpegts webm
avm2 g722 md5 opus rtsp webm_chunk
avs2 g723_1 microdvd pcm_alaw sap webm_dash_manifest
avs3 g726 mjpeg pcm_f32be sbc webp
bit g726le mkvtimestamp_v2 pcm_f32le scc webvtt
caf gif mlp pcm_f64be segafilm wsaud
cavsvideo gsm mmf pcm_f64le segment wtv
codec2 gxf mov pcm_mulaw smjpeg wv
codec2raw h261 mp2 pcm_s16be smoothstreaming yuv4mpegpipe
Enabled protocols:
async ffrtmphttp http md5 rtmps tcp
cache file httpproxy mmsh rtmpt tee
concat ftp https mmst rtmpts tls
concatf gopher icecast pipe rtp udp
crypto gophers ipfs prompeg srtp udplite
data hls ipns rtmp subfile
Enabled filters:
abench asdr copy graphmonitor normalize silenceremove
abitscope asegment crop grayworld null sinc
acompressor aselect crossfeed greyedge nullsink sine
acontrast asendcmd crystalizer guided nullsrc siti
acopy asetnsamples cue haas oscilloscope smptebars
acrossfade asetpts curves haldclut overlay smptehdbars
acrossover asetrate datascope haldclutsrc pad sobel
acrusher asettb dblur hdcd pal100bars spectrumsynth
acue ashowinfo dcshift headphone pal75bars speechnorm
addroi asidedata dctdnoiz hflip palettegen split
adeclick asoftclip ddagrab highpass paletteuse sr
adeclip aspectralstats deband highshelf pan ssim
adecorrelate asplit deblock hilbert perms stereotools
adelay astats decimate histogram photosensitivity stereowiden
adenorm astreamselect deconvolve hqx pixdesctest streamselect
aderivative asubboost dedot hstack pixelize superequalizer
adrawgraph asubcut deesser hsvhold pixscope surround
adynamicequalizer asupercut deflate hsvkey premultiply swaprect
adynamicsmooth asuperpass deflicker hue prewitt swapuv
aecho asuperstop dejudder huesaturation pseudocolor tblend
aemphasis atadenoise derain hwdownload psnr telecine
aeval atempo deshake hwmap qp testsrc
aevalsrc atilt despill hwupload random testsrc2
aexciter atrim detelecine hysteresis readeia608 thistogram
afade avectorscope dialoguenhance identity readvitc threshold
afftdn avgblur dilation idet realtime thumbnail
afftfilt avsynctest displace il remap tile
afifo axcorrelate dnn_classify inflate removegrain tiltshelf
afir bandpass dnn_detect interleave removelogo tlut2
afirsrc bandreject dnn_processing join replaygain tmedian
aformat bass doubleweave kirsch reverse tmidequalizer
afreqshift bbox drawbox lagfun rgbashift tmix
afwtdn bench drawgraph latency rgbtestsrc tonemap
agate bilateral drawgrid lenscorrection roberts tpad
agraphmonitor biquad drmeter life rotate transpose
ahistogram bitplanenoise dynaudnorm limitdiff scale treble
aiir blackdetect earwax limiter scale2ref tremolo
aintegral blend ebur128 loop scdet trim
ainterleave blockdetect edgedetect loudnorm scharr unpremultiply
alatency blurdetect elbg lowpass scroll unsharp
alimiter bm3d entropy lowshelf segment untile
allpass bwdif epx lumakey select v360
allrgb cas equalizer lut selectivecolor varblur
allyuv cellauto erosion lut1d sendcmd vectorscope
aloop channelmap estdif lut2 separatefields vflip
alphaextract channelsplit exposure lut3d setdar vfrdet
alphamerge chorus extractplanes lutrgb setfield vibrance
amerge chromahold extrastereo lutyuv setparams vibrato
ametadata chromakey fade mandelbrot setpts vif
amix chromanr feedback maskedclamp setrange vignette
amovie chromashift fftdnoiz maskedmax setsar virtualbass
amplify ciescope fftfilt maskedmerge settb vmafmotion
amultiply codecview field maskedmin shear volume
anequalizer color fieldhint maskedthreshold showcqt volumedetect
anlmdn colorbalance fieldmatch maskfun showfreqs vstack
anlmf colorchannelmixer fieldorder mcompand showinfo w3fdif
anlms colorchart fifo median showpalette waveform
anoisesrc colorcontrast fillborders mergeplanes showspatial weave
anull colorcorrect firequalizer mestimate showspectrum xbr
anullsink colorhold flanger metadata showspectrumpic xcorrelate
anullsrc colorize floodfill midequalizer showvolume xfade
apad colorkey format minterpolate showwaves xmedian
aperms colorlevels fps mix showwavespic xstack
aphasemeter colormap framepack monochrome shuffleframes yadif
aphaser colorspace framerate morpho shufflepixels yaepblur
aphaseshift colorspectrum framestep movie shuffleplanes yuvtestsrc
apsyclip colortemperature freezedetect msad sidechaincompress zoompan
apulsator compand freezeframes multiply sidechaingate
arealtime compensationdelay gblur negate sidedata
aresample concat geq nlmeans sierpinski
areverse convolution gradfun noformat signalstats
arnndn convolve gradients noise silencedetect
Enabled bsfs:
aac_adtstoasc dv_error_marker hapqa_extract mp3_header_decompress pgs_frame_merge vp9_metadata
av1_frame_merge eac3_core hevc_metadata mpeg2_metadata prores_metadata vp9_raw_reorder
av1_frame_split extract_extradata hevc_mp4toannexb mpeg4_unpack_bframes remove_extradata vp9_superframe
av1_metadata filter_units imx_dump_header noise setts vp9_superframe_split
chomp h264_metadata mjpeg2jpeg null text2movsub
dca_core h264_mp4toannexb mjpega_dump_header opus_metadata trace_headers
dump_extradata h264_redundant_pps mov2textsub pcm_rechunk truehd_core
Enabled indevs:
dshow gdigrab lavfi vfwcap
Enabled outdevs:
License: LGPL version 2.1 or later
(2)进行编译
-j16是cpu数量,按本机的数量来,这样编译速度快。
make -j16 && make install
7、编译完成
编译成功会在build文件夹下生成如下内容。