1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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<uint32_t>(&framestart)->default_value(0),
"Initial frame counter value for timelapse captures")
("datetime", value<bool>(&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>(×tamp)->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>(&restart)->default_value(0),
"Set JPEG restart interval")
("keypress,k", value<bool>(&keypress)->default_value(false)->implicit_value(true),
|