[{"id":18139,"web_url":"https://patchwork.libcamera.org/comment/18139/","msgid":"<54a52077-c092-6370-bc80-5853a9ce5e66@ideasonboard.com>","date":"2021-07-12T16:07:06","subject":"Re: [libcamera-devel] [PATCH 27/30] cam: Allow specifying\n\tdirectories in the --file option","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"On 07/07/2021 03:19, Laurent Pinchart wrote:\n> The value of the --file option is the full name of the file to which\n> captured frames are written. To write files to a specific directory with\n> the default naming scheme, the \"frame-#.bin\" name has to appear at the\n> end of the file name. Simplify usage of the option by allowing --file to\n> specify a directory only. If the file name ends with a '/', the default\n> \"frame-#.bin\" file name is automatically appended.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nI wonder if the camera id should be encoded by the # as well as the\nstream name ... but maybe that's not needed if multiple cameras will\nalways write to a separate directory...\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n\n> ---\n>  src/cam/buffer_writer.cpp | 7 ++++++-\n>  src/cam/buffer_writer.h   | 2 +-\n>  src/cam/main.cpp          | 5 ++++-\n>  3 files changed, 11 insertions(+), 3 deletions(-)\n> \n> diff --git a/src/cam/buffer_writer.cpp b/src/cam/buffer_writer.cpp\n> index f2b21aef3362..a7648a92fc92 100644\n> --- a/src/cam/buffer_writer.cpp\n> +++ b/src/cam/buffer_writer.cpp\n> @@ -49,7 +49,12 @@ int BufferWriter::write(FrameBuffer *buffer, const std::string &streamName)\n>  \tsize_t pos;\n>  \tint fd, ret = 0;\n>  \n> -\tfilename = pattern_;\n> +\tif (!pattern_.empty())\n> +\t\tfilename = pattern_;\n> +\n> +\tif (filename.empty() || filename.back() == '/')\n> +\t\tfilename += \"frame-#.bin\";\n> +\n>  \tpos = filename.find_first_of('#');\n>  \tif (pos != std::string::npos) {\n>  \t\tstd::stringstream ss;\n> diff --git a/src/cam/buffer_writer.h b/src/cam/buffer_writer.h\n> index 604ce8702ec7..7626de42d369 100644\n> --- a/src/cam/buffer_writer.h\n> +++ b/src/cam/buffer_writer.h\n> @@ -15,7 +15,7 @@\n>  class BufferWriter\n>  {\n>  public:\n> -\tBufferWriter(const std::string &pattern = \"frame-#.bin\");\n> +\tBufferWriter(const std::string &pattern = \"\");\n>  \t~BufferWriter();\n>  \n>  \tvoid mapBuffer(libcamera::FrameBuffer *buffer);\n> diff --git a/src/cam/main.cpp b/src/cam/main.cpp\n> index a3f19d0fa61b..6d7d45e11499 100644\n> --- a/src/cam/main.cpp\n> +++ b/src/cam/main.cpp\n> @@ -118,7 +118,10 @@ int CamApp::parseOptions(int argc, char *argv[])\n>  \t\t\t \"capture\", ArgumentOptional, \"count\");\n>  \tparser.addOption(OptFile, OptionString,\n>  \t\t\t \"Write captured frames to disk\\n\"\n> -\t\t\t \"The first '#' character in the file name is expanded to the stream name and frame sequence number.\\n\"\n> +\t\t\t \"If the file name ends with a '/', it sets the directory in which\\n\"\n> +\t\t\t \"to write files, using the default file name. Otherwise it sets the\\n\"\n> +\t\t\t \"full file path and name. The first '#' character in the file name\\n\"\n> +\t\t\t \"is expanded to the stream name and frame sequence number.\\n\"\n>  \t\t\t \"The default file name is 'frame-#.bin'.\",\n>  \t\t\t \"file\", ArgumentOptional, \"filename\");\n>  \tparser.addOption(OptStream, &streamKeyValue,\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 65EF7C3225\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 12 Jul 2021 16:07:10 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AFD4D68524;\n\tMon, 12 Jul 2021 18:07:09 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D7BC068513\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 12 Jul 2021 18:07:08 +0200 (CEST)","from [192.168.0.20]\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 66F95CC;\n\tMon, 12 Jul 2021 18:07:08 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"PAD2B2hx\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1626106028;\n\tbh=QvfZkCcA/ZHDSEjhV1qqcysiAnLOTB0XLP6azVmZ6AM=;\n\th=Subject:To:References:From:Date:In-Reply-To:From;\n\tb=PAD2B2hxhIZk3tlP3bviUL9d+U2Dn0/qn2vWAL7Kx3Nf1rpic/Ievm92LlGU6jTvj\n\tgWOqT7fVD97B4myUyOqNQBh6+XzLxYCh0GQrNMDiUmGgyIaAHhjFBffZRTxbeDPeW9\n\tvghiE0HL5R7RmDKQ+kvTmANbmKg9UrzrWlqH1T/0=","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210707021941.20804-1-laurent.pinchart@ideasonboard.com>\n\t<20210707021941.20804-28-laurent.pinchart@ideasonboard.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<54a52077-c092-6370-bc80-5853a9ce5e66@ideasonboard.com>","Date":"Mon, 12 Jul 2021 17:07:06 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.11.0","MIME-Version":"1.0","In-Reply-To":"<20210707021941.20804-28-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH 27/30] cam: Allow specifying\n\tdirectories in the --file option","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]