From patchwork Sun Jun 12 22:44:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 36186 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1a22:b0:84:42e0:ad30 with SMTP id cj34csp195007pzb; Sun, 12 Jun 2022 15:45:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwXtlckfP3UguBCUGJhgJIFHqM1V4SlGMoaK+ZeKsPAEEbc77Z84GgzntsKwl/P0qH1yx2y X-Received: by 2002:aa7:cd46:0:b0:42d:d73d:be8b with SMTP id v6-20020aa7cd46000000b0042dd73dbe8bmr63084640edw.85.1655073916829; Sun, 12 Jun 2022 15:45:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655073916; cv=none; d=google.com; s=arc-20160816; b=Ln2oMc9DX7crIeDrn4sgghQ+EYW0uEBkP/HWnx+pm30/t4LqM8eVpV+RwRoWLua6V6 rxPsIwB4IUBjfI2fpTyux5cwVQrXi18pMASLrLXM9aWgxe+UQjsYEW+9TVJoDLH4t/Rt KsZRkazjYDAehslo93nhNvDdFQ/p1rs2G9W0IMC7K1V1rmQN4DfG+YhFtJIBprHbGH8w uESJIoDHnFcPdw1ziznU59XfjfVVHSg4u6VppzQeIUg6i7RwaW+afhPIOUwZAtpXX7UM sp8q4MYV9P9JGBzWaaMEcd9ZddUh7TEBKZuMxdh44+a+WrKy4Dq/VWIRgaMurk2TZyn7 Z1Gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=fBpo++TdWY2uaXACcRw7Wsr4NUtdvKXB/IoA1mb8Vdk=; b=eeiSlIpkCLfV7Ix03eQKYq7GWOdx3FGbuzRdLtlXMHDNwhjk3/fa+gK3f+ACTI6Vb9 uTsQammmqJNvHq4sPd36YLUC5lMVLvILg3JJq/hJZHxeUCCjlhDotq9HdPJtGiEkPMgl VdCbfdGsQvXRaA4Q9vueyIw5K43s4irumR4Mde1h9c5hST11KGGBGr0OyOTdVvCRm400 GubXfoyOan86w5zjuRCwn+qyqVxMvhR2raD96JiTWedJBeJrwoXzyRV5Ny8ppHOF7ywn PvhRoT3URarr9D+IFSMOxvs3W9Ktp0stuDemalrD0CMBxyAeoE7jVDim4Jq+FSUNf86s ABxQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id hs25-20020a1709073e9900b007038cb015c2si7326452ejc.990.2022.06.12.15.45.15; Sun, 12 Jun 2022 15:45:16 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 88A5168B549; Mon, 13 Jun 2022 01:45:11 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3F1F76801A2 for ; Mon, 13 Jun 2022 01:45:04 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 14206E73D1; Mon, 13 Jun 2022 00:44:59 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PPehyG1Oqq78; Mon, 13 Jun 2022 00:44:57 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 65525E73CF; Mon, 13 Jun 2022 00:44:57 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Mon, 13 Jun 2022 00:44:49 +0200 Message-Id: <20220612224449.23333-2-cus@passwd.hu> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220612224449.23333-1-cus@passwd.hu> References: <20220612224449.23333-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] avformat/img2enc: use unmatched filename for an invalid or missing sequence pattern X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: tNjZFD8zlvrK Also warn the user that for single images -update should be used, for sequences a proper pattern should be specified. Fixes ticket #9748. Signed-off-by: Marton Balint --- libavformat/img2enc.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c index 82a04e639b..50e469dd96 100644 --- a/libavformat/img2enc.c +++ b/libavformat/img2enc.c @@ -163,13 +163,17 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) } } else if (av_get_frame_filename2(filename, sizeof(filename), s->url, img->img_number, - AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0 && - img->img_number > img->start_img_number) { - av_log(s, AV_LOG_ERROR, - "Could not get frame filename number %d from pattern '%s'. " - "Use '-frames:v 1' for a single image, or '-update' option, or use a pattern such as %%03d within the filename.\n", - img->img_number, s->url); - return AVERROR(EINVAL); + AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0) { + if (img->img_number == img->start_img_number) { + av_log(s, AV_LOG_WARNING, "The specified filename '%s' does not contain an image sequence pattern or a pattern is invalid.\n", s->url); + av_log(s, AV_LOG_WARNING, + "Use a pattern such as %%03d for an image sequence or " + "use the -update option (with -frames:v 1 if needed) to write a single image.\n"); + av_strlcpy(filename, s->url, sizeof(filename)); + } else { + av_log(s, AV_LOG_ERROR, "Cannot write more than one file with the same name. Are you missing the -update option or a sequence pattern?\n"); + return AVERROR(EINVAL); + } } for (i = 0; i < 4; i++) { av_dict_copy(&options, img->protocol_opts, 0);