From db2136cd0473e46b1dc7aae9d32c37841bf5a7ff Mon Sep 17 00:00:00 2001
From: zhangmeng <775834166@qq.com>
Date: 星期四, 24 十月 2019 11:01:08 +0800
Subject: [PATCH] add backup rec
---
csrc/buz/recorder.cpp | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/csrc/buz/recorder.cpp b/csrc/buz/recorder.cpp
index 17f2306..beda224 100644
--- a/csrc/buz/recorder.cpp
+++ b/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;
--
Gitblit v1.8.0