From c8bed31dc4e01b5163981900d5b3b62efbe0ec72 Mon Sep 17 00:00:00 2001 From: Ingar Date: Mon, 15 Apr 2024 22:22:36 +0200 Subject: Added output filename patch for raspicam-still. --- PKGBUILD | 5 ++- rpicam-apps-1.4.3-outputfilename.patch | 57 ++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 rpicam-apps-1.4.3-outputfilename.patch diff --git a/PKGBUILD b/PKGBUILD index 206b175..e2becc5 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,4 +1,4 @@ -pkgname=rpicam-apps +pkgname=rpicam-apps-ing pkgver=1.4.3 pkgrel=1 pkgdesc="Camera utilities for the Raspberry Pi" @@ -7,10 +7,12 @@ url='https://github.com/raspberrypi/rpicam-apps' source=( "https://github.com/raspberrypi/rpicam-apps/releases/download/v${pkgver}/rpicam-apps-${pkgver}.tar.xz" "rpicam.rules" + "rpicam-apps-1.4.3-outputfilename.patch" ) sha256sums=( "c5415249eb8216a5c7063d31c713ba84cac88103f65ae0dcf097f1839156102e" "4045e41e24d8c3e247b667a66bc9eee13918f599f464003dde25ca55ed7bb995" + "1e53aa6ea95ded5b6e6d28bac35f53b5725c06a99ab4664e37e88869dfe2e698" ) depends=( boost @@ -27,6 +29,7 @@ optdepends=() prepare() { cd rpicam-apps-${pkgver} + patch -Np1 -i "${srcdir}/rpicam-apps-1.4.3-outputfilename.patch" mkdir build arch-meson build \ --buildtype=release \ diff --git a/rpicam-apps-1.4.3-outputfilename.patch b/rpicam-apps-1.4.3-outputfilename.patch new file mode 100644 index 0000000..fc748ff --- /dev/null +++ b/rpicam-apps-1.4.3-outputfilename.patch @@ -0,0 +1,57 @@ +diff --git a/apps/rpicam_still.cpp b/apps/rpicam_still.cpp +index 5721edc..5ce78ea 100644 +--- a/apps/rpicam_still.cpp ++++ b/apps/rpicam_still.cpp +@@ -34,24 +34,28 @@ public: + + static std::string generate_filename(StillOptions const *options) + { +- char filename[128]; +- std::string folder = options->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->datetime) + { + 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); +- snprintf(filename, sizeof(filename), "%s%s.%s", folder.c_str(), time_string, options->encoding.c_str()); ++ std::strftime(time_string, sizeof(time_string), "%Y%m%d%H%M%S", time_info); ++ // expects "%s" in the filename ++ snprintf(filename, sizeof(filename), options->output.c_str(), time_string); + } + else if (options->timestamp) +- snprintf(filename, sizeof(filename), "%s%u.%s", folder.c_str(), (unsigned)time(NULL), +- options->encoding.c_str()); ++ { ++ // expects "%u" in the filename ++ snprintf(filename, sizeof(filename), options->output.c_str(), (unsigned)time(NULL)); ++ } + else ++ { ++ // expects "%d" in the filename + snprintf(filename, sizeof(filename), options->output.c_str(), options->framestart); ++ } + filename[sizeof(filename) - 1] = 0; + return std::string(filename); + } +diff --git a/core/still_options.hpp b/core/still_options.hpp +index 1d1fbe7..3338767 100644 +--- a/core/still_options.hpp ++++ b/core/still_options.hpp +@@ -27,9 +27,9 @@ struct StillOptions : public Options + ("framestart", value(&framestart)->default_value(0), + "Initial frame counter value for timelapse captures") + ("datetime", value(&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(×tamp)->default_value(false)->implicit_value(true), +- "Use system timestamps for output file names") ++ "Replace %u with timestamp in output file names") + ("restart", value(&restart)->default_value(0), + "Set JPEG restart interval") + ("keypress,k", value(&keypress)->default_value(false)->implicit_value(true), -- cgit v1.2.3