编译ffmpeg无法生成ffplay的问题解决
好多人问编译ffmpeg时无法生成ffplay,其具体原因多数是由于没有SDL或者SDL版本不正确所导致。
解决办法如下:
安装正确的SDL库既可解决
-
wget http://libsdl.org/release/SDL-1.2.15.tar.gz
-
tar zxvf SDL-1.2.15.tar.gz
-
cd SDL-1.2.15
-
./configure --prefix=/usr
-
make -j16
-
sudo make install
安装完成后,再次编译ffmpeg既可解决
原因分析:
打开configure分析一下内容既可看到如下内容:
-
SDL_CONFIG="${cross_prefix}sdl-config"
-
if check_pkg_config sdl SDL_events.h SDL_PollEvent; then
-
check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
-
check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x010300" $sdl_cflags &&
-
enable sdl
-
else
-
if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
-
sdl_cflags=$("${SDL_CONFIG}" --cflags)
-
sdl_libs=$("${SDL_CONFIG}" --libs)
-
check_func_headers SDL_version.h SDL_Linked_Version $sdl_cflags $sdl_libs &&
-
check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
-
check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x010300" $sdl_cflags &&
-
enable sdl
-
fi
-
fi
-
enabled sdl && add_cflags $sdl_cflags && add_extralibs $sdl_libs
这里比较关键,首先判断SDL.h中的版本对应的值在通过计算后是否在0x010201至0x010300之间,如果是的话SDL版本才会正确的被执行,否则这个测试项将会出现错误,生成的config.log中有对应的错误记录
当没有安装SDL库时,config.log中相关的错误信息如下
-
check_pkg_config sdl SDL_events.h SDL_PollEvent
-
false --exists --print-errors sdl
当安装的SDL版本库不对应时,config.log中对应的错误信息如下
-
check_pkg_config sdl SDL_events.h SDL_PollEvent
-
false --exists --print-errors sdl
-
check_func_headers SDL_version.h SDL_Linked_Version -I/usr/include/SDL2 -I/usr/X11R6/include -D_THREAD_SAFE -L/usr/lib -lSDL2
-
check_ld cc -I/usr/include/SDL2 -I/usr/X11R6/include -D_THREAD_SAFE -L/usr/lib -lSDL2
-
check_cc -I/usr/include/SDL2 -I/usr/X11R6/include -D_THREAD_SAFE -L/usr/lib
-
BEGIN /var/folders/z5/31tj_ff977n3r59bx1cwg98c0000gn/T//ffconf.NYPJoPCV.c
-
1 #include <SDL_version.h>
-
2 long check_SDL_Linked_Version(void) { return (long) SDL_Linked_Version; }
-
3 int main(void) { return 0; }
-
bbs.chinaffmpeg.com 孙悟空
-
END /var/folders/z5/31tj_ff977n3r59bx1cwg98c0000gn/T//ffconf.NYPJoPCV.c
-
gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -DPIC -std=c99 -mdynamic-no-pic -fomit-frame-pointer -fPIC -I/usr/include/SDL2 -I/usr/X11R6/include -D_THREAD_SAFE -L/usr/lib -c -o /var/folders/z5/31tj_ff977n3r59bx1cwg98c0000gn/T//ffconf.q6QhmvUN.o /var/folders/z5/31tj_ff977n3r59bx1cwg98c0000gn/T//ffconf.NYPJoPCV.c
-
/var/folders/z5/31tj_ff977n3r59bx1cwg98c0000gn/T//ffconf.NYPJoPCV.c: In function 'check_SDL_Linked_Version':
-
/var/folders/z5/31tj_ff977n3r59bx1cwg98c0000gn/T//ffconf.NYPJoPCV.c:2: error: 'SDL_Linked_Version' undeclared (first use in this function)
-
/var/folders/z5/31tj_ff977n3r59bx1cwg98c0000gn/T//ffconf.NYPJoPCV.c:2: error: (Each undeclared identifier is reported only once
-
/var/folders/z5/31tj_ff977n3r59bx1cwg98c0000gn/T//ffconf.NYPJoPCV.c:2: error: for each function it appears in.)
或者如下错误
-
BEGIN /var/folders/z5/31tj_ff977n3r59bx1cwg98c0000gn/T//ffconf.mfC1B2mW.c
-
1 #include <SDL_version.h>
-
2 long check_SDL_GetVersion(void) { return (long) SDL_GetVersion; }
-
3 int main(void) { return 0; }
-
END /var/folders/z5/31tj_ff977n3r59bx1cwg98c0000gn/T//ffconf.mfC1B2mW.c
-
gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -DPIC -std=c99 -mdynamic-no-pic -fomit-frame-pointer -fPIC -I/usr/local/include/SDL2 -I/usr/X11R6/include -D_THREAD_SAFE -L/usr/local/lib -c -o /var/folders/z5/31tj_ff977n3r59bx1cwg98c0000gn/T//ffconf.E9d2cGZ6.o /var/folders/z5/31tj_ff977n3r59bx1cwg98c0000gn/T//ffconf.mfC1B2mW.c
-
gcc -Wl,-dynamic,-search_paths_first -I/usr/local/include/SDL2 -I/usr/X11R6/include -D_THREAD_SAFE -L/usr/local/lib -o /var/folders/z5/31tj_ff977n3r59bx1cwg98c0000gn/T//ffconf.Z74XFGa5 /var/folders/z5/31tj_ff977n3r59bx1cwg98c0000gn/T//ffconf.E9d2cGZ6.o -lSDL2 -lm -lbz2 -lz
-
check_cpp_condition SDL.h (SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201 -I/usr/local/include/SDL2 -I/usr/X11R6/include -D_THREAD_SAFE
-
check_cpp -I/usr/local/include/SDL2 -I/usr/X11R6/include -D_THREAD_SAFE
-
BEGIN /var/folders/z5/31tj_ff977n3r59bx1cwg98c0000gn/T//ffconf.mfC1B2mW.c
-
1 #include <SDL.h>
-
2 #if !((SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201)
-
3 #error "unsatisfied condition: (SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201"
-
4 #endif
-
END /var/folders/z5/31tj_ff977n3r59bx1cwg98c0000gn/T//ffconf.mfC1B2mW.c
-
gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -DPIC -std=c99 -mdynamic-no-pic -fomit-frame-pointer -fPIC -I/usr/local/include/SDL2 -I/usr/X11R6/include -D_THREAD_SAFE -E -o /var/folders/z5/31tj_ff977n3r59bx1cwg98c0000gn/T//ffconf.E9d2cGZ6.o /var/folders/z5/31tj_ff977n3r59bx1cwg98c0000gn/T//ffconf.mfC1B2mW.c
-
check_cpp_condition SDL.h (SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x010300 -I/usr/local/include/SDL2 -I/usr/X11R6/include -D_THREAD_SAFE
-
check_cpp -I/usr/local/include/SDL2 -I/usr/X11R6/include -D_THREAD_SAFE
-
BEGIN /var/folders/z5/31tj_ff977n3r59bx1cwg98c0000gn/T//ffconf.mfC1B2mW.c
-
1 #include <SDL.h>
-
2 #if !((SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x010300)
-
3 #error "unsatisfied condition: (SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x010300"
-
4 #endif
-
bbs.chinaffmpeg.com 孙悟空
-
END /var/folders/z5/31tj_ff977n3r59bx1cwg98c0000gn/T//ffconf.mfC1B2mW.c
-
gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -DPIC -std=c99 -mdynamic-no-pic -fomit-frame-pointer -fPIC -I/usr/local/include/SDL2 -I/usr/X11R6/include -D_THREAD_SAFE -E -o /var/folders/z5/31tj_ff977n3r59bx1cwg98c0000gn/T//ffconf.E9d2cGZ6.o /var/folders/z5/31tj_ff977n3r59bx1cwg98c0000gn/T//ffconf.mfC1B2mW.c
-
/var/folders/z5/31tj_ff977n3r59bx1cwg98c0000gn/T//ffconf.mfC1B2mW.c:3:2: error: #error "unsatisfied condition: (SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x010300"
根据对ffplay与ffmpeg中libavdevice中SDL相关的接口与SDL1和SDL2的初步对比,发现SDL2与SDL1差别还是蛮大的,要改libavdevice也是力气活,所以如果SDL1不影响太多的话,还是用SDL1吧
阅读(1298) | 评论(0) | 转发(0) |