Use batch_X_YYYYMMDD_HHMMSS.mp4 filename for exported recordings

This commit is contained in:
proitlab committed 2026-08-05 00:26:01 +07:00
1 parent 37f98f243c
commit 31476d2fa7
3 files changed
+14 -12

No files matched your search

Binary file not shown.
+3 -3
View File
@@ -4,11 +4,11 @@
namespace version { namespace version {
const std::string GIT_COMMIT = "a94c3dff"; const std::string GIT_COMMIT = "37f98f24";
const std::string GIT_BRANCH = "main"; const std::string GIT_BRANCH = "main";
const std::string GIT_TAG = ""; const std::string GIT_TAG = "";
const std::string BUILD_DATE = "2026-08-04"; const std::string BUILD_DATE = "2026-08-05";
const std::string BUILD_TIME = "23:55:47"; const std::string BUILD_TIME = "00:25:19";
const int BUILD_YEAR = 2026; const int BUILD_YEAR = 2026;
const bool BUILD_RKNN = 1; const bool BUILD_RKNN = 1;
+11 -9
View File
@@ -4,6 +4,7 @@
#include <sstream> #include <sstream>
#include <iomanip> #include <iomanip>
#include <ctime> #include <ctime>
#include <algorithm>
#include <filesystem> #include <filesystem>
#include <sys/wait.h> #include <sys/wait.h>
#include <unistd.h> #include <unistd.h>
@@ -65,11 +66,15 @@ static std::string today_str() {
return ss.str(); return ss.str();
} }
static std::string timestamp_str() { static std::string build_mp4_name(int batch_number, const std::string& counting_date) {
std::string date_part = counting_date;
date_part.erase(std::remove(date_part.begin(), date_part.end(), '-'), date_part.end());
auto t = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); auto t = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
std::ostringstream ss; std::ostringstream name;
ss << std::put_time(std::localtime(&t), "%H%M%S"); name << "batch_" << batch_number << "_"
return ss.str(); << date_part << "_"
<< std::put_time(std::localtime(&t), "%H%M%S") << ".mp4";
return name.str();
} }
void VideoBatchWriter::note_motion() { void VideoBatchWriter::note_motion() {
@@ -179,9 +184,7 @@ void VideoBatchWriter::stop_and_move(int batch_number) {
std::string day_dir = output_dir_ + "/" + (current_date_.empty() ? today_str() : current_date_); std::string day_dir = output_dir_ + "/" + (current_date_.empty() ? today_str() : current_date_);
ensure_dir(day_dir); ensure_dir(day_dir);
std::ostringstream name; std::string dst = day_dir + "/" + build_mp4_name(batch_number, current_date_);
name << "batch_" << batch_number << "_" << timestamp_str() << ".mp4";
std::string dst = day_dir + "/" + name.str();
pid_t pid = fork(); pid_t pid = fork();
if (pid == 0) { if (pid == 0) {
@@ -208,8 +211,7 @@ void VideoBatchWriter::shutdown() {
if (prev_state == CONFIRMED || prev_state == STOPPING) { if (prev_state == CONFIRMED || prev_state == STOPPING) {
std::string day_dir = output_dir_ + "/" + (current_date_.empty() ? today_str() : current_date_); std::string day_dir = output_dir_ + "/" + (current_date_.empty() ? today_str() : current_date_);
ensure_dir(day_dir); ensure_dir(day_dir);
std::string dst = day_dir + "/" + std::string dst = day_dir + "/" + build_mp4_name(current_batch_, current_date_);
fs::path(src).filename().string();
pid_t pid = fork(); pid_t pid = fork();
if (pid == 0) { if (pid == 0) {