live555的编译及使用
live555是个流媒体C++开源库,VLC的Meida Player就使用了它的API完成的RTSP客户端,由于VLC的SDK没有提供相关record流到视频文件的API,所以我想用过live555的例子学习,但是live555它不自带二进制的发布,必须自己编译。
编译live555:
http://www.cnblogs.com/skyseraph/archive/2012/04/11/2442840.html
这个是打好的VS2013的包,编译live555的工程:
http://download.csdn.net/detail/zgzhaobo/7376487
live555的OpenRTSP例子程序可以打开接收流,并且进行存储为视频文件。当然听说FFMPEG也可以,但是我看了些例子,比较复杂,所以不看了。而且VLC也是使用live555来做的。所以就打算研究这个。
我是用VS2013编译的,但是照链接文章的方法,出现了Error U1052: File 'ntwin32.mak' not found的错误,原来是在VS2013安装的时候,把ntwin32.mak拷贝到VC的include目录下失败了,所以就没有,是从我的C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include这个目录拷贝的,这里面有ntwin32.mak 和win32.mak,这两个都需要。拷贝到VS2013的安装目录的VC目录的include目录下。编译就不会出错了。但是这个过程中还有一个错误:就是打开msvcirt.lib 这个库错误,心想,这是啥库啊,都没有听过,其实这个msvcirt.lib 是老版本的名字,不是新的,VS2013的SDK当然是新的了,所以要用CRT,msvcrt.lib 这个运行时库,原来是win32config这个文件里面这个域LINK_OPTS_0 的库名字写错了,把它改成msvcrt.lib 就行了。然后就完美成功生成相关lib了。唉,开源的东西真心蛋疼啊,windows上编译又不友好。
照上面的方法,默认编译出来的是x86的,需要编译成x64的。
就需要在VS2013的VS tools里面找到x64 Native Common Prompt的命令行工具进行编译。做个好人,还是把x64相关的win32config修改贴上来吧:
1 # Comment out the following line to produce Makefiles that generate debuggable code: 2 NODEBUG=1 3 4 # The following definition ensures that we are properly matching 5 # the WinSock2 library file with the correct header files. 6 # (will link with "ws2_32.lib" and include "winsock2.h" & "Ws2tcpip.h") 7 TARGETOS = WINNT 8 9 # If for some reason you wish to use WinSock1 instead, uncomment the 10 # following two definitions. 11 # (will link with "wsock32.lib" and include "winsock.h") 12 #TARGETOS = WIN95 13 #APPVER = 4.0 14 15 !include <ntwin32.mak> 16 17 UI_OPTS = $(guilflags) $(guilibsdll) 18 # Use the following to get a console (e.g., for debugging): 19 CONSOLE_UI_OPTS = $(conlflags) $(conlibsdll) 20 CPU=i386 21 22 TOOLS32 = D:\MathxH\SoftWare\VS2013\VC 23 COMPILE_OPTS = $(INCLUDES) $(cdebug) $(cflags) $(cvarsdll) -I. -I"$(TOOLS32)\include" 24 C = c 25 C_COMPILER = "$(TOOLS32)\bin\amd64\cl" 26 C_FLAGS = $(COMPILE_OPTS) 27 CPP = cpp 28 CPLUSPLUS_COMPILER = $(C_COMPILER) 29 CPLUSPLUS_FLAGS = $(COMPILE_OPTS) 30 OBJ = obj 31 LINK = $(link) -out: 32 LIBRARY_LINK = lib -out: 33 LINK_OPTS_0 = $(linkdebug) msvcrt.lib 34 LIBRARY_LINK_OPTS = 35 LINK_OPTS = $(LINK_OPTS_0) $(UI_OPTS) 36 CONSOLE_LINK_OPTS = $(LINK_OPTS_0) $(CONSOLE_UI_OPTS) 37 SERVICE_LINK_OPTS = kernel32.lib advapi32.lib shell32.lib -subsystem:console,$(APPVER) 38 LIB_SUFFIX = lib 39 LIBS_FOR_CONSOLE_APPLICATION = 40 LIBS_FOR_GUI_APPLICATION = 41 MULTIMEDIA_LIBS = winmm.lib 42 EXE = .exe 43 PLATFORM = Windows 44 45 rc32 = "$(TOOLS32)\bin\rc" 46 .rc.res: 47 $(rc32) $<
references:
http://superuser.com/questions/766437/capture-rtsp-stream-from-ip-camera-and-store
https://social.msdn.microsoft.com/Forums/vstudio/en-US/4db6024e-cb2c-4992-9fb8-4aeefc194733/ntwin32mak-not-found
http://bbs.csdn.net/topics/360035084
http://stackoverflow.com/questions/29041258/building-64bit-live555-with-visual-studio-2013