diff options
| author | Ingar <ingar@telenet.be> | 2026-11-19 22:17:16 +0100 |
|---|---|---|
| committer | Ingar <ingar@telenet.be> | 2026-11-19 22:17:16 +0100 |
| commit | b84ba7a8d7412783f18b914b89afb1f3122278de (patch) | |
| tree | d434dfdaff8c827c2d374349194f5cf532cad847 /rpicam-apps-1.13.0-outputfilename.patch | |
| parent | bfb4c5cdff0e682dc8b54a572fe153ed81391036 (diff) | |
Added new patch file.
Diffstat (limited to 'rpicam-apps-1.13.0-outputfilename.patch')
| -rw-r--r-- | rpicam-apps-1.13.0-outputfilename.patch | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/rpicam-apps-1.13.0-outputfilename.patch b/rpicam-apps-1.13.0-outputfilename.patch new file mode 100644 index 0000000..dcf9297 --- /dev/null +++ b/rpicam-apps-1.13.0-outputfilename.patch @@ -0,0 +1,69 @@ +diff -ur rpicam-apps-1.13.0/apps/rpicam_still.cpp rpicam-apps-1.13.0-ingar/apps/rpicam_still.cpp +--- rpicam-apps-1.13.0/apps/rpicam_still.cpp 2026-10-09 12:12:22.000000000 +0200 ++++ rpicam-apps-1.13.0-ingar/apps/rpicam_still.cpp 2026-11-19 21:47:14.187396989 +0100 +@@ -43,36 +43,30 @@ + + static std::string generate_filename(StillOptions const *options) + { +- std::string folder = options->Get().output; // sometimes "output" is used as a folder name +- if (!folder.empty() && folder.back() != '/') +- folder += "/"; ++ // treat the output file name as a mask ++ char filename[2048]; + if (options->Get().datetime) + { ++ // expects "%s" in the filename + std::time_t raw_time; + std::time(&raw_time); + char time_string[32]; + std::tm *time_info = std::localtime(&raw_time); +- std::strftime(time_string, sizeof(time_string), "%m%d%H%M%S", time_info); +- std::ostringstream os; +- os << folder << time_string << "." << options->Get().encoding; +- return os.str(); ++ std::strftime(time_string, sizeof(time_string), "%Y%m%d%H%M%S", time_info); ++ snprintf(filename, sizeof(filename), options->Get().output.c_str(), time_string); + } + else if (options->Get().timestamp) + { +- std::ostringstream os; +- os << folder << (unsigned)time(NULL) << "." << options->Get().encoding; +- return os.str(); ++ // expects "%u" in the filename ++ snprintf(filename, sizeof(filename), options->Get().output.c_str(), (unsigned)time(NULL)); + } +- +- // The output string may contain a printf-style format specifier (e.g. "%04d") for the +- // frame number, so size the buffer dynamically to avoid truncating long filenames. +- std::string const &format = options->Get().output; +- int len = snprintf(nullptr, 0, format.c_str(), options->Get().framestart); +- if (len < 0) +- return {}; +- std::string filename(len, '\0'); +- snprintf(filename.data(), len + 1, format.c_str(), options->Get().framestart); +- return filename; ++ else ++ { ++ // expects "%d" in the filename ++ snprintf(filename, sizeof(filename), options->Get().output.c_str(), options->Get().framestart); ++ } ++ filename[sizeof(filename) - 1] = 0; ++ return std::string(filename); + } + + static void update_latest_link(std::string const &filename, StillOptions const *options) +diff -ur rpicam-apps-1.13.0/core/still_options.hpp rpicam-apps-1.13.0-ingar/core/still_options.hpp +--- rpicam-apps-1.13.0/core/still_options.hpp 2026-10-09 12:12:22.000000000 +0200 ++++ rpicam-apps-1.13.0-ingar/core/still_options.hpp 2026-11-19 21:50:16.919782197 +0100 +@@ -27,9 +27,9 @@ + ("framestart", value<uint32_t>(&v_->framestart)->default_value(0), + "Initial frame counter value for timelapse captures") + ("datetime", value<bool>(&v_->datetime)->default_value(false)->implicit_value(true), +- "Use date format for output file names") ++ "Replace %s with date and time in output file names") + ("timestamp", value<bool>(&v_->timestamp)->default_value(false)->implicit_value(true), +- "Use system timestamps for output file names") ++ "Replace %u with timestamp in output file names") + ("restart", value<unsigned int>(&v_->restart)->default_value(0), + "Set JPEG restart interval") + ("keypress,k", value<bool>(&v_->keypress)->default_value(false)->implicit_value(true), |
