Add --source CLI flag to override video source

This commit is contained in:
proitlab committed 2026-08-04 23:37:07 +07:00
1 parent eefff48953
commit a94c3dff87
3 files changed
+25 -4

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 = "bb7d08ab"; const std::string GIT_COMMIT = "eefff489";
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-07-29"; const std::string BUILD_DATE = "2026-08-04";
const std::string BUILD_TIME = "00:00:24"; const std::string BUILD_TIME = "23:35:10";
const int BUILD_YEAR = 2026; const int BUILD_YEAR = 2026;
const bool BUILD_RKNN = 1; const bool BUILD_RKNN = 1;
+22 -1
View File
@@ -100,6 +100,21 @@ int main(int argc, char* argv[]) {
signal(SIGINT, signal_handler); signal(SIGINT, signal_handler);
signal(SIGTERM, signal_handler); signal(SIGTERM, signal_handler);
std::string cli_source;
for (int i = 2; i < argc; ++i) {
std::string a = argv[i];
if (a == "--source" || a == "-s") {
if (i + 1 < argc) {
cli_source = argv[++i];
} else {
std::cerr << "Error: --source requires a value" << std::endl;
return 1;
}
} else if (a.rfind("--source=", 0) == 0) {
cli_source = a.substr(9);
}
}
if (argc < 2) { if (argc < 2) {
std::cout << "ByteTrack Counter (C++)" << std::endl; std::cout << "ByteTrack Counter (C++)" << std::endl;
std::cout << "Version: " << version::GIT_COMMIT std::cout << "Version: " << version::GIT_COMMIT
@@ -109,13 +124,19 @@ int main(int argc, char* argv[]) {
if (!version::GIT_TAG.empty()) if (!version::GIT_TAG.empty())
std::cout << " | tag: " << version::GIT_TAG; std::cout << " | tag: " << version::GIT_TAG;
std::cout << std::endl; std::cout << std::endl;
std::cout << "Usage: bytetrack-counter <config.env>" << std::endl; std::cout << "Usage: bytetrack-counter <config.env> [--source <rtsp://|http://|/path/to/file.mp4>]" << std::endl;
std::cout << " config.env path to environment configuration file (required)" << std::endl; std::cout << " config.env path to environment configuration file (required)" << std::endl;
std::cout << " --source, -s override video source (rtsp://, http://, or local file)" << std::endl;
return 1; return 1;
} }
g_config.load_from_env(argv[1]); g_config.load_from_env(argv[1]);
if (!cli_source.empty()) {
g_config.source = cli_source;
std::cout << "Source overridden by CLI: " << g_config.source << std::endl;
}
std::cout << "Starting ByteTrack Counter (C++)" << std::endl; std::cout << "Starting ByteTrack Counter (C++)" << std::endl;
std::cout << "Version: " << version::GIT_COMMIT std::cout << "Version: " << version::GIT_COMMIT
<< " | branch: " << version::GIT_BRANCH << " | branch: " << version::GIT_BRANCH