監控直播方案
越來越多人的開始将普通安防錄影機接入網絡流媒體伺服器,進行網絡直播。但是市面上安防錄影機的品牌、型号比較多,想通過SDK方式接入這些各種錄影機不現實。由于安防錄影機基本都是可以輸出rtsp流,是以我們可以用拉取RTSP流的方式來相容各家的錄影機。 LiveGBS就是通過GB28181協定接入安防錄影機或,轉成RTMP和HLS流,可以在各平台上進行H5 web直播或者app直播。
直播方案中快照抓取
LiveGBS實作了拉取錄影機實時、曆史視訊流,實作監控直播。直播的過程隻是流媒體資料轉發的過程,不進行解碼,這樣對CPU等硬體資源消耗較小。
但是直播時,可能希望定時抓取一張實時圖檔進行封面展示、資料分析等。這種情況就需要定時擷取一幀資料進行解碼,抓成jpg或bmp圖檔。
如下是将視訊某一幀資料轉成圖檔的代碼:
bool rawData2Image(char* rawBuf, int bufSize, int codec, int width, int height, const char* jpgpath)
{
decodeParam.codec = codec;
decodeParam.width = width;
decodeParam.height = height;
if (!decoderHelper_)
{
decoderHelper_ = new DecoderHelper;
}
decoderHelper_->SetVideoDecoderParam(width, height, codec);
int ret = decoderHelper_->DecodeVideo(rawBuf, bufSize);
if (ret < 0)
{
return false;
}
decoderHelper_->WriteJPEG(jpgpath);
if (QTSServerInterface::GetServer()->GetThridPartPlatformModule())
{
if (!decodeParam.imageData)
decodeParam.imageData = new char[width * height * 3];
memset(decodeParam.imageData, 0, width * height * 3);
FILE* snapFile = ::fopen(jpgpath, "rb");
if (snapFile)
{
// obtain file size: 獲得檔案大小
::fseek(snapFile, 0, SEEK_END); // 指針移到檔案末位
decodeParam.imageSize = ftell(snapFile); // 獲得檔案長度
::rewind(snapFile); // 函數rewind()把檔案指針移到由stream(流)指定的開始處, 同時清除和流相關的錯誤和EOF标記
::fread(decodeParam.imageData, 1, decodeParam.imageSize, snapFile);
::fclose(snapFile);
}
}
return true;
}
下載下傳
LiveGBS 就是實作将傳統安防錄影機實作在網際網路直播、錄像、回放,相容Windows和各移動終端。
大家可以在 https://gitee.com/liveqing/ReleaseVersion 下載下傳LiveGBS測試。
擷取更多資訊
郵件:[email protected]
技術交流QQ群:947137753
咨詢電話:15156896292
試用下載下傳:https://gitee.com/liveqing/ReleaseVersion/
LiveQing視訊流媒體無插件直播方案:www.liveqing.com
Copyright © LiveQing Team 2016-2019