From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 3843045650 for ; Thu, 9 Feb 2023 16:16:40 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7948A68BE7D; Thu, 9 Feb 2023 18:16:38 +0200 (EET) Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7726568BD53 for ; Thu, 9 Feb 2023 18:16:32 +0200 (EET) Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (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-202.mailbox.org (Postfix) with ESMTPS id 4PCMSF74cyz9sW7 for ; Thu, 9 Feb 2023 17:16:29 +0100 (CET) Message-ID: <5a2a2d45-0716-28dc-1703-ed055034d092@gyani.pro> Date: Thu, 9 Feb 2023 21:46:16 +0530 MIME-Version: 1.0 Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: <20230209155722.28285-1-anton@khirnov.net> From: Gyan Doshi In-Reply-To: <20230209155722.28285-1-anton@khirnov.net> X-Rspamd-Queue-Id: 4PCMSF74cyz9sW7 Subject: Re: [FFmpeg-devel] [PATCH] fftools/ffmpeg_mux: distinguish between sync queue and muxer EOF 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 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 2023-02-09 09:27 pm, Anton Khirnov wrote: > --- > How about something like this? Yes, this works. Regards, Gyan > --- > fftools/ffmpeg_mux.c | 14 +++++++++----- > 1 file changed, 9 insertions(+), 5 deletions(-) > > diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c > index dffc1410c8..cf58051949 100644 > --- a/fftools/ffmpeg_mux.c > +++ b/fftools/ffmpeg_mux.c > @@ -159,14 +159,18 @@ fail: > return ret; > } > > -static int sync_queue_process(Muxer *mux, OutputStream *ost, AVPacket *pkt) > +static int sync_queue_process(Muxer *mux, OutputStream *ost, AVPacket *pkt, int *stream_eof) > { > OutputFile *of = &mux->of; > > if (ost->sq_idx_mux >= 0) { > int ret = sq_send(mux->sq_mux, ost->sq_idx_mux, SQPKT(pkt)); > - if (ret < 0) > + if (ret < 0) { > + if (ret == AVERROR_EOF) > + *stream_eof = 1; > + > return ret; > + } > > while (1) { > ret = sq_receive(mux->sq_mux, -1, SQPKT(mux->sq_pkt)); > @@ -208,7 +212,7 @@ static void *muxer_thread(void *arg) > > while (1) { > OutputStream *ost; > - int stream_idx; > + int stream_idx, stream_eof = 0; > > ret = tq_receive(mux->tq, &stream_idx, pkt); > if (stream_idx < 0) { > @@ -218,9 +222,9 @@ static void *muxer_thread(void *arg) > } > > ost = of->streams[stream_idx]; > - ret = sync_queue_process(mux, ost, ret < 0 ? NULL : pkt); > + ret = sync_queue_process(mux, ost, ret < 0 ? NULL : pkt, &stream_eof); > av_packet_unref(pkt); > - if (ret == AVERROR_EOF) > + if (ret == AVERROR_EOF && stream_eof) > tq_receive_finish(mux->tq, stream_idx); > else if (ret < 0) { > av_log(mux, AV_LOG_ERROR, "Error muxing a packet\n"); _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".