video analysis2.0拆分,ffmpeg封装go接口库
zhangmeng
2019-10-24 db2136cd0473e46b1dc7aae9d32c37841bf5a7ff
add backup rec
1个文件已修改
16 ■■■■ 已修改文件
csrc/buz/recorder.cpp 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
csrc/buz/recorder.cpp
@@ -84,6 +84,12 @@
            std::string filename(sole::uuid4().base62() + "-" + std::to_string(pid) + ".mp4");
            file_path_ = dir_ + "/" + filename;
            std::string backup_dir("./video");
            size_t pos = dir_.rfind("/");
            if (pos != std::string::npos){
                backup_dir = dir_.substr(0, pos);
            }
            auto v = in_->getStream(AVMEDIA_TYPE_VIDEO);
            if (!v){
                return -2;
@@ -97,10 +103,9 @@
                logIt("start record h264 file: %s", file_path_.c_str());                
                return 0;
            }else{
                std::string backup_dir("./video");
                mkdir(backup_dir.c_str(), 0777);
                file_path_ = backup_dir + "/" + filename;
                logIt("failed in dir %s, try file %s to start record file", dir_.c_str(), file_path_.c_str());                
                ret = out_->JustWriter(v, a, file_path_.c_str());
                if (ret){
@@ -123,9 +128,14 @@
            std::string filename(sole::uuid4().base62() + "-" + std::to_string(pid) + ".hevc");
            file_path_ = dir_ + "/" + filename;
            std::string backup_dir("./video");
            size_t pos = dir_.rfind("/");
            if (pos != std::string::npos){
                backup_dir = dir_.substr(0, pos);
            }
            fp_ = fopen(file_path_.c_str(), "wb");
            if (!fp_){
                std::string backup_dir("./video");
                mkdir(backup_dir.c_str(), 0777);
                file_path_ = backup_dir + "/" + filename;