1.srs的分辨率在config.json配置
2.单播推流控制,国标摄像机差一个关闭测试
3. 底库字段添加
| | |
| | | std::string publish_basepath = "rtmp://localhost:1934/live/cam" + std::to_string(554); |
| | | appPref.setIntData("gpu.index", 0); |
| | | appPref.setStringData("publish.basepath", publish_basepath); |
| | | appPref.setIntData("pulish.width", 640); |
| | | appPref.setIntData("pulish.height", 360); |
| | | // appPref.setIntData("pulish.width", 640); |
| | | // appPref.setIntData("pulish.height", 360); |
| | | |
| | | AppPipeController a(0, json); |
| | | a.start(); |
| | |
| | | #ifdef TestCode |
| | | DBG("waitSignal(\"DecoderImageOK\") after"); |
| | | #endif |
| | | { |
| | | if (p_this->m_publishVideoRet) { |
| | | if (p_this->videoPublishElement == nullptr) { |
| | | string path = appConfig.getStringProperty("srsAddr") + "cam" + p_this->m_chanPubID + ".flv"; |
| | | cv::Size size_(appConfig.getIntProperty("pulish.width"), appConfig.getIntProperty("pulish.height")); |
| | | int gupIdx = appPref.getIntData("gpu.index"); |
| | | DBG("videoPublishpath: " << p_this->m_chanPubID << path << " h:" << size_.height); |
| | | p_this->videoPublishElement = new ffmpeg::VideoPublishElement(path, size_, "flv", 25, gupIdx); |
| | | p_this->videoPublishElement->start(); |
| | | } else { |
| | | DBG("videoPublishElement->setImage() : " << p_this->m_chanPubID); |
| | | if (!p_this->m_image.empty()) { |
| | | p_this->videoPublishElement->setImage(p_this->m_image); |
| | | } else { |
| | | ERR("m_image.empty()"); |
| | | } |
| | | } |
| | | } else { |
| | | if (p_this->videoPublishElement != nullptr) { |
| | | DBG("videoPublishElement->stop() :" << p_this->m_chanPubID); |
| | | p_this->videoPublishElement->stop(); |
| | | p_this->videoPublishElement->wait(); |
| | | delete p_this->videoPublishElement; |
| | | p_this->videoPublishElement = nullptr; |
| | | }else{ |
| | | DBG("videoPublishElement null :" << p_this->m_chanPubID); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /****录像模块代码*****/ |
| | | p_this->m_picCount++; |
| | | //几张选一张放入Redis |
| | |
| | | } |
| | | |
| | | void BASICGB28181::VideoCaptureElementWithRtp::threadFunc() { |
| | | |
| | | if (m_publishVideoRet) { |
| | | if (videoPublishElement == nullptr) { |
| | | string path = appConfig.getStringProperty("srsAddr") + "cam" + m_chanPubID + ".flv"; |
| | | cv::Size size_(appConfig.getIntProperty("pulish.width"), appConfig.getIntProperty("pulish.height")); |
| | | int gupIdx = appPref.getIntData("gpu.index"); |
| | | videoPublishElement = new ffmpeg::VideoPublishElement(path, size_, "flv", 25, gupIdx); |
| | | } else { |
| | | videoPublishElement->stop(); |
| | | videoPublishElement->wait(); |
| | | delete videoPublishElement; |
| | | videoPublishElement = nullptr; |
| | | } |
| | | } |
| | | // { |
| | | // if (m_publishVideoRet) { |
| | | // if (videoPublishElement == nullptr) { |
| | | // string path = appConfig.getStringProperty("srsAddr") + "cam" + m_chanPubID + ".flv"; |
| | | // cv::Size size_(appConfig.getIntProperty("pulish.width"), appConfig.getIntProperty("pulish.height")); |
| | | // int gupIdx = appPref.getIntData("gpu.index"); |
| | | // DBG("videoPublishpath:" << path << " h:" << size_.height << " w:" << size_.width); |
| | | // videoPublishElement = new ffmpeg::VideoPublishElement(path, size_, "flv", 25, gupIdx); |
| | | // videoPublishElement->start(); |
| | | // } else { |
| | | // if (!m_image.empty()) { |
| | | // videoPublishElement->setImage(m_image); |
| | | // } else { |
| | | // ERR("m_image.empty()"); |
| | | // } |
| | | // } |
| | | // } else { |
| | | // if (videoPublishElement != nullptr) { |
| | | // DBG("videoPublishElement->stop()"); |
| | | // videoPublishElement->stop(); |
| | | // videoPublishElement->wait(); |
| | | // delete videoPublishElement; |
| | | // videoPublishElement = nullptr; |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | fireConnectors(); |
| | | } |
| | |
| | | |
| | | std::atomic<bool> m_running; |
| | | std::atomic<bool> m_waitSignal; |
| | | std::atomic<bool> m_waitSignalrunning; |
| | | std::atomic<bool> m_waitSignalrunning{false}; |
| | | |
| | | //用来保存录像视频的路径 |
| | | std::string m_cutPath; |
| | | std::atomic<bool> m_publishVideoRet{false}; |
| | | ffmpeg::VideoPublishElement * videoPublishElement; |
| | | ffmpeg::VideoPublishElement * videoPublishElement{nullptr}; |
| | | private: |
| | | /*** |
| | | * 启动实时流接收数据线程 |
| | |
| | | // %% ALTER TABLE sys_o_tables ADD COLUMN uploadFlag varchar(255) DEFAULT 0; |
| | | // %% ALTER TABLE sys_o_tables ADD COLUMN cmpThreshold varchar(255) DEFAULT 60; |
| | | // %% ALTER TABLE sys_o_tables ADD COLUMN enabled varchar(255) DEFAULT 1; |
| | | |
| | | // %% ALTER TABLE "0cd82a8b-5285-5737-ab19-8c07247c797e" ADD COLUMN uploadFlag varchar(255) DEFAULT 0; |
| | | // %% ALTER TABLE "0cd82a8b-5285-5737-ab19-8c07247c797e" ADD COLUMN cmpThreshold varchar(255) DEFAULT 60; |
| | | // %% ALTER TABLE "0cd82a8b-5285-5737-ab19-8c07247c797e" ADD COLUMN enabled varchar(255) DEFAULT 1; |
| | | |
| | | std::string sql = "CREATE TABLE \"main\".\"sys_o_tables\" ("; |
| | | sql.append(" uuid varchar(255) PRIMARY KEY, "); |
| | | // sql.append(" ClusterName varchar(255) DEFAULT NULL,");//本地库不需要 |
| | |
| | | sql.append("create_by varchar(255) DEFAULT NULL,"); |
| | | sql.append("del_flag INTEGER DEFAULT 0,"); |
| | | sql.append("monitorLevel varchar(255) DEFAULT 0,"); |
| | | sql.append("uploadFlag varchar(255) DEFAULT 0,"); |
| | | sql.append("cmpThreshold varchar(255) DEFAULT 60,"); |
| | | sql.append("enabled varchar(255) DEFAULT 1"); |
| | | sql.append(");"); |
| | | // 人脸特征表 |
| | |
| | | if (pthis->m_GB28181_Enable) { |
| | | if (pthis->m_controllers_videoCapElem.find(cam_idx) != |
| | | pthis->m_controllers_videoCapElem.end()) { |
| | | INFO("cam add is " << cfg_val["str_addr"].asString()); |
| | | INFO("cam add is " << cam_idx); |
| | | pthis->m_controllers_videoCapElem[cam_idx]->startPublishVideo(); |
| | | } |
| | | } else { |
| | | if (pthis->m_controllers.find(cam_idx) != pthis->m_controllers.end()) { |
| | | INFO("cam add is " << cfg_val["str_addr"].asString()); |
| | | INFO("cam add is " << cam_idx); |
| | | pthis->m_controllers[cam_idx]->startPublishVideo(); |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | m_picCount++; |
| | | //几张选一张放入Redis |
| | | if (m_picCount % m_nPicsPickOne != 0) { |
| | | return; |
| | | } else { |
| | | m_picCount.store(0); |
| | | } |
| | | |
| | | { |
| | | u_char *data; |
| | | int width = 0, height = 0, step = 0, cn = 0; |
| | | m_capture->retrieveFrame(0, &data, &step, &width, &height, &cn); |
| | | |
| | | cv::Mat img(height, width, CV_8UC3, data, step); |
| | | cv::Mat copyMat; |
| | | img.copyTo(copyMat); |
| | | std::string imageName = m_capture->GetImageName(); |
| | | m_pManager->SaveImageToRedis(m_camId, imageName, copyMat); |
| | | } |
| | | //#todo publish Video |
| | | |
| | | //#publish Video |
| | | if (m_publishVideoRet) { |
| | | if (videoPublishElement == nullptr) { |
| | | string path = appConfig.getStringProperty("srsAddr") + "cam" + m_camId + ".flv"; |
| | | cv::Size size_(appConfig.getIntProperty("pulish.width"), appConfig.getIntProperty("pulish.height")); |
| | | int gupIdx = appPref.getIntData("gpu.index"); |
| | | DBG("size_:" << size_.width << "X" << size_.height); |
| | | videoPublishElement = new ffmpeg::VideoPublishElement(path, size_, "flv", 25, gupIdx); |
| | | videoPublishElement->start(); |
| | | } else { |
| | | // DBG("videoPublishElement->setImage()"); |
| | | m_capture->retrieveFrame(0, &data, &step, &width, &height, &cn); |
| | | cv::Mat img(height, width, CV_8UC3, data, step); |
| | | img.copyTo(copyMat); |
| | | |
| | | if (!copyMat.empty()) { |
| | | videoPublishElement->setImage(copyMat); |
| | | } else { |
| | | DBG("copyMat.empty()"); |
| | | } |
| | | } |
| | | } else { |
| | | if (videoPublishElement != nullptr) { |
| | | DBG("videoPublishElement->stop()"); |
| | | videoPublishElement->stop(); |
| | | videoPublishElement->wait(); |
| | | delete videoPublishElement; |
| | | videoPublishElement = nullptr; |
| | | } |
| | | } |
| | | |
| | | //几张选一张放入Redis |
| | | m_picCount++; |
| | | if (m_picCount % m_nPicsPickOne != 0) { |
| | | return; |
| | | } else { |
| | | m_picCount.store(0); |
| | | } |
| | | |
| | | if (copyMat.empty()) { |
| | | // ERR("copyMat.empty()"); |
| | | m_capture->retrieveFrame(0, &data, &step, &width, &height, &cn); |
| | | cv::Mat img(height, width, CV_8UC3, data, step); |
| | | img.copyTo(copyMat); |
| | | } |
| | | std::string imageName = m_capture->GetImageName(); |
| | | m_pManager->SaveImageToRedis(m_camId, imageName, copyMat); |
| | | |
| | | fireConnectors(); |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | std::atomic<bool> m_publishVideoRet{false}; |
| | | ffmpeg::VideoPublishElement *videoPublishElement; |
| | | ffmpeg::VideoPublishElement *videoPublishElement{nullptr}; |
| | | // Redis的工具类 |
| | | // HiredisTool m_redisTool; |
| | | |