流媒体开发之开源项目live555---live555 server 编译 包括更改帧率大小
由于要測試8148解碼器的性能,需要搭建不同幀率25fps - >30fps,宏塊大小defualt 100 000 -》 200 000不同大小的h264碼流,所以就需要編譯改動的live555 server ,沒想到很順利,用的是vs2010,一步到位沒報任何錯誤。這里做一下筆記方便下次使用:
1.準備源碼www.live555.com 下載最新源碼包,解壓
主要包括服務端和客戶端
用到的主要有4大模塊:livemedia groupsock ?basicuseageenvironmental usageenvironment ?+testprogs?
服務端:livemedia groupsock basicuseageenironmental usageenvironmental + mediaserver
客戶端:livemedia groupsock basicusageenvironmental usageenvironmental + testprogs(單路收取流的話就用:openrtsp.cpp playcommon.cpp 再轉發的話加個fifo.c隊列緩存)
2.編譯選用win32工程先說客戶端
先建一個空的工程,然后添加所有live555目錄下的include下的頭文件.hh添加到header頭文件里面,然后添加cpp文件主要是四大模塊livemedia groupsock basicusageenvironmental usageenvironmental 不包括testprogs ,為了方便調用,app testprogs 獨立建一個工程目錄myclient 然后在里面添加openrtsp.cpp playcommon.cpp playcommon.hh;
文件添加完之后,得設置工程屬性:
VS2010添加方法如下:
方法一:
工程properties
linker->input->additional depandencies
?
方法二:
直接包含
#include<winsock2.h>
#pragma comment(lib,"ws_32.lib")
繼續在工程里面
工程properties
c/c++->general->additional Include Directories 包含include下的所有頭文件愛你.hh(我這里就全部在一個工程目錄下live555server/client)
服務端一樣,不同的是在api 不同服務端有個專門的mediaserver 目錄 作為主程序,我們直接將下面的兩個DynamicRTSPServer.cpp?live555MediaServer.cpp兩個 文件添加到myserver 工程目錄下。
####################1 片包大小
順便修改下maxbuffer 宏塊大小在dynamicrtspserver.cpp中:
NEW_SMS("H.264 Video");
OutPacketBuffer::maxSize = 200000; // allow for some possibly large H.264 frames
printf("maxsize h264 change by pkf 200k!\n");
####################2 幀率大小
在h264or5streamframer.cpp中:
// H264or5VideoStreamFramer implementation //
H264or5VideoStreamFramer
::H264or5VideoStreamFramer(int hNumber, UsageEnvironment& env, FramedSource* inputSource,
Boolean createParser, Boolean includeStartCodeInOutput)
: MPEGVideoStreamFramer(env, inputSource),
fHNumber(hNumber),
fLastSeenVPS(NULL), fLastSeenVPSSize(0),
fLastSeenSPS(NULL), fLastSeenSPSSize(0),
fLastSeenPPS(NULL), fLastSeenPPSSize(0) {
fParser = createParser
? new H264or5VideoStreamParser(hNumber, this, inputSource, includeStartCodeInOutput)
: NULL;
fNextPresentationTime = fPresentationTimeBase;
fFrameRate = 25.0; // We assume a frame rate of 25 fps, unless we learn otherwise (from parsing a VPS or SPS NAL unit)
}
然后就是building咯。。。ok完成
2014-12-11 關于幀率修改的修正:
上面的幀率只是在幀率為0的情況下的默認值,后面會被同文件下的里一個函數重新復制修改unsigned H264or5VideoStreamParser::parse() 這個解析函數有如下修改:
else if (isSPS(nal_unit_type)) { // Sequence parameter set
// First, save a copy of this NAL unit, in case the downstream object wants to see it:
usingSource()->saveCopyOfSPS(fStartOfFrame + fOutputStartCodeSize, curFrameSize() - fOutputStartCodeSize);
if (fParsedFrameRate == 0.0) {
// We haven't yet parsed a frame rate from the stream.
// So parse this NAL unit to check whether frame rate information is present:
unsigned num_units_in_tick, time_scale;
analyze_seq_parameter_set_data(num_units_in_tick, time_scale);
if (time_scale > 0 && num_units_in_tick > 0) {
usingSource()->fFrameRate = fParsedFrameRate = 25;//2*time_scale/(2.0*num_units_in_tick);//這里才是真正的產生作用的地方!
2015-5-18 關于server read file loop:
在bytestreamfilesource.cpp 中的handleClosure();前面添加
if(feof(fFid))
{
fprintf(stderr,"frames=%d,tostremf = %d, fmaxs=%d\n",fPreferredFrameSize,fLimitNumBytesToStream,fMaxSize);
SeekFile64(fFid, 0, SEEK_SET);
doReadFromFile();
return;
}
?
3.live555mediaserver 的使用:把x.h264 文件和live555_server.exe放同一目錄下運行.exe ?版本0.83
4.最后美圖附圖一張
?
http://www.cnblogs.com/-simple-/p/3398009.html
http://www.cnblogs.com/skyseraph/archive/2012/04/11/2442840.html
http://blog.csdn.net/aobai219/article/details/5841951
http://blog.csdn.net/lf8289/article/details/7785898
http://blog.csdn.net/wolfliuming/article/details/6087070
http://download.csdn.net/detail/zgzhaobo/4220620
轉載于:https://www.cnblogs.com/pengkunfan/p/3975194.html
總結
以上是生活随笔為你收集整理的流媒体开发之开源项目live555---live555 server 编译 包括更改帧率大小的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 自定义键盘keyfere——pcsens
- 下一篇: PMBOK摘要