From patchwork Thu Feb 2 18:06:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gyan Doshi X-Patchwork-Id: 40222 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:5494:b0:bf:7b3a:fd32 with SMTP id i20csp562176pzk; Thu, 2 Feb 2023 10:07:27 -0800 (PST) X-Google-Smtp-Source: AK7set8PZnMklm7Ocy7HmIcYuV3jpocm5kcQgjh076Nk+059OK3DXPENIVuaBXzO7T+/91f8Z61I X-Received: by 2002:a17:907:d687:b0:88d:d304:3432 with SMTP id wf7-20020a170907d68700b0088dd3043432mr8162931ejc.60.1675361246818; Thu, 02 Feb 2023 10:07:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675361246; cv=none; d=google.com; s=arc-20160816; b=kZz8z3LdfbZPKdV8BeoULI9qT0jAhkb6sSXkqB2SfUy1lQD0x+uUiFKgQ/0Up4Nvnz rMTryCKpIAjHKUOGNzgPUd5acpoANBHGvoMj3GlknJoCXCmAeg8aRh6kAKWjUoLvk9pz gTsUDbvlP53+zRyYasQXpBJAruV3UXU2K/LCwtF8efG0dsgqwVntkvdcfo8d6ET5+5Rg iAWS2+vHSqbvJ8eI4Xt8eNQhL/o3ZxOB8zphv5FoFVtXFZAvfshtHchKRbuI3OVCWFxh VPBq6gQvEJrsqFXj4F9FSeWof5a+2hgWh+bTIRccDmiUogMMRItOn1A2Gsx/5bx+vqR/ DW/Q== 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:message-id:date:to:from :delivered-to; bh=SizihFaO/mqgTh3VEbeHNByMjvNH9gGnTxenI+O/Jzw=; b=GVK7uhQ69wV92rnnOBtjshcONqQdPXP3+vivbaYCF9po/ZbB3CYJ9mnhdhfTaiZ9v6 B86kNc3IodPPkG8ys+pIHPhKPYP+Bb86mr74GkvPzUS4Zps2RFZZ4v0I1reqcc6o00ml b7YiUw7N35N1vmG2e53juBRNq7DYz45FsbkHQVDOnfHhgNFysbcOmRbGkdeowaDGPgJo 0gXUsXBN3gTqhOTmTvQQsOkdivFCUh37ydpqYkDqtt1z7NmtXD2Wdf/rXNh38ynXwnzr ZS+fdD9QzyfIe4gfypPzkWYmxQoxfWA6aXVBKfTfDg0xrdfZTf+Tp3bcXPnExPcVrPI+ xWdw== 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 fu17-20020a170907b01100b0084d34face39si160046ejc.759.2023.02.02.10.07.26; Thu, 02 Feb 2023 10:07:26 -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 ECBD668BDA1; Thu, 2 Feb 2023 20:07:22 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mout-p-103.mailbox.org (mout-p-103.mailbox.org [80.241.56.161]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BFEA268BB9A for ; Thu, 2 Feb 2023 20:07:14 +0200 (EET) Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-103.mailbox.org (Postfix) with ESMTPS id 4P76FD2D5Jz9sTs for ; Thu, 2 Feb 2023 19:07:12 +0100 (CET) From: Gyan Doshi To: ffmpeg-devel@ffmpeg.org Date: Thu, 2 Feb 2023 23:36:42 +0530 Message-Id: <20230202180642.3479-1-ffmpeg@gyani.pro> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat/tee: signal EOF if no more output is to be published. 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: eEzuBdr/x7Cz Prior to 2d924b3a630, ffmpeg.c would exit if any packet write failed. tee's write_packet seemingly relied on that to enforce its abort failure policy. From 2d924b3a630, ffmpeg only closes that OutputStream and keeps on sending packets of other streams. This breaks the abort behaviour with the tee muxer when there are multiple streams, leaving the ffmpeg process running beyond the intended point of abortion. Fixed by signaling EOF in tee's write_packet if an abort is required. --- libavformat/tee.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/tee.c b/libavformat/tee.c index dd408dd096..8362cdc972 100644 --- a/libavformat/tee.c +++ b/libavformat/tee.c @@ -54,6 +54,7 @@ typedef struct TeeContext { const AVClass *class; unsigned nb_slaves; unsigned nb_alive; + int abort; TeeSlave *slaves; int use_fifo; AVDictionary *fifo_options; @@ -438,6 +439,7 @@ static int tee_process_slave_failure(AVFormatContext *avf, unsigned slave_idx, i return err_n; } else if (tee_slave->on_fail == ON_SLAVE_FAILURE_ABORT) { av_log(avf, AV_LOG_ERROR, "Slave muxer #%u failed, aborting.\n", slave_idx); + tee->abort = 1; return err_n; } else { av_log(avf, AV_LOG_ERROR, "Slave muxer #%u failed: %s, continuing with %u/%u slaves.\n", @@ -599,7 +601,7 @@ static int tee_write_packet(AVFormatContext *avf, AVPacket *pkt) ret_all = ret; } } - return ret_all; + return (tee->abort || !tee->nb_alive) ? AVERROR_EOF : ret_all; } const AVOutputFormat ff_tee_muxer = {