-
-
Save RangelReale/3e6392289d8ba1a52b6e70cdd7e10282 to your computer and use it in GitHub Desktop.
##### How to compile ffmpeg + x264 using Visual Studio 2015 ##### | |
##### Building this way will make the DLLs compatible with SEH, so there will be no need to use /SAFESEH:NO when compiling your code ##### | |
##### SOURCES: | |
### https://pracucci.com/compile-ffmpeg-on-windows-with-visual-studio-compiler.html | |
### https://gist.github.com/sailfish009/8d6761474f87c074703e187a2bc90bbc | |
### http://roxlu.com/2016/057/compiling-x264-on-windows-with-msvc | |
* Download "MSYS2 x86_64" from "http://msys2.github.io" and install into "C:\workspace\windows\msys64" | |
# pacman -S make gcc diffutils mingw-w64-{i686,x86_64}-pkg-config mingw-w64-i686-nasm mingw-w64-i686-yasm | |
* Rename C:\workspace\windows\msys64\usr\bin\link.exe to C:\workspace\windows\msys64\usr\bin\link_orig.exe, in order to use MSVC link.exe | |
===== 32 BITS BEGIN | |
* Run "VS2015 x86 Native Tools Command Prompt" | |
* Inside the command prompt, run: | |
# C:\workspace\windows\msys64\msys2_shell.cmd -mingw32 -use-full-path | |
===== 32 BITS END | |
===== 64 BITS BEGIN | |
* Run "VS2015 x64 Native Tools Command Prompt" | |
* Inside the command prompt, run: | |
# C:\workspace\windows\msys64\msys2_shell.cmd -mingw64 -use-full-path | |
===== 64 BITS END | |
### x264 ### | |
# git clone http://git.videolan.org/git/x264.git | |
# cd x264 | |
# CC=cl ./configure --enable-static --prefix=/usr/local --disable-cli | |
# make | |
# make install | |
### ffmpeg ### | |
* Download sources from "http://www.ffmpeg.org/download.html" | |
# cd ffmpeg-3.3.2 | |
# export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig | |
===== 32 BITS BEGIN | |
# ./configure --toolchain=msvc --arch=x86 --enable-yasm --enable-asm --enable-shared --disable-static --disable-programs --enable-avresample --enable-libx264 --enable-gpl --prefix=./install | |
===== 32 BITS END | |
===== 64 BITS BEGIN | |
# ./configure --toolchain=msvc --arch=x86_64 --enable-yasm --enable-asm --enable-shared --disable-static --disable-programs --enable-avresample --enable-libx264 --enable-gpl --prefix=./install | |
===== 64 BITS END | |
# make | |
# make install |
Thanks for the guide, I had to add nasm to my Path environment to get x264 to compile:
- Download nasm from: https://www.nasm.us and install into : "C:\workspace\windows"
- Add C:\workspace\windows to PATH environment variable (setx PATH "%PATH%;C:\workspace\windows)
While configuring for ffmpeg i get the error that x264lib not found.
Same thing happened to me. How did you fix this?
While configuring for ffmpeg i get the error that x264lib not found.
Same thing happened to me. How did you fix this?
Add two flags --extra-cflags=-I/usr/local/include --extra-ldflags=-LIBPATH:/usr/local/lib
behind.
while running make to build ffmpeg with x264, it reported lots of unresolved external symbol
libavcodec.a(libx264.o) : error LNK2019: unresolved external symbol __imp_x264_param_default referenced in function X264_init libavcodec.a(libx264.o) : error LNK2019: unresolved external symbol __imp_x264_param_parse referenced in function X264_init libavcodec.a(libx264.o) : error LNK2019: unresolved external symbol __imp_x264_param_default_preset referenced in function X264_init libavcodec.a(libx264.o) : error LNK2019: unresolved external symbol __imp_x264_param_apply_fastfirstpass referenced in function X264_init libavcodec.a(libx264.o) : error LNK2019: unresolved external symbol __imp_x264_param_apply_profile referenced in function X264_init libavcodec.a(libx264.o) : error LNK2019: unresolved external symbol __imp_x264_picture_init referenced in function X264_frame libavcodec.a(libx264.o) : error LNK2019: unresolved external symbol __imp_x264_encoder_open_160 referenced in function X264_init libavcodec.a(libx264.o) : error LNK2019: unresolved external symbol __imp_x264_encoder_reconfig referenced in function reconfig_encoder libavcodec.a(libx264.o) : error LNK2019: unresolved external symbol __imp_x264_encoder_headers referenced in function X264_init libavcodec.a(libx264.o) : error LNK2019: unresolved external symbol __imp_x264_encoder_encode referenced in function X264_frame libavcodec.a(libx264.o) : error LNK2019: unresolved external symbol __imp_x264_encoder_close referenced in function X264_close libavcodec.a(libx264.o) : error LNK2019: unresolved external symbol __imp_x264_encoder_delayed_frames referenced in function X264_frame libavcodec.a(libx264.o) : error LNK2019: unresolved external symbol __imp_x264_encoder_maximum_delayed_frames referenced in function X264_init libavcodec.a(libx264.o) : error LNK2019: unresolved external symbol __imp_x264_levels referenced in function X264_init ffmpeg_g.exe : fatal error LNK1120: 14 unresolved externals make: *** [Makefile:111: ffmpeg_g.exe] Error 96
I followed the solution from https://stackoverflow.com/questions/62077528/compiling-static-libs-of-ffmpeg-with-x264-in-msys2-for-visual-studio-but-libx26, and it can build successfully, but after all succeed, avcodec_find_encoder_by_name(libx264) still return nullptr, also used ffmpeg -codecs | grep 264, in the list there is no x264 encoder. is there any thing I miss or something wrong?
finally I got the issue fixed. there was a ffmpeg under msys64\usr\local\bin, so I just renamed it, and then the ffmpeg refers to thre correct path that is under /ffmpeg/output where I installed the build binaries. would someone explain or clarify why need to comment libx264.c code as below when build ffmpeg linking to static libx264?
#if defined(_MSC_VER)
#define X264_API_IMPORTS 1
#endif
While configuring for ffmpeg i get the error that x264lib not found.
Same thing happened to me. How did you fix this?
Add two flags
--extra-cflags=-I/usr/local/include --extra-ldflags=-LIBPATH:/usr/local/lib
behind.
this doesn't work.
While configuring for ffmpeg i get the error that x264lib not found.