From patchwork Tue Jan 11 09:58:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 33204 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp3544695iog; Tue, 11 Jan 2022 01:59:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJy37RA+NP4dZXe6wcJFRyY1x8XKbqqaJ7bkBbyRTF+3wQxnxPD5hIg299dkcfB/IaSIw2JF X-Received: by 2002:a17:907:2cc2:: with SMTP id hg2mr3077537ejc.66.1641895154992; Tue, 11 Jan 2022 01:59:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1641895154; cv=none; d=google.com; s=arc-20160816; b=w0Oxst7qa/DjR7BfBO783gKlEo0IVjEAjxLPx/XclT4eLZCe8LMYOoCDMF/iqmVfyF kMLMrpxB/06KMYKKACGfduT9P9InuuLxHrs9VDHKt0ljuGk2Tfia9cG5jmeNJnxfrncv L7OzfPu85cPI+AM278422OYfPxlm9kcWz9sM53cMSlth5h7DMqwqxkr7luQJhVGxBH9B VPkI1JD+i9Btu8bmwcjXCyvk5xnzVPJxkOsubN+Igjab0DtBJp8HBhRMXFe3JRp0Rsoh 3LXRbp/mj0XnucSVs87J32VqwRuKBdcnSGbL5J6PBVNGjC1/SZ8pUQOppB6vcRZm+hw5 yPSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=cwzHNeIIQtrlhSSwIQC0xznQha2bp88ValaXxfVE5H0=; b=so649M3VN48W59szAWSFMKPY8dZ32yNM3xlV7EqSnRoJqPyAqK+8Qv4sU7AQQ9fuCr UvA7RIZKXhPLW51VDvXDzxPTMlvguDEK1c0OerUu8sG8muzcPqd1nw27uNQmUrz7C4MP AQZ4JI7DfIGy8Q0FrpKF0sjf9CHAomCpbwTkdca6QivBX/72+Cp3fJEDSFWTgOyCRU1Z GM31KZxWJVs7P6ucyAn7VJXSZ6kBWasdG4pml3eN4vfjEJDcIonVwNDi3Mozf67MW/J8 G5LyZCHZWb7KnZLG5adhIMNXmqpOxiFQ9OqVHgst5QwMhtdgQHpSZxm5wWYiewZ144Dp QbLQ== 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 c26si5161878edy.386.2022.01.11.01.59.14; Tue, 11 Jan 2022 01:59:14 -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 A92C7680BA3; Tue, 11 Jan 2022 11:59:10 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 23AFF680BA3 for ; Tue, 11 Jan 2022 11:59:04 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 4C7BA240694 for ; Tue, 11 Jan 2022 10:59:03 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id JWcjXAE2DFeN for ; Tue, 11 Jan 2022 10:59:02 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 3EE3F24017E for ; Tue, 11 Jan 2022 10:59:02 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id D9BC23A0743; Tue, 11 Jan 2022 10:59:01 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Tue, 11 Jan 2022 10:58:06 +0100 Message-Id: <20220111095830.31542-4-anton@khirnov.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220111095830.31542-1-anton@khirnov.net> References: <20220111095830.31542-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 04/28] ffmpeg: move writing the trailer to ffmpeg_mux.c 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Sn1sMHtiirF9 --- fftools/ffmpeg.c | 16 +++------------- fftools/ffmpeg.h | 1 + fftools/ffmpeg_mux.c | 21 +++++++++++++++++++++ 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index e0aa533dc9..87e8b0be59 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -4440,19 +4440,9 @@ static int transcode(void) /* write the trailer if needed */ for (i = 0; i < nb_output_files; i++) { - os = output_files[i]->ctx; - if (!output_files[i]->header_written) { - av_log(NULL, AV_LOG_ERROR, - "Nothing was written into output file %d (%s), because " - "at least one of its streams received no packets.\n", - i, os->url); - continue; - } - if ((ret = av_write_trailer(os)) < 0) { - av_log(NULL, AV_LOG_ERROR, "Error writing trailer of %s: %s\n", os->url, av_err2str(ret)); - if (exit_on_error) - exit_program(1); - } + ret = of_write_trailer(output_files[i]); + if (ret < 0 && exit_on_error) + exit_program(1); } /* dump report by using the first video and audio streams */ diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index fed34b06f8..91c313d8ef 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -686,6 +686,7 @@ int hwaccel_decode_init(AVCodecContext *avctx); /* open the muxer when all the streams are initialized */ int of_check_init(OutputFile *of); +int of_write_trailer(OutputFile *of); void of_write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int unqueue); diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 3c2980ba90..c65ed3631a 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -291,3 +291,24 @@ int of_check_init(OutputFile *of) return 0; } + +int of_write_trailer(OutputFile *of) +{ + int ret; + + if (!of->header_written) { + av_log(NULL, AV_LOG_ERROR, + "Nothing was written into output file %d (%s), because " + "at least one of its streams received no packets.\n", + of->index, of->ctx->url); + return AVERROR(EINVAL); + } + + ret = av_write_trailer(of->ctx); + if (ret < 0) { + av_log(NULL, AV_LOG_ERROR, "Error writing trailer of %s: %s\n", of->ctx->url, av_err2str(ret)); + return ret; + } + + return 0; +}