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