ubuntu下利用ffserver+ffmpeg进行视频流直播,但vlc却一直无法播放,以前资料提到的都是使用ffplay,经查ffmpeg编译时并未编出ffplay,只得编译如下:
1:ffmpeg的config.h中修改#define CONFIG_FFPLAY 1
2:zhujinhua@thinkpadE455:~/ffmpeg/ffmpeg-3.0$ make
CC ffplay.o
ffplay.c:56:17: fatal error: SDL.h: 没有那个文件或目录
http://www.libsdl.org/download-1.2.php下载sdl库,另外还有2.0,但是试了下不行
编译sdl库时:
./src/video/x11/SDL_x11sym.h:168:17: error: conflicting types for ‘_XData32’
SDL_X11_SYM(int,_XData32,(Display *dpy,register long *data,unsigned len),(dpy,data,len),return)
./src/video/x11/SDL_x11dyn.c:95:5: note: in definition of macro ‘SDL_X11_SYM’
rc fn params { ret p##fn args ; }
^
In file included from ./src/video/x11/SDL_x11dyn.h:34:0,
from ./src/video/x11/SDL_x11dyn.c:26:
/usr/include/X11/Xlibint.h:568:12: note: previous declaration of ‘_XData32’ was here
extern int _XData32(
^
make: *** [build/SDL_x11dyn.lo] 错误 1
只需将其中的第168、169行代码注释掉即可:
#ifdef LONG64
SDL_X11_MODULE(IO_32BIT)
//SDL_X11_SYM(int,_XData32,(Display *dpy,register long *data,unsigned len),(dpy,data,len),return)
//SDL_X11_SYM(void,_XRead32,(Display *dpy,register long *data,long len),(dpy,data,len),)
#endif
SDL编译安装后如下:
zhujinhua@thinkpadE455:~/ffmpeg/SDL-1.2.15$ ll /usr/local/lib/*SDL*
lrwxrwxrwx 1 root root 20 2月 25 23:01 /usr/local/lib/libSDL-1.2.so.0 -> libSDL-1.2.so.0.11.4
-rwxr-xr-x 1 root root 2363853 2月 25 23:01 /usr/local/lib/libSDL-1.2.so.0.11.4
-rw-r--r-- 1 root root 4798606 2月 25 23:01 /usr/local/lib/libSDL.a
-rwxr-xr-x 1 root root 954 2月 25 23:01 /usr/local/lib/libSDL.la
-rw-r--r-- 1 root root 4874 2月 25 23:01 /usr/local/lib/libSDLmain.a
-rwxr-xr-x 1 root root 905 2月 25 23:01 /usr/local/lib/libSDLmain.la
lrwxrwxrwx 1 root root 20 2月 25 23:01 /usr/local/lib/libSDL.so -> libSDL-1.2.so.0.11.4
3:编译ffplay时找不到SDL的头文件
需要修改common.mak,增加如下红色部分
# NASM requires -I path terminated with /
IFLAGS := -I/usr/local/include/SDL -I. -I$(SRC_LINK)/
编译通过后链接时如下错误:
ffplay.o:在函数‘main’中:
/home/zhujinhua/ffmpeg/ffmpeg-3.0/ffplay.c:3815:对‘SDL_Init’未定义的引用
/home/zhujinhua/ffmpeg/ffmpeg-3.0/ffplay.c:3827:对‘SDL_EventState’未定义的引用
/home/zhujinhua/ffmpeg/ffmpeg-3.0/ffplay.c:3828:对‘SDL_EventState’未定义的引用
/home/zhujinhua/ffmpeg/ffmpeg-3.0/ffplay.c:3829:对‘SDL_EventState’未定义的引用
/home/zhujinhua/ffmpeg/ffmpeg-3.0/ffplay.c:3831:对‘SDL_EnableKeyRepeat’未定义的引用
修改common.mak,增加SDL库即可:
ALLFFLIBS = avcodec avdevice avfilter avformat avresample avutil postproc swscale swresample SDL