From patchwork Tue Nov 30 00:49:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 31825 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp6968695iob; Mon, 29 Nov 2021 16:50:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJw6NoX4TCcmCznpcHxAIdqgztNr5jxqCVa8SuASIr/P5mRZJ8B1sSg5rwu+vlIEASEQUbUF X-Received: by 2002:a50:e003:: with SMTP id e3mr78782474edl.374.1638233431744; Mon, 29 Nov 2021 16:50:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1638233431; cv=none; d=google.com; s=arc-20160816; b=yhxYwxmbEZ35qn2f1HI6fXoPVifqChRGQ5i3XA3WlViSZeKAd96vbtcC+bkLjHbhBq IaTBXYyaVqlV2EpHOgyXf6JYTDhRmnrTApxHCJetjdUNt2L40uGOdxQdbEaEPbfYqo5r d2OrH3DIG/UOu1gv0tw0fE+L33n8/pL5wCrf/sRIGKRkjeJh5L7l4B0vMTl5Ul8SmkXt XhXbpsGakfUg67EiWaDg4qiAeaZxeBheSer8lhGpYhGwfmhbEE/J/pZqWamBzRqS2QAC 4oOeaotyHjDkvm/a717yiWxaiClGcuw1P1zCetS0mesteFhLofm4Ja+tovVnUI/vf+Pm 2nHQ== 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=blDO9CUgaZr0B+IwbC9sRu6ULLXXLNVp9mnxmeCC+MI=; b=befjeFZeu7CDyvSr0jH3LZwGnyZU+bMGk1DtjMkHpZvfVQcILcpFiNr7+TC3UgnQx/ 85Uyj9ySzirmc+Pw8f5DFtzQQRxAvan9VDkNK9NUA1EauFAQqq2SR9JW2g4tdcAFJxX1 qVVrUlDH+k1gFNe6sAkysQzZObjzh0Ck/2VP9xl++QGOalat30Sasi99QxhKGIuUIGRf WCklaALJQSuTLQs7XJzRYiflt6uxk4KBrnvH5/X/J0xYa0fF19unWuawPP6/k5aC720f e33MF7dF7w7sN3dPDuPCGDhqDnQa8GM2fyDIdyrouZNcHQ3ub/phd8xPqEVD3z1Yp2/0 DWIA== 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 g9si32755530edz.166.2021.11.29.16.50.31; Mon, 29 Nov 2021 16:50:31 -0800 (PST) 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 2146668AE72; Tue, 30 Nov 2021 02:50:09 +0200 (EET) 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 48E5B680C85 for ; Tue, 30 Nov 2021 02:50:00 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id B7518E6372; Tue, 30 Nov 2021 01:49:59 +0100 (CET) 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 Ln6r7UpOnCWC; Tue, 30 Nov 2021 01:49:58 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 455A6E643E; Tue, 30 Nov 2021 01:49:58 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Tue, 30 Nov 2021 01:49:48 +0100 Message-Id: <20211130004950.30697-3-cus@passwd.hu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211130004950.30697-1-cus@passwd.hu> References: <20211130004950.30697-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/5] fftools/ffmpeg: close output files before cleanup 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: xj88Fq5Qea+t This allows us to check the return value of avio_closep(). Signed-off-by: Marton Balint --- fftools/ffmpeg.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 25360423b5..ea75fad637 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -4716,7 +4716,7 @@ static int transcode(void) term_exit(); - /* write the trailer if needed and close file */ + /* write the trailer if needed */ for (i = 0; i < nb_output_files; i++) { os = output_files[i]->ctx; if (!output_files[i]->header_written) { @@ -4736,6 +4736,18 @@ static int transcode(void) /* dump report by using the first video and audio streams */ print_report(1, timer_start, av_gettime_relative()); + /* close the output files */ + for (i = 0; i < nb_output_files; i++) { + os = output_files[i]->ctx; + if (os && os->oformat && !(os->oformat->flags & AVFMT_NOFILE)) { + if ((ret = avio_closep(&os->pb)) < 0) { + av_log(NULL, AV_LOG_ERROR, "Error closing file %s: %s\n", os->url, av_err2str(ret)); + if (exit_on_error) + exit_program(1); + } + } + } + /* close each encoder */ for (i = 0; i < nb_output_streams; i++) { ost = output_streams[i];