mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-23 16:45:07 +03:00
cam: Allow specifying directories in the --file option
The value of the --file option is the full name of the file to which captured frames are written. To write files to a specific directory with the default naming scheme, the "frame-#.bin" name has to appear at the end of the file name. Simplify usage of the option by allowing --file to specify a directory only. If the file name ends with a '/', the default "frame-#.bin" file name is automatically appended. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
caa6ffacb2
commit
5082fe7b5b
3 changed files with 11 additions and 3 deletions
|
@ -49,7 +49,12 @@ int BufferWriter::write(FrameBuffer *buffer, const std::string &streamName)
|
||||||
size_t pos;
|
size_t pos;
|
||||||
int fd, ret = 0;
|
int fd, ret = 0;
|
||||||
|
|
||||||
filename = pattern_;
|
if (!pattern_.empty())
|
||||||
|
filename = pattern_;
|
||||||
|
|
||||||
|
if (filename.empty() || filename.back() == '/')
|
||||||
|
filename += "frame-#.bin";
|
||||||
|
|
||||||
pos = filename.find_first_of('#');
|
pos = filename.find_first_of('#');
|
||||||
if (pos != std::string::npos) {
|
if (pos != std::string::npos) {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
class BufferWriter
|
class BufferWriter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BufferWriter(const std::string &pattern = "frame-#.bin");
|
BufferWriter(const std::string &pattern = "");
|
||||||
~BufferWriter();
|
~BufferWriter();
|
||||||
|
|
||||||
void mapBuffer(libcamera::FrameBuffer *buffer);
|
void mapBuffer(libcamera::FrameBuffer *buffer);
|
||||||
|
|
|
@ -118,7 +118,10 @@ int CamApp::parseOptions(int argc, char *argv[])
|
||||||
"capture", ArgumentOptional, "count");
|
"capture", ArgumentOptional, "count");
|
||||||
parser.addOption(OptFile, OptionString,
|
parser.addOption(OptFile, OptionString,
|
||||||
"Write captured frames to disk\n"
|
"Write captured frames to disk\n"
|
||||||
"The first '#' character in the file name is expanded to the stream name and frame sequence number.\n"
|
"If the file name ends with a '/', it sets the directory in which\n"
|
||||||
|
"to write files, using the default file name. Otherwise it sets the\n"
|
||||||
|
"full file path and name. The first '#' character in the file name\n"
|
||||||
|
"is expanded to the stream name and frame sequence number.\n"
|
||||||
"The default file name is 'frame-#.bin'.",
|
"The default file name is 'frame-#.bin'.",
|
||||||
"file", ArgumentOptional, "filename");
|
"file", ArgumentOptional, "filename");
|
||||||
parser.addOption(OptStream, &streamKeyValue,
|
parser.addOption(OptStream, &streamKeyValue,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue