From patchwork Sun Apr 9 14:08:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41043 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1590627pzb; Sun, 9 Apr 2023 07:09:21 -0700 (PDT) X-Google-Smtp-Source: AKy350bcXwvN3JgMI51YAC93t89qJsgu9QgfwDZ48GBRjWpjicsKzncXSYBgtq1G4XIddQ0f9ILc X-Received: by 2002:a17:906:6959:b0:94a:8b47:8c66 with SMTP id c25-20020a170906695900b0094a8b478c66mr273675ejs.30.1681049361285; Sun, 09 Apr 2023 07:09:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681049361; cv=none; d=google.com; s=arc-20160816; b=wcpoxsSRGZck17oNiFTAZSQJc4RwvcY9xJK7wbcQcuICTUA6IWd0w1R69InDSZrusC TIsv5MH4M4smavz+ym/CZNh5dHj89sJIO/NwkcQYTeH50skiaghcP3KCqtWCCk3Daln+ jCH4SuaP3T3Cat80V41wYuk2vfPfEeym7BNhpkFcZBiVmgRR9ypIcv0F6tJ3eDMSoiAz Ig1qrP3omC9WBqU2x3g+hQZPThypl0zMFvUt8d5w5aCIseY8zBc4/NQuwFbVD0lk3l3B +zF0z5/IDHnOyY7AE3jLnbwpLPrmjqW7hPy51U72hLhlszx77DM6E/idiLAukUTZxO9L xpzg== 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=/oT403Ssit74c8iV2EfTcbd+pza1GacYnL3eHUw4YfY=; b=UoQo3/ecEnn1DyUjpow/WvEz6yzqYx8XtmXxRCJc9b5MzQQHN+GujoUKrdWWw5Q3Re 7osC0wXdhvhiBlqV0qQEansvYCaU/r0/44pT+SIs+KE6uraqMmuuY34L+lo8xyZINR1D fqt4itf0WO3SZ3De+FK3aXPRU6HI95sLhh/WULNfDVhXAAX+1NhgupccihXYvQb9k4y/ QUZuKUV7rrTlla8byQHeeAkdGCl1V2GSssQ/j04IbrRri/XaHlLm6tEkxmp6FJcfsqEO sfTXWuOpCQcQfVgGH3OUR96zyAUrtXF8/uFbC+qxsebxW39F5/gDBmMM4JBuOaOE9QF/ OK5A== 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 l17-20020a170906645100b00932e989991bsi6820620ejn.643.2023.04.09.07.09.20; Sun, 09 Apr 2023 07:09:21 -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 DC71F68BB59; Sun, 9 Apr 2023 17:09:17 +0300 (EEST) 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 EC150689CE2 for ; Sun, 9 Apr 2023 17:09:10 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id B575A240D1B for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 7XDobzYtMak0 for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) 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 16FB12404EE for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id BA57D3A038E for ; Sun, 9 Apr 2023 16:09:09 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Apr 2023 16:08:25 +0200 Message-Id: <20230409140853.28858-1-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 01/29] fftools/ffmpeg: move OutputStream.vsync_frame_number to Encoder 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: RjJD7zjCMiPO It is video encoding-only and does not need to be visible outside of ffmpeg_enc.c --- fftools/ffmpeg.h | 2 -- fftools/ffmpeg_enc.c | 11 +++++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 8193dabb57..886124d874 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -571,8 +571,6 @@ typedef struct OutputStream { InputStream *ist; AVStream *st; /* stream in the output file */ - /* number of frames emitted by the video-encoding sync code */ - int64_t vsync_frame_number; /* predicted pts of the next frame to be encoded * audio/video encoding only */ int64_t next_pts; diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index 2f1803a74c..5266026945 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -45,6 +45,8 @@ struct Encoder { AVFrame *last_frame; + /* number of frames emitted by the video-encoding sync code */ + int64_t vsync_frame_number; }; static uint64_t dup_warning = 1000; @@ -832,6 +834,7 @@ static void video_sync_process(OutputFile *of, OutputStream *ost, AVFrame *next_picture, double duration, int64_t *nb_frames, int64_t *nb_frames_prev) { + Encoder *e = ost->enc; double delta0, delta; double sync_ipts = adjust_frame_pts_to_encoder_tb(of, ost, next_picture); @@ -861,7 +864,7 @@ static void video_sync_process(OutputFile *of, OutputStream *ost, switch (ost->vsync_method) { case VSYNC_VSCFR: - if (ost->vsync_frame_number == 0 && delta0 >= 0.5) { + if (e->vsync_frame_number == 0 && delta0 >= 0.5) { av_log(ost, AV_LOG_DEBUG, "Not duplicating %d initial frames\n", (int)lrintf(delta0)); delta = duration; delta0 = 0; @@ -869,7 +872,7 @@ static void video_sync_process(OutputFile *of, OutputStream *ost, } case VSYNC_CFR: // FIXME set to 0.5 after we fix some dts/pts bugs like in avidec.c - if (frame_drop_threshold && delta < frame_drop_threshold && ost->vsync_frame_number) { + if (frame_drop_threshold && delta < frame_drop_threshold && e->vsync_frame_number) { *nb_frames = 0; } else if (delta < -1.1) *nb_frames = 0; @@ -998,7 +1001,7 @@ static void do_video_out(OutputFile *of, nb_frames_drop++; av_log(ost, AV_LOG_VERBOSE, "*** dropping frame %"PRId64" at ts %"PRId64"\n", - ost->vsync_frame_number, e->last_frame->pts); + e->vsync_frame_number, e->last_frame->pts); } if (nb_frames > (nb_frames_prev && ost->last_dropped) + (nb_frames > nb_frames_prev)) { if (nb_frames > dts_error_threshold * 30) { @@ -1043,7 +1046,7 @@ static void do_video_out(OutputFile *of, exit_program(1); ost->next_pts++; - ost->vsync_frame_number++; + e->vsync_frame_number++; } av_frame_unref(e->last_frame); From patchwork Sun Apr 9 14:08:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41045 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1590771pzb; Sun, 9 Apr 2023 07:09:38 -0700 (PDT) X-Google-Smtp-Source: AKy350aw7D4OshYoiZbiPIMVVuYIFNZdlTzMV6V9jNtG6jqMaw2z7Led9iGjk8N1F/WdSR4I0hBk X-Received: by 2002:a17:906:5fcb:b0:878:7189:a457 with SMTP id k11-20020a1709065fcb00b008787189a457mr5450292ejv.51.1681049377862; Sun, 09 Apr 2023 07:09:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681049377; cv=none; d=google.com; s=arc-20160816; b=NsNe2NxE/TayA4tTdZB/YQpqRcChFXSmHzV5BJEB0pAVRo04P8M/RUSJSTiXmtev9I Xq6tkOZyw4qz13IEDE4V551id0LTnQFGA0velxzNeNBYZ2MygEOwDj3+ArK6S+iVaSzG 3Abt7yaIBUdqhB1wmLU2kuv2OXdI9vMihT1a4ofBaabbqaNZY2wBogl6Bm0vhQIVt8x0 e7cfyJhKKyPu7/kXo67dYn5ak0JDJqOBwocRpXSUdHD10QKvu0pu95K1GWmco2/E89iq yWtOXr+ly6Y3NpkQCk0sxEcnDpNXkmU4Hnl/u9bkdUazryG1+OS/DOj1CimlYCtV/JTF aWSA== 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=4s32RF/rOFr2vpwBzYpOUxxrQPkpBAR9kTzyh6CCPVQ=; b=a+xnGcOxCdOSu762pGPHyWBVKQqEjVrPUJoAFKjUOZ/an4C0ro+fN5PDt3Yc4ajCPS eadRzu1DPO99PSrwt1NzxWJ2erDBkb/wFyjUcU1N2JZab9XN7BzI5BGxKjob/Z7gI4qr tXzzj1gWqq7Q0qsOf2Tdn4P1WmbM7s4Rdii/W4bgkBJQRtkvsw1zQp7WrUOBmx3CECRg uzJi4wRaAv5NcRNHW6zfaqGaZeZUdQv5rIFleVQ9y2x9FLhNoOpY5xgFOipiYg9C/fGi 3a3QBf3f+syqEvD9jsADJ1mxb2QFerAu9hiw1eEOZUD3KjzQOwjSNg77MudWVWfFJdx+ OUOQ== 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 i11-20020a17090671cb00b0093d4fb59d99si3881532ejk.422.2023.04.09.07.09.37; Sun, 09 Apr 2023 07:09:37 -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 C5A8668BCC3; Sun, 9 Apr 2023 17:09:19 +0300 (EEST) 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 C344D689CE2 for ; Sun, 9 Apr 2023 17:09:11 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 90AC12404F8 for ; Sun, 9 Apr 2023 16:09:11 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 2lihZ9vqVhRn for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) 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 0E0B82404EC for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id C65303A039B for ; Sun, 9 Apr 2023 16:09:09 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Apr 2023 16:08:26 +0200 Message-Id: <20230409140853.28858-2-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230409140853.28858-1-anton@khirnov.net> References: <20230409140853.28858-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 02/29] fftools/ffmpeg: move OutputStream.next_pts to Encoder 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: CHYliyAMlSwy It is audio/video encoding-only and does not need to be visible outside of ffmpeg_enc.c --- fftools/ffmpeg.h | 3 --- fftools/ffmpeg_enc.c | 22 +++++++++++++--------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 886124d874..e7e7d88577 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -571,9 +571,6 @@ typedef struct OutputStream { InputStream *ist; AVStream *st; /* stream in the output file */ - /* predicted pts of the next frame to be encoded - * audio/video encoding only */ - int64_t next_pts; /* dts of the last packet sent to the muxing queue, in AV_TIME_BASE_Q */ int64_t last_mux_dts; /* pts of the last frame received from the filters, in AV_TIME_BASE_Q */ diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index 5266026945..bb11cdf42a 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -44,6 +44,9 @@ #include "libavformat/avformat.h" struct Encoder { + /* predicted pts of the next frame to be encoded */ + int64_t next_pts; + AVFrame *last_frame; /* number of frames emitted by the video-encoding sync code */ int64_t vsync_frame_number; @@ -761,11 +764,12 @@ static int submit_encode_frame(OutputFile *of, OutputStream *ost, static void do_audio_out(OutputFile *of, OutputStream *ost, AVFrame *frame) { + Encoder *e = ost->enc; AVCodecContext *enc = ost->enc_ctx; int ret; if (frame->pts == AV_NOPTS_VALUE) - frame->pts = ost->next_pts; + frame->pts = e->next_pts; else { int64_t start_time = (of->start_time == AV_NOPTS_VALUE) ? 0 : of->start_time; frame->pts = @@ -777,7 +781,7 @@ static void do_audio_out(OutputFile *of, OutputStream *ost, if (!check_recording_time(ost, frame->pts, frame->time_base)) return; - ost->next_pts = frame->pts + frame->nb_samples; + e->next_pts = frame->pts + frame->nb_samples; ret = submit_encode_frame(of, ost, frame); if (ret < 0 && ret != AVERROR_EOF) @@ -840,7 +844,7 @@ static void video_sync_process(OutputFile *of, OutputStream *ost, double sync_ipts = adjust_frame_pts_to_encoder_tb(of, ost, next_picture); /* delta0 is the "drift" between the input frame (next_picture) and * where it would fall in the output. */ - delta0 = sync_ipts - ost->next_pts; + delta0 = sync_ipts - e->next_pts; delta = delta0 + duration; // tracks the number of times the PREVIOUS frame should be duplicated, @@ -857,7 +861,7 @@ static void video_sync_process(OutputFile *of, OutputStream *ost, av_log(ost, AV_LOG_VERBOSE, "Past duration %f too large\n", -delta0); } else av_log(ost, AV_LOG_DEBUG, "Clipping frame in rate conversion by %f\n", -delta0); - sync_ipts = ost->next_pts; + sync_ipts = e->next_pts; duration += delta0; delta0 = 0; } @@ -868,7 +872,7 @@ static void video_sync_process(OutputFile *of, OutputStream *ost, av_log(ost, AV_LOG_DEBUG, "Not duplicating %d initial frames\n", (int)lrintf(delta0)); delta = duration; delta0 = 0; - ost->next_pts = llrint(sync_ipts); + e->next_pts = llrint(sync_ipts); } case VSYNC_CFR: // FIXME set to 0.5 after we fix some dts/pts bugs like in avidec.c @@ -887,13 +891,13 @@ static void video_sync_process(OutputFile *of, OutputStream *ost, if (delta <= -0.6) *nb_frames = 0; else if (delta > 0.6) - ost->next_pts = llrint(sync_ipts); + e->next_pts = llrint(sync_ipts); next_picture->duration = duration; break; case VSYNC_DROP: case VSYNC_PASSTHROUGH: next_picture->duration = duration; - ost->next_pts = llrint(sync_ipts); + e->next_pts = llrint(sync_ipts); break; default: av_assert0(0); @@ -1031,7 +1035,7 @@ static void do_video_out(OutputFile *of, if (!in_picture) return; - in_picture->pts = ost->next_pts; + in_picture->pts = e->next_pts; if (!check_recording_time(ost, in_picture->pts, ost->enc_ctx->time_base)) return; @@ -1045,7 +1049,7 @@ static void do_video_out(OutputFile *of, else if (ret < 0) exit_program(1); - ost->next_pts++; + e->next_pts++; e->vsync_frame_number++; } From patchwork Sun Apr 9 14:08:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41047 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1590828pzb; Sun, 9 Apr 2023 07:09:46 -0700 (PDT) X-Google-Smtp-Source: AKy350YMooFEOhvOU3FDwuxmXk9ooVyGWOYpxHhAF38anSi3wQRyO4U6KQrNK0fhSCs7i2hJSW51 X-Received: by 2002:a17:906:f1d7:b0:94a:5c6d:3207 with SMTP id gx23-20020a170906f1d700b0094a5c6d3207mr2768014ejb.44.1681049386659; Sun, 09 Apr 2023 07:09:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681049386; cv=none; d=google.com; s=arc-20160816; b=woQCo1m4uOom1Vm9XcTynDoe/1QYe2SzxApNo8c9xq/imTVabX464GMe3x9ppW5WZU HyDKYX+0IkP9Jx9S8f+dKsPJqDCpHanoLkY9jXQ/8HFoRxYq+G4rMsYMRWidYdk9aq97 jDmTcZiY2hx75XM1f3JPy/xLvJM8RQQ6JPQ0kEnGeaP5w1MEAZq5hdlfTFETZeIS8BN/ DFPW/Ue7BADAjaoFguejeJVHzgIYoykSOlb4EWLTeZ3lj6VRsxKGF3a8HY2jMNes87dA vWhmncMDx6Lw378qul3hYYWmAb1/qxKi//1A9X401dlHJgm1JYFtk/+vrbEDmYIpFA/y YaOw== 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=AoF8SpZNcUjE7KDaeQ1cQZWPbXotC2q8kx6JN89RstA=; b=OeqWTAz3Vzo6ErFhZbcPdoiRRAuFhKXYNNVkxclczDu7GgRQUVTUb32FumlQvV3NXe wdK+2U38kbYu6PxsV26KgIG7JePfJZQfJypulZoj1FkRr711aP8HhYC6W4pW9ql+3sRR UEIhiSQqs6+GMo2CfFFk9+WzfOhyQSTVXuBqqeCpG+oF9DOFfGNbchtD4rua3JfBCjD6 Z3YiRYqgUw7egHeT4PRtH5mNglXRTMxpapbGF8x3IxSXjaKcM0hnaAbjrxr9zDgai4ne gqtzpzkcy4glbvM1767dfQPPFp8yBO86GNZcVME+of3bDiWzDE6ko5oaPyIuX909khe2 jn/w== 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 hr11-20020a1709073f8b00b0094a6e192697si1779279ejc.888.2023.04.09.07.09.46; Sun, 09 Apr 2023 07:09:46 -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 AEAA068BD3D; Sun, 9 Apr 2023 17:09:20 +0300 (EEST) 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 410F868A6B5 for ; Sun, 9 Apr 2023 17:09:12 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 071A82404EC for ; Sun, 9 Apr 2023 16:09:12 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 9xB-qYEu_n7b for ; Sun, 9 Apr 2023 16:09:11 +0200 (CEST) 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 18BE52404F5 for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id D10263A03E5 for ; Sun, 9 Apr 2023 16:09:09 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Apr 2023 16:08:27 +0200 Message-Id: <20230409140853.28858-3-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230409140853.28858-1-anton@khirnov.net> References: <20230409140853.28858-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 03/29] fftools/ffmpeg: move OutputStream.sq_frame to Encoder 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: wEshcpf4a0nJ It is audio/video encoding-only and does not need to be visible outside of ffmpeg_enc.c --- fftools/ffmpeg.h | 1 - fftools/ffmpeg_enc.c | 17 ++++++++++++++--- fftools/ffmpeg_mux.c | 1 - fftools/ffmpeg_mux_init.c | 4 ---- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index e7e7d88577..84418d8da5 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -588,7 +588,6 @@ typedef struct OutputStream { Encoder *enc; AVCodecContext *enc_ctx; AVFrame *filtered_frame; - AVFrame *sq_frame; AVPacket *pkt; int64_t last_dropped; int64_t last_nb0_frames[3]; diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index bb11cdf42a..5c56ad0325 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -50,6 +50,8 @@ struct Encoder { AVFrame *last_frame; /* number of frames emitted by the video-encoding sync code */ int64_t vsync_frame_number; + + AVFrame *sq_frame; }; static uint64_t dup_warning = 1000; @@ -62,6 +64,7 @@ void enc_free(Encoder **penc) return; av_frame_free(&enc->last_frame); + av_frame_free(&enc->sq_frame); av_freep(penc); } @@ -139,6 +142,7 @@ static void init_encoder_time_base(OutputStream *ost, AVRational default_time_ba int enc_open(OutputStream *ost, AVFrame *frame) { InputStream *ist = ost->ist; + Encoder *e = ost->enc; AVCodecContext *enc_ctx = ost->enc_ctx; AVCodecContext *dec_ctx = NULL; const AVCodec *enc = enc_ctx->codec; @@ -328,6 +332,12 @@ int enc_open(OutputStream *ost, AVFrame *frame) return ret; } + if (ost->sq_idx_encode >= 0) { + e->sq_frame = av_frame_alloc(); + if (!e->sq_frame) + return AVERROR(ENOMEM); + } + if (ost->enc_ctx->frame_size) { av_assert0(ost->sq_idx_encode >= 0); sq_frame_samples(output_files[ost->file_index]->sq_encode, @@ -718,16 +728,17 @@ static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame) static int submit_encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame) { + Encoder *e = ost->enc; int ret; if (ost->sq_idx_encode < 0) return encode_frame(of, ost, frame); if (frame) { - ret = av_frame_ref(ost->sq_frame, frame); + ret = av_frame_ref(e->sq_frame, frame); if (ret < 0) return ret; - frame = ost->sq_frame; + frame = e->sq_frame; } ret = sq_send(of->sq_encode, ost->sq_idx_encode, @@ -740,7 +751,7 @@ static int submit_encode_frame(OutputFile *of, OutputStream *ost, } while (1) { - AVFrame *enc_frame = ost->sq_frame; + AVFrame *enc_frame = e->sq_frame; ret = sq_receive(of->sq_encode, ost->sq_idx_encode, SQFRAME(enc_frame)); diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 527567831f..5663b8f11d 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -663,7 +663,6 @@ static void ost_free(OutputStream **post) av_bsf_free(&ms->bsf_ctx); av_frame_free(&ost->filtered_frame); - av_frame_free(&ost->sq_frame); av_packet_free(&ost->pkt); av_dict_free(&ost->encoder_opts); diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 6c53a8810d..ee5829c7fe 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -1505,10 +1505,6 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, int64_t buf_size_u if (ost->sq_idx_encode < 0) return ost->sq_idx_encode; - ost->sq_frame = av_frame_alloc(); - if (!ost->sq_frame) - return AVERROR(ENOMEM); - if (ms->max_frames != INT64_MAX) sq_limit_frames(of->sq_encode, ost->sq_idx_encode, ms->max_frames); } From patchwork Sun Apr 9 14:08:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41044 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1590700pzb; Sun, 9 Apr 2023 07:09:29 -0700 (PDT) X-Google-Smtp-Source: AKy350YZBKjoqIko6Fme0huvYgv3L8xX+ltYBubD5rFnS2Alcevh1JVEtcA8Wuvi2Nb/z4mewaxU X-Received: by 2002:a17:907:8a85:b0:947:40e6:fde4 with SMTP id sf5-20020a1709078a8500b0094740e6fde4mr4031672ejc.2.1681049369413; Sun, 09 Apr 2023 07:09:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681049369; cv=none; d=google.com; s=arc-20160816; b=D5qhBh3QzbF+NmL7plLbfY08Hhtyit3giYGWEzW1sL+t7lDANY31dHb0Pnl5YYsuKd m0zQYMEB1UQu1NnKxd86rlcmGN3IJX6owdipIVznGs5Ewm07gvk2k1ECpUCXPB5d0674 tKpI+qNfFwlCghvnJTk/fD9i0sY6c93tKkBiAgx3CTqw2C2AlS6FZJIcgorHmkqPwJpY DiDfuAWSTcTHypVM3JqHDfntRMnoK6ziruCvz7s9AVUAVbAspKWVMsiX90RamNeBdu2Q BBP/L7j7FPDrz7AT3RLkXzA0pcc4rMoDct1enmAdwgVIWCZ9dI4Mbro85ET76qo/SB6d nEEA== 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=44MQokheFu1QIBJIKqB+Bd4iNeeC233LPK7kZCZHN1s=; b=qcftGna+O1q3Bfki9eKMzf85hH06xyg7nuV7hHuUaLLlnFPyR0JORln/TO6JV/ocjA 4mRMYkegORR8QufJTWE7j5uSSdFEHTnOJShWKKZwPgNfGPk8PYVc3mrWry0sLtCr0MbG go87E+dyej/8zhSJCQceEh1jc4q0q5SvPHYI/Q7nutnWmsUIwcv3wvuRyJ1GmUUdQ8+F 4RLSLqE8/y3bJ9PDZA/EpdLA2RGFSOutD+KsVDvYNsHaUQtoj6xwWBNZIU0mRbyPQ8QL 1Jy0EN4LHzFNRG5gpK7STNPaySATRvqe871082fs1NUBANZXRVWUJ/60VtOaeKBIKZjN Jltw== 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 g15-20020a1709064e4f00b0094a701e39c7si1151076ejw.148.2023.04.09.07.09.29; Sun, 09 Apr 2023 07:09:29 -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 C836E68A59F; Sun, 9 Apr 2023 17:09:18 +0300 (EEST) 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 8B9DC689CE2 for ; Sun, 9 Apr 2023 17:09:11 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 5298F240D25 for ; Sun, 9 Apr 2023 16:09:11 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id rjLzq9xfD_Be for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) 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 233F02404F8 for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id DBF7D3A0404 for ; Sun, 9 Apr 2023 16:09:09 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Apr 2023 16:08:28 +0200 Message-Id: <20230409140853.28858-4-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230409140853.28858-1-anton@khirnov.net> References: <20230409140853.28858-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 04/29] fftools/ffmpeg: move OutputStream.last_nb0_frames to Encoder 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: wQR07HPfD4+A It is video encoding-only and does not need to be visible outside of ffmpeg_enc.c Also, rename the variable to frames_prev_hist to be consistent with the naming in do_video_out(). --- fftools/ffmpeg.h | 1 - fftools/ffmpeg_enc.c | 18 +++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 84418d8da5..b45a2039ce 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -590,7 +590,6 @@ typedef struct OutputStream { AVFrame *filtered_frame; AVPacket *pkt; int64_t last_dropped; - int64_t last_nb0_frames[3]; /* video only */ AVRational frame_rate; diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index 5c56ad0325..7f6bd76f10 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -50,6 +50,10 @@ struct Encoder { AVFrame *last_frame; /* number of frames emitted by the video-encoding sync code */ int64_t vsync_frame_number; + /* history of nb_frames_prev, i.e. the number of times the + * previous frame was duplicated by vsync code in recent + * do_video_out() calls */ + int64_t frames_prev_hist[3]; AVFrame *sq_frame; }; @@ -999,18 +1003,18 @@ static void do_video_out(OutputFile *of, if (!next_picture) { //end, flushing - nb_frames_prev = nb_frames = mid_pred(ost->last_nb0_frames[0], - ost->last_nb0_frames[1], - ost->last_nb0_frames[2]); + nb_frames_prev = nb_frames = mid_pred(e->frames_prev_hist[0], + e->frames_prev_hist[1], + e->frames_prev_hist[2]); } else { video_sync_process(of, ost, next_picture, duration, &nb_frames, &nb_frames_prev); } - memmove(ost->last_nb0_frames + 1, - ost->last_nb0_frames, - sizeof(ost->last_nb0_frames[0]) * (FF_ARRAY_ELEMS(ost->last_nb0_frames) - 1)); - ost->last_nb0_frames[0] = nb_frames_prev; + memmove(e->frames_prev_hist + 1, + e->frames_prev_hist, + sizeof(e->frames_prev_hist[0]) * (FF_ARRAY_ELEMS(e->frames_prev_hist) - 1)); + e->frames_prev_hist[0] = nb_frames_prev; if (nb_frames_prev == 0 && ost->last_dropped) { nb_frames_drop++; From patchwork Sun Apr 9 14:08:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41064 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1592122pzb; Sun, 9 Apr 2023 07:12:14 -0700 (PDT) X-Google-Smtp-Source: AKy350YpfxG5LAHRyJV9NrUVQG4gRK74Ybexr512CYktbc2ZqhP2YuSt3xuB0t5feHzxiLlY0mNi X-Received: by 2002:a17:906:4883:b0:933:80c:67d7 with SMTP id v3-20020a170906488300b00933080c67d7mr4600115ejq.49.1681049533798; Sun, 09 Apr 2023 07:12:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681049533; cv=none; d=google.com; s=arc-20160816; b=dkDeuFIfFTskHdZN7K7fXOsrw1Q5rq2EavwxCxO+nbll7ddptLZqcM3SlQZWVlGKgC fD8mdt+XT+1aJoBwCOSEG7efLL7gMBx0UAcXuNAEBszSdSdh7Dck3fjZCtmDUB1BHVdz K7icJ3zOMQkQZEpDhTtZAEr4FaV3S7+KKOpXwy6p+JA7ZqERS/mBaJeP+FONEP18Tzmz rndKjMxjUlfOhPFc3sh2MhJp8mhzPkbr32QzR5NNKOCA7hmddHfuEOPXT4RcIuD31HqB VjMERQ0FJihUYztsbj+P0J0igUb3gxL6/hh1BeKI2fCE2s337AlqnlCheW4bolvRNMcf M1Rw== 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=hzM5RiPXAP1WsTrO3CnKefiRuY6hn47GR6UZz3v+7Yw=; b=m6cCw2uki7wMlMAX7Wx61uuyFKnDpA+OwZVyUQuMbxlgWlT6R1OzeVdvlxRmSeNmij toDUNECfg//ipv51XDeHTX9KZeXrC7srhX+4jfh5GxTFA/qz2rxib3vkcvJ5eFWLZGQ2 qCh7hOSZgGrhOFk++tBP/XnXBjoDkmeMuXw8mltJ+hevwmTUOaCDjrQ2K7zJwY9HlzFb hAYUIm3sV5yyll13DoqCi1s76go0Mn/yCM55r/NGEuFGZ1kr6PynbmNtxJJ0alY1CvIP NDQtl5R62xY3fK1eu5/WuuAHz3g00oOg+cK/EI7vCsgKp809bKTKIyq747WMSg2BG8gm Mokg== 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 vt6-20020a170907a60600b0094a82b4e9d8si420550ejc.149.2023.04.09.07.12.13; Sun, 09 Apr 2023 07:12:13 -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 330CA68BD50; Sun, 9 Apr 2023 17:09:37 +0300 (EEST) 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 38DCE68BD2C for ; Sun, 9 Apr 2023 17:09:16 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 2C8A02405B5 for ; Sun, 9 Apr 2023 16:09:13 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id ozwA3pyUbN02 for ; Sun, 9 Apr 2023 16:09:12 +0200 (CEST) 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 2EBA82405EC for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id E7CCF3A042D for ; Sun, 9 Apr 2023 16:09:09 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Apr 2023 16:08:29 +0200 Message-Id: <20230409140853.28858-5-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230409140853.28858-1-anton@khirnov.net> References: <20230409140853.28858-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 05/29] fftools/ffmpeg: move OutputStream.last_filter_pts to OutputFilter 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: 3gJiK8iB1kRr This value is associated with the filtergraph output rather than the output stream, so this is a more appropriate place for it. --- fftools/ffmpeg.c | 8 ++++---- fftools/ffmpeg.h | 5 +++-- fftools/ffmpeg_filter.c | 21 +++++++++++++++------ fftools/ffmpeg_mux_init.c | 1 - 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 750ab76693..1f50b82794 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -697,8 +697,8 @@ static int reap_filters(int flush) if (filtered_frame->pts != AV_NOPTS_VALUE) { AVRational tb = av_buffersink_get_time_base(filter); - ost->last_filter_pts = av_rescale_q(filtered_frame->pts, tb, - AV_TIME_BASE_Q); + ost->filter->last_pts = av_rescale_q(filtered_frame->pts, tb, + AV_TIME_BASE_Q); filtered_frame->time_base = tb; if (debug_ts) @@ -2391,8 +2391,8 @@ static OutputStream *choose_output(void) for (OutputStream *ost = ost_iter(NULL); ost; ost = ost_iter(ost)) { int64_t opts; - if (ost->filter && ost->last_filter_pts != AV_NOPTS_VALUE) { - opts = ost->last_filter_pts; + if (ost->filter && ost->filter->last_pts != AV_NOPTS_VALUE) { + opts = ost->filter->last_pts; } else { opts = ost->last_mux_dts == AV_NOPTS_VALUE ? INT64_MIN : ost->last_mux_dts; diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index b45a2039ce..84ce017320 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -314,6 +314,9 @@ typedef struct OutputFilter { const int *formats; const AVChannelLayout *ch_layouts; const int *sample_rates; + + /* pts of the last frame received from this filter, in AV_TIME_BASE_Q */ + int64_t last_pts; } OutputFilter; typedef struct FilterGraph { @@ -573,8 +576,6 @@ typedef struct OutputStream { AVStream *st; /* stream in the output file */ /* dts of the last packet sent to the muxing queue, in AV_TIME_BASE_Q */ int64_t last_mux_dts; - /* pts of the last frame received from the filters, in AV_TIME_BASE_Q */ - int64_t last_filter_pts; // timestamp from which the streamcopied streams should start, // in AV_TIME_BASE_Q; diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index c9fd65e902..f48ae83a40 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -176,6 +176,18 @@ static void choose_channel_layouts(OutputFilter *ofilter, AVBPrint *bprint) av_bprint_chars(bprint, ':', 1); } +static OutputFilter *ofilter_alloc(FilterGraph *fg) +{ + OutputFilter *ofilter; + + ofilter = ALLOC_ARRAY_ELEM(fg->outputs, fg->nb_outputs); + ofilter->graph = fg; + ofilter->format = -1; + ofilter->last_pts = AV_NOPTS_VALUE; + + return ofilter; +} + int init_simple_filtergraph(InputStream *ist, OutputStream *ost) { FilterGraph *fg = av_mallocz(sizeof(*fg)); @@ -186,10 +198,8 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost) report_and_exit(AVERROR(ENOMEM)); fg->index = nb_filtergraphs; - ofilter = ALLOC_ARRAY_ELEM(fg->outputs, fg->nb_outputs); - ofilter->ost = ost; - ofilter->graph = fg; - ofilter->format = -1; + ofilter = ofilter_alloc(fg); + ofilter->ost = ost; ost->filter = ofilter; @@ -502,9 +512,8 @@ int init_complex_filtergraph(FilterGraph *fg) init_input_filter(fg, cur); for (cur = outputs; cur;) { - OutputFilter *const ofilter = ALLOC_ARRAY_ELEM(fg->outputs, fg->nb_outputs); + OutputFilter *const ofilter = ofilter_alloc(fg); - ofilter->graph = fg; ofilter->out_tmp = cur; ofilter->type = avfilter_pad_get_type(cur->filter_ctx->output_pads, cur->pad_idx); diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index ee5829c7fe..3490c99c94 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -649,7 +649,6 @@ static OutputStream *new_output_stream(Muxer *mux, const OptionsContext *o, ost->ist->st->discard = ost->ist->user_set_discard; } ost->last_mux_dts = AV_NOPTS_VALUE; - ost->last_filter_pts = AV_NOPTS_VALUE; MATCH_PER_STREAM_OPT(copy_initial_nonkeyframes, i, ost->copy_initial_nonkeyframes, oc, st); From patchwork Sun Apr 9 14:08:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41048 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1590907pzb; Sun, 9 Apr 2023 07:09:54 -0700 (PDT) X-Google-Smtp-Source: AKy350YtiVWZYJOBww7cSs5VQKdvHSD2soTOaBdtsHPCFm/bSPX6E0PiDRIyp15g73m4a7oFnnIb X-Received: by 2002:aa7:d3d0:0:b0:4fb:f2db:a654 with SMTP id o16-20020aa7d3d0000000b004fbf2dba654mr6978973edr.12.1681049394295; Sun, 09 Apr 2023 07:09:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681049394; cv=none; d=google.com; s=arc-20160816; b=VUnxIKL1M4KjgWKXvo0iszSMcgNKR8tWB430at04TySgB+ZIYbeUh3zRf3Vul9xD+2 nTajniye7rhS2WJmp0et3USpq+mH5Uny+DkVoDUX3fLTp6oCSPTEdgbjxn6snNmyR9j7 gP5fi72wgHJPx6VDfc92Kz1DUj5SQHOLkKRkDMpdKTgTHmL9B0vdQ8k6xevSDuGO568F sTo9BEcxxq3u/UEk3qrXfADxE9Q7Y1s6ZcKpIKKl6clsvjB+ZbV/HVO3Lou0YTejg4+1 +9WUzmvAr5SYZ33/kka4vM0YlHg7YHSjZnRi+VkITB4R9LWar8BlLfeT4cgkIgpsJ+wi aPaQ== 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=tqu+b4HeMX0MsNWwClew60NS1LSYU3QsxrsX5lfPFR4=; b=IJE5TD/gayQCQsQbUpirZG+oAoLjD5dxnIb3J0XHgzEzCsvNsO053Mt5ONdvmnsvdk ok7dIlRv5T0IEZiM/HDaVQZdxmBfGqVKGZxyt2uTh6XukpGZKtWik6d0CsQvC8KAtq63 aQPL0Ilz91fk/GAOXeF9h/6l0HbSr3x0EOrA5d3YB2MKUsJdwqpFM7drLEnHXywyJQ3y 34NUYm5clCc2Q97V3NOftn8vdUWzzsTYyrWBi3LNxOmPEN7in5eW52iZ7E0KxPk74SS8 KSQ5s1sTcTl3l+iQc2pAOUXus7zvGLCIp1SCUEbHkSJkvRTP4ydNGjkF00BYxt7WuGV+ KyYA== 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 t7-20020a05640203c700b004c1190b5abbsi7353174edw.184.2023.04.09.07.09.54; Sun, 09 Apr 2023 07:09:54 -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 E103768BD68; Sun, 9 Apr 2023 17:09:21 +0300 (EEST) 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 B8C7368BBCC for ; Sun, 9 Apr 2023 17:09:12 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 7C1212404F5 for ; Sun, 9 Apr 2023 16:09:12 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id yMutnp98Bz-W for ; Sun, 9 Apr 2023 16:09:12 +0200 (CEST) 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 25F99240591 for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id F31FF3A0567 for ; Sun, 9 Apr 2023 16:09:09 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Apr 2023 16:08:30 +0200 Message-Id: <20230409140853.28858-6-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230409140853.28858-1-anton@khirnov.net> References: <20230409140853.28858-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 06/29] fftools/ffmpeg_enc: replace abort() with av_assert0(0) 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: 0usZSizjBzKA This is consistent with the treatment of other unreachable paths. --- fftools/ffmpeg_enc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index 7f6bd76f10..2aaef806f6 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -306,7 +306,7 @@ int enc_open(OutputStream *ost, AVFrame *frame) break; default: - abort(); + av_assert0(0); break; } From patchwork Sun Apr 9 14:08:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41063 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1592039pzb; Sun, 9 Apr 2023 07:12:05 -0700 (PDT) X-Google-Smtp-Source: AKy350bTQIk7wDMuKPghEkOx2xt3Gtxf4hR79L39IwGrN1kEHfIOwfxIL98KzkZr0XJOaF4/VlhV X-Received: by 2002:aa7:c317:0:b0:504:8b5c:a961 with SMTP id l23-20020aa7c317000000b005048b5ca961mr3635474edq.18.1681049524816; Sun, 09 Apr 2023 07:12:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681049524; cv=none; d=google.com; s=arc-20160816; b=NZe/WljGcZcvL1platiFWVDrIS3cqkNJ4wUV5zKDk3eWNvV7zUkwE4/Rd9pHnSjyMN jJ8I/IwgeW1iiUM7Dq1yK480r1Neci6dwE8ZY/sFXLStn0+WuZihOSIlseKSAAu5NghV OppmzrpQ/PhGsb3hHBJc6U36iUmqtU1xhBaFCUIgtJv1S5ue+/ELca+fzdHgQ+mgham1 tiUNW3D0w75JivwU0zxu4upZF/Dw06nEbUFKT7QB6gCVbz6W355ySO4myAEGrS6rypf6 lDT5V3qWBr3sTezJMAZxX5NlSyoD0Y+GVd/AMAzyoXDqBlndiqYnsqnHk2+QP2m6A0FU RH8g== 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=f6dYN4SwzJEdFJAz28pzKhufL0WSYFiULXrpLpTYnwM=; b=AKf0NOOUZ10Ifk7iUHVjoAoU88J2SMlWZXADkOeRwh8HHZvKbOFe2Md2dUwFavEXWS lPjT1FeICd629oLziPp71FhFpE4osUa0wX71Tg0E7/xK0FgT+jWR+vtv+6JzFdzNxF3/ czrazyzuRXbjuH1MR4XY60AFgbJjWhSNASOmNSkT1GznihUgJ9IO1D76dGlslhHIT8O/ bcnwq+117Lt+UA89C1PovW5gH+fLFd+xwm6RlvcGwBnwiBNYv4qiGMKxRuLLQiOfRPvv Kvu8UMGZu6qxPnZocf4BDKAcV1hXO4HHQj+kgYCZfL7M1GW/EVKOUUkYtvQUL26hZhs7 LQZg== 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 l7-20020aa7c3c7000000b00504937f1e7asi2071445edr.336.2023.04.09.07.12.04; Sun, 09 Apr 2023 07:12:04 -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 3702368BD97; Sun, 9 Apr 2023 17:09:36 +0300 (EEST) 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 2F59368BCDC for ; Sun, 9 Apr 2023 17:09:16 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id A4905240591 for ; Sun, 9 Apr 2023 16:09:12 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id BkwwT9kjoJka for ; Sun, 9 Apr 2023 16:09:11 +0200 (CEST) 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 27A5F2405B5 for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 09C053A0586 for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Apr 2023 16:08:31 +0200 Message-Id: <20230409140853.28858-7-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230409140853.28858-1-anton@khirnov.net> References: <20230409140853.28858-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 07/29] fftools/ffmpeg: drop a useless goto 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: 7AlfqfkQaRip There is no cleanup in transcode(), can return an error directly. --- fftools/ffmpeg.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 1f50b82794..1cd9a8f29f 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2905,7 +2905,7 @@ static int transcode(void) ret = transcode_init(); if (ret < 0) - goto fail; + return ret; if (stdin_interaction) { av_log(NULL, AV_LOG_INFO, "Press [q] to stop, [?] for help\n"); @@ -2975,11 +2975,7 @@ static int transcode(void) hw_device_free_all(); - /* finished ! */ - ret = 0; - - fail: - return ret; + return 0; } static BenchmarkTimeStamps get_benchmark_time_stamps(void) From patchwork Sun Apr 9 14:08:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41046 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1592421pzb; Sun, 9 Apr 2023 07:12:48 -0700 (PDT) X-Google-Smtp-Source: AKy350ZsrhzGHpdWsopc2T2U5yD2ffjOHfMfZS2KG+Kt0WbTANMhT6tzkkVRtpXxdXeBHC8y2hLb X-Received: by 2002:a05:6402:1501:b0:504:784e:47d9 with SMTP id f1-20020a056402150100b00504784e47d9mr7494438edw.6.1681049568518; Sun, 09 Apr 2023 07:12:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681049568; cv=none; d=google.com; s=arc-20160816; b=li6F4iHGOH2QGJESZpvlJ6YXSfCvMj3va5yor5BTslH7XwV6k5AcRAhsp4oI5O2KW6 M9zB5Khso2DR451FKjv3xhGv81tQ2ud/ftKBA+UB1RgQf3UhSa5ckVVHoZu6ISvJyVZj N+o0sUrkxsSbuuLANs6fxWimS4U96+RSJGlE2Z/896neiZesNwcOmFeCah3QDiSlwfpS vmmesiNtstP0Cc2fEwdwztH5ONAbMtx0BNyY9hDQMggudMzMCEkbCI/mS09hf05OB7lp XFjPp3YBmnlV2iFkBEJjhoFdB1K1jLI2gHxZUD7JVJNqzKtfnQvDtbRL76F+C9hRTpWz EN6w== 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=LXN77rhYSZkwGPJ1xQOSUl+7EsSkcj77k5c3Iwv8zEI=; b=00oKNWP0cE4f3BwDazpB8Ug/GXcPWrihbUzbaOGDOzxShpWK8hHHremPN7uejts561 qMXfGYSeYS3UL/Qrew8FVc9tx6PU6l2oz1egl/SDqY/43zrGbZ69UltuOGmgkM3w5ziZ PFGXnj/tCMHqu8h4/6kS5xzt4CuvLon9iDtz7HXaCya/OBx/QmujLyXAFKAmqtPx24V7 2GtdO1o7OzgE52Fj5w7fNS20En7Ox2BbfhWxtDdAs83Tk1In89Psn8QVxoDgdNPHbY1k V/NvINlxFOFLIo8jpESgAanFUKwkWm+6kgU9RefgCdBr3LX9dV/posUpx7yad5pUk7Yq lUYA== 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 a24-20020aa7cf18000000b00504a189b831si638132edy.104.2023.04.09.07.12.48; Sun, 09 Apr 2023 07:12:48 -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 1D1AC68BE85; Sun, 9 Apr 2023 17:09:41 +0300 (EEST) 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 CDE8D68BD67 for ; Sun, 9 Apr 2023 17:09:16 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id C84972406CA for ; Sun, 9 Apr 2023 16:09:13 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id qglg7zJnFIHw for ; Sun, 9 Apr 2023 16:09:13 +0200 (CEST) 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 4CC022406CC for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 1476C3A05C8 for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Apr 2023 16:08:32 +0200 Message-Id: <20230409140853.28858-8-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230409140853.28858-1-anton@khirnov.net> References: <20230409140853.28858-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 08/29] fftools/ffmpeg: move the hw_device_free_all() call to ffmpeg_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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: bH6u3ousa6eh Frees devices on failure as well as success. --- fftools/ffmpeg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 1cd9a8f29f..816b6c4b08 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -551,6 +551,8 @@ static void ffmpeg_cleanup(int ret) av_freep(&vstats_filename); of_enc_stats_close(); + hw_device_free_all(); + av_freep(&filter_nbthreads); av_freep(&input_files); @@ -2973,8 +2975,6 @@ static int transcode(void) exit_program(1); } - hw_device_free_all(); - return 0; } From patchwork Sun Apr 9 14:08:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41069 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1592560pzb; Sun, 9 Apr 2023 07:13:06 -0700 (PDT) X-Google-Smtp-Source: AKy350aFAFNDjAimfubPQskATMRTWLB9H1hx0XLwuRD+HIbocxMgpRRZcvZU56/H9xAS1izQ4Peg X-Received: by 2002:a05:6402:1603:b0:4fa:ba31:6c66 with SMTP id f3-20020a056402160300b004faba316c66mr3974319edv.42.1681049585928; Sun, 09 Apr 2023 07:13:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681049585; cv=none; d=google.com; s=arc-20160816; b=gwmZvgg4LwkMb+wfGxGCguLDW/G0XmSAeezj68QGzzKtn9QCzIi/HogPiIF56qjQEg hf5Yez8hya0gx1RWfLMVxP6p4zjPpycduRblTt6yGbEYu54Cwt680oVLFqT2jNnrooOY qJEUwIT6M8XekROdk+VLgJUdUVbhK+8pDVsMYRzaSjmxixUHE337KEs8aanVG8B728Kz dVSBcGsdwgptYgiftQgloFixc70N0lSOk01ZbsZYG677fU9MSyfaX7/zWMOoR+RVHibD TCUqLmygBjhANZn73mEj138BuMJsQFpU4ukqBTvJj+LfX5EUXwrpZmIdKQULffJcJkb3 snUw== 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=e34+W+EXEoltV6vP6PvdQcD6p2liSnOLC67RtL8WBzE=; b=ZRCCtmRN3LMXqndPVl/dodorbq9BlB4X5R0Ec0tIqZJOCrWbKTpLEmQeI90XRKEE/b D34ROMvgPBv+16urcIbBSCEBslER1+pILKWvDITUKaS0vaHQEZ7tAK+yvuzYInH4KL6e TAp9woo8/oWbPJpouqMcdmIv0ZXZeSvRSWga9g7fxtIs5UgsXVRqbb2+q8poeWKux2Br gHXUQGOkyGN/C5DNnWe7sbXpIxypTywwsuOjhdcsZvVWvG+o0Ghu38GIbPe+UdzPCOEt CyflVpQQhQRXo5oFj4iwnz0es8zMBgWfqygre6pjoCKjIu+ObprTDIwwc6dpwDtyE9dD NBUg== 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 w18-20020a056402129200b004cfc2f60ca3si7298558edv.50.2023.04.09.07.13.05; Sun, 09 Apr 2023 07:13:05 -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 256B668BE98; Sun, 9 Apr 2023 17:09:43 +0300 (EEST) 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 0FB0468BBF7 for ; Sun, 9 Apr 2023 17:09:17 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id C902B2406CD for ; Sun, 9 Apr 2023 16:09:14 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id bVxTs3EEvDaN for ; Sun, 9 Apr 2023 16:09:13 +0200 (CEST) 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 3033A2405F9 for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 206F83A05CB for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Apr 2023 16:08:33 +0200 Message-Id: <20230409140853.28858-9-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230409140853.28858-1-anton@khirnov.net> References: <20230409140853.28858-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 09/29] fftools/ffmpeg: eliminate the main_return_code global 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: iPLtvwoBAkeZ Properly pass muxing return codes through the call stack instead. Slightly changes behavior in case of errors: * the output IO stream is closed even if writing the trailer returns an error, which should be more correct * all files get properly closed with -xerror, even if one of them fails --- fftools/ffmpeg.c | 18 ++++++++---------- fftools/ffmpeg.h | 12 +++++++++++- fftools/ffmpeg_mux.c | 12 +++++------- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 816b6c4b08..7431482acc 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -318,7 +318,6 @@ static volatile int received_sigterm = 0; static volatile int received_nb_signals = 0; static atomic_int transcode_init_done = ATOMIC_VAR_INIT(0); static volatile int ffmpeg_exited = 0; -int main_return_code = 0; static int64_t copy_ts_first_pts = AV_NOPTS_VALUE; static void @@ -2951,9 +2950,8 @@ static int transcode(void) /* write the trailer if needed */ for (i = 0; i < nb_output_files; i++) { - ret = of_write_trailer(output_files[i]); - if (ret < 0 && exit_on_error) - exit_program(1); + int err = of_write_trailer(output_files[i]); + ret = err_merge(ret, err); } /* dump report by using the first video and audio streams */ @@ -2975,7 +2973,7 @@ static int transcode(void) exit_program(1); } - return 0; + return ret; } static BenchmarkTimeStamps get_benchmark_time_stamps(void) @@ -3061,9 +3059,8 @@ int main(int argc, char **argv) } current_time = ti = get_benchmark_time_stamps(); - if (transcode() < 0) - exit_program(1); - if (do_benchmark) { + ret = transcode(); + if (ret >= 0 && do_benchmark) { int64_t utime, stime, rtime; current_time = get_benchmark_time_stamps(); utime = current_time.user_usec - ti.user_usec; @@ -3078,6 +3075,7 @@ int main(int argc, char **argv) if ((decode_error_stat[0] + decode_error_stat[1]) * max_error_rate < decode_error_stat[1]) exit_program(69); - exit_program(received_nb_signals ? 255 : main_return_code); - return main_return_code; + ret = received_nb_signals ? 255 : ret; + exit_program(ret); + return ret; } diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 84ce017320..ddfeeabf75 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -756,7 +756,6 @@ extern const OptionDef options[]; extern HWDevice *filter_hw_device; extern unsigned nb_output_dumped; -extern int main_return_code; extern int ignore_unknown_streams; extern int copy_unknown_streams; @@ -887,6 +886,17 @@ void close_output_stream(OutputStream *ost); int trigger_fix_sub_duration_heartbeat(OutputStream *ost, const AVPacket *pkt); void update_benchmark(const char *fmt, ...); +/** + * Merge two return codes - return one of the error codes if at least one of + * them was negative, 0 otherwise. + * Currently just picks the first one, eventually we might want to do something + * more sophisticated, like sorting them by priority. + */ +static inline int err_merge(int err0, int err1) +{ + return (err0 < 0) ? err0 : FFMIN(err1, 0); +} + #define SPECIFIER_OPT_FMT_str "%s" #define SPECIFIER_OPT_FMT_i "%i" #define SPECIFIER_OPT_FMT_i64 "%"PRId64 diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 5663b8f11d..c2b7993e66 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -602,7 +602,7 @@ int of_write_trailer(OutputFile *of) { Muxer *mux = mux_from_of(of); AVFormatContext *fc = mux->fc; - int ret; + int ret, mux_result = 0; if (!mux->tq) { av_log(mux, AV_LOG_ERROR, @@ -611,14 +611,12 @@ int of_write_trailer(OutputFile *of) return AVERROR(EINVAL); } - ret = thread_stop(mux); - if (ret < 0) - main_return_code = ret; + mux_result = thread_stop(mux); ret = av_write_trailer(fc); if (ret < 0) { av_log(mux, AV_LOG_ERROR, "Error writing trailer: %s\n", av_err2str(ret)); - return ret; + mux_result = err_merge(mux_result, ret); } mux->last_filesize = filesize(fc->pb); @@ -627,11 +625,11 @@ int of_write_trailer(OutputFile *of) ret = avio_closep(&fc->pb); if (ret < 0) { av_log(mux, AV_LOG_ERROR, "Error closing file: %s\n", av_err2str(ret)); - return ret; + mux_result = err_merge(mux_result, ret); } } - return 0; + return mux_result; } static void ost_free(OutputStream **post) From patchwork Sun Apr 9 14:08:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41067 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1592336pzb; Sun, 9 Apr 2023 07:12:39 -0700 (PDT) X-Google-Smtp-Source: AKy350ZV6IvoPRi/wiXXpHZ2ICrU8Eucc7I887JG0i1xM0Guz3gKR5/4PY6/p0fCmG4KXwhSBWyM X-Received: by 2002:a05:6402:26cc:b0:504:999f:525a with SMTP id x12-20020a05640226cc00b00504999f525amr1552758edd.20.1681049559741; Sun, 09 Apr 2023 07:12:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681049559; cv=none; d=google.com; s=arc-20160816; b=OXjxbqQRW7w2gHfxCcB4yXKSCNSDDwxDUy9j/9/s5jPUUp0TjHNnhY6bnjv2ux3jDo Ifb+uey1kzmvTkh3ERsiNX+8AoWTJMUNeMSL0vWsEdtHGJuysbQ13IIwkSz359HMUFKV IegdAStvPjCSOlIJTxmBncV0PLsbNvbYIWje8kap4ZPZKjHKdyDhBi9DtqgQ4OREjeko +2MV3h5pWHohokLjrwwigrPgLDUx9hq/4S+Ta+m1yUDxYasXrlq9NPJAICEuj97Yg3HI u1+PpVU0ZiwZwDvYnjThJ4rdXm+L7Aoc+s0oVUnFu/rel9OLZ7rAKFHqn5Hy90n43XyW 2nGw== 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=tcwUkSgG+U1I5lQ6Wg8BHg80u9/edszNqRYb5nE0DBo=; b=m9ihszdAEOIiAksbGCOMkrfteRtKYN1Y183xetFIm8yvDy2Nn0dr8j+1RX/ZFNOlcQ bx9iBm4NdleLs74g+QMU/QrBBvWJw6sIOVd4joOlUBCnX7lWg44dvwkqj55GlWEgsbWR 6ptxSU10PNbW7O2pdnHTDVu135JzDxgbbjRF3VJB400luuwGEc4Gy05D0aE5EBeQL9Gz Hkycj0GXNK0FzC8EIX4kmpb4vjFAZPb5ZapFbOA7Mb7MS9bFTtr47qhp53xYOo5/4taF x9ECVP7FAaukpR+8MSxddPlSbNbxtrSgu7oRhnxD3wFNIMCr91uMDOicRGi2EAjENuRo gyBg== 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 b13-20020aa7cd0d000000b0050497afb3b4si1986811edw.258.2023.04.09.07.12.39; Sun, 09 Apr 2023 07:12:39 -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 2C77E68BE7E; Sun, 9 Apr 2023 17:09:40 +0300 (EEST) 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 C4C2968BBE7 for ; Sun, 9 Apr 2023 17:09:16 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 549902405EC for ; Sun, 9 Apr 2023 16:09:13 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id x2OAauG9nUXs for ; Sun, 9 Apr 2023 16:09:12 +0200 (CEST) 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 3CCFB2406CA for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 2C3063A038E for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Apr 2023 16:08:34 +0200 Message-Id: <20230409140853.28858-10-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230409140853.28858-1-anton@khirnov.net> References: <20230409140853.28858-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 10/29] fftools/ffmpeg: factorize checking whether any output was written 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: 8B8/I3G3rQV2 This is currently done in two places: * at the end of print_final_stats(), which merely prints a warning if the total size of all written packets is zero * at the end of transcode() (under a misleading historical 'close each encoder' comment), which instead checks the packet count to implement -abort_on empty_output[_stream] Consolidate both of these blocks into a single function called from of_write_trailer(), which is a more appropriate place for this. Also, return an error code rather than exit immediately, which ensures all output files are properly closed. --- fftools/ffmpeg.c | 30 ------------------------------ fftools/ffmpeg_mux.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 30 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 7431482acc..48e771cbc5 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -745,7 +745,6 @@ static void print_final_stats(int64_t total_size) uint64_t data_size = 0; float percent = -1.0; int i, j; - int pass1_used = 1; for (OutputStream *ost = ost_iter(NULL); ost; ost = ost_iter(ost)) { AVCodecParameters *par = ost->st->codecpar; @@ -759,10 +758,6 @@ static void print_final_stats(int64_t total_size) } extra_size += par->extradata_size; data_size += s; - if (ost->enc_ctx && - (ost->enc_ctx->flags & (AV_CODEC_FLAG_PASS1 | AV_CODEC_FLAG_PASS2)) - != AV_CODEC_FLAG_PASS1) - pass1_used = 0; } if (data_size && total_size>0 && total_size >= data_size) @@ -848,14 +843,6 @@ static void print_final_stats(int64_t total_size) av_log(NULL, AV_LOG_VERBOSE, " Total: %"PRIu64" packets (%"PRIu64" bytes) muxed\n", total_packets, total_size); } - if(video_size + data_size + audio_size + subtitle_size + extra_size == 0){ - av_log(NULL, AV_LOG_WARNING, "Output file is empty, nothing was encoded "); - if (pass1_used) { - av_log(NULL, AV_LOG_WARNING, "\n"); - } else { - av_log(NULL, AV_LOG_WARNING, "(check -ss / -t / -frames parameters if used)\n"); - } - } } static void print_report(int is_last_report, int64_t timer_start, int64_t cur_time) @@ -2902,7 +2889,6 @@ static int transcode(void) int ret, i; InputStream *ist; int64_t timer_start; - int64_t total_packets_written = 0; ret = transcode_init(); if (ret < 0) @@ -2957,22 +2943,6 @@ static int transcode(void) /* dump report by using the first video and audio streams */ print_report(1, timer_start, av_gettime_relative()); - /* close each encoder */ - for (OutputStream *ost = ost_iter(NULL); ost; ost = ost_iter(ost)) { - uint64_t packets_written; - packets_written = atomic_load(&ost->packets_written); - total_packets_written += packets_written; - if (!packets_written && (abort_on_flags & ABORT_ON_FLAG_EMPTY_OUTPUT_STREAM)) { - av_log(ost, AV_LOG_FATAL, "Empty output\n"); - exit_program(1); - } - } - - if (!total_packets_written && (abort_on_flags & ABORT_ON_FLAG_EMPTY_OUTPUT)) { - av_log(NULL, AV_LOG_FATAL, "Empty output\n"); - exit_program(1); - } - return ret; } diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index c2b7993e66..9a91861bd4 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -598,6 +598,45 @@ int of_stream_init(OutputFile *of, OutputStream *ost) return mux_check_init(mux); } +static int check_written(OutputFile *of) +{ + int64_t total_packets_written = 0; + int pass1_used = 1; + int ret = 0; + + for (int i = 0; i < of->nb_streams; i++) { + OutputStream *ost = of->streams[i]; + uint64_t packets_written = atomic_load(&ost->packets_written); + + total_packets_written += packets_written; + + if (ost->enc_ctx && + (ost->enc_ctx->flags & (AV_CODEC_FLAG_PASS1 | AV_CODEC_FLAG_PASS2)) + != AV_CODEC_FLAG_PASS1) + pass1_used = 0; + + if (!packets_written && + (abort_on_flags & ABORT_ON_FLAG_EMPTY_OUTPUT_STREAM)) { + av_log(ost, AV_LOG_FATAL, "Empty output stream\n"); + ret = err_merge(ret, AVERROR(EINVAL)); + } + } + + if (!total_packets_written) { + int level = AV_LOG_WARNING; + + if (abort_on_flags & ABORT_ON_FLAG_EMPTY_OUTPUT) { + ret = err_merge(ret, AVERROR(EINVAL)); + level = AV_LOG_FATAL; + } + + av_log(of, level, "Output file is empty, nothing was encoded%s\n", + pass1_used ? "" : "(check -ss / -t / -frames parameters if used)"); + } + + return ret; +} + int of_write_trailer(OutputFile *of) { Muxer *mux = mux_from_of(of); @@ -629,6 +668,10 @@ int of_write_trailer(OutputFile *of) } } + // check whether anything was actually written + ret = check_written(of); + mux_result = err_merge(mux_result, ret); + return mux_result; } From patchwork Sun Apr 9 14:08:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41071 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1592705pzb; Sun, 9 Apr 2023 07:13:24 -0700 (PDT) X-Google-Smtp-Source: AKy350brWEectH6IjnLfE2btrUqfM4fV2xfVEbf6HLYnCwhry1Xrs1SIXCxnMVSmU2vbykeiQ2tV X-Received: by 2002:a17:906:381b:b0:947:c221:eb38 with SMTP id v27-20020a170906381b00b00947c221eb38mr5511707ejc.13.1681049604045; Sun, 09 Apr 2023 07:13:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681049604; cv=none; d=google.com; s=arc-20160816; b=WYFCpIyoVYtA51bOqTRIENPg+KD49RtWbz8bEZMbxmlvEDRQAbVQqwPYyz472BI3XN ZCZTBslEOR/OX0hJNXBLtN6O94p3XSnEgae+/CsTxKjApaj5zhTqJP3fitz7TSi6zwH0 I4nELUrDP89z1paRZpVJx50QeoJPvV/qcAEKes25INk4TPtB986AQH0rde8zzDDJ5TpV AeM25uNc737fDEMJJSNw1irS+6ocm2/CQ4rxcF4wWuEk9gR6yz9hdkKVsllZVuySUKSE IGPwt/F0pocUS1nJwX7lVfP5ZDofRRN/d2JgJEqIp9YYfKJkzhgc9xnhLUhAyglnjmh0 H6mA== 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=M6pMLC9F8gymGtA7kObxhYnfak8v3soQUeiJpHP9PHc=; b=KB0/GKewILNND2ZfidfdrgSqVVGY/A7PU/RE6VLfK9RzLGSNlDPf7cz0rQEBxzjh/s yu+sEHDHZe5WfozIp0u/mWDWI2Q6RRfXJ0pOX+6JDODIhAXH5lecvTTc/0Mkx/11rATm qZ2ZFsQhUOezVeiKBds9SBnpV2/ZwTatHNjCDJ9rIJ3+Z+esdT40YUau9TSu+v6gJqa7 gcntf2+Hk0Vpd/WVlEQStULVM9y6h0dcmMv5AbbiAhr3ZaMpY8LT/DrYwTQq9WESkDnx iG2pT9ku+mYTy+HLNuQ8fruFOUSVNwFqeIMW/wpJh2FYgF3PXaBH9iyAVJ3aOJeRSye/ p+HA== 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 hq22-20020a1709073f1600b00947b79daa6dsi8344948ejc.325.2023.04.09.07.13.23; Sun, 09 Apr 2023 07:13:24 -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 2566368BEA9; Sun, 9 Apr 2023 17:09:45 +0300 (EEST) 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 85DD068BD6C for ; Sun, 9 Apr 2023 17:09:17 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 098FB2405F9 for ; Sun, 9 Apr 2023 16:09:15 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id DZJ5pG_O54dm for ; Sun, 9 Apr 2023 16:09:14 +0200 (CEST) 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 464912406CB for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 37A813A039B for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Apr 2023 16:08:35 +0200 Message-Id: <20230409140853.28858-11-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230409140853.28858-1-anton@khirnov.net> References: <20230409140853.28858-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 11/29] fftools/ffmpeg: move printing verbose muxing stats to ffmpeg_mux 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: TePXgNegAdU9 This is a more appropriate place for this. --- fftools/ffmpeg.c | 34 ---------------------------------- fftools/ffmpeg_mux.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 34 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 48e771cbc5..e1748114b3 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -809,40 +809,6 @@ static void print_final_stats(int64_t total_size) av_log(NULL, AV_LOG_VERBOSE, " Total: %"PRIu64" packets (%"PRIu64" bytes) demuxed\n", total_packets, total_size); } - - for (i = 0; i < nb_output_files; i++) { - OutputFile *of = output_files[i]; - uint64_t total_packets = 0, total_size = 0; - - av_log(NULL, AV_LOG_VERBOSE, "Output file #%d (%s):\n", - i, of->url); - - for (j = 0; j < of->nb_streams; j++) { - OutputStream *ost = of->streams[j]; - enum AVMediaType type = ost->st->codecpar->codec_type; - - total_size += ost->data_size_mux; - total_packets += atomic_load(&ost->packets_written); - - av_log(NULL, AV_LOG_VERBOSE, " Output stream #%d:%d (%s): ", - i, j, av_get_media_type_string(type)); - if (ost->enc_ctx) { - av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" frames encoded", - ost->frames_encoded); - if (type == AVMEDIA_TYPE_AUDIO) - av_log(NULL, AV_LOG_VERBOSE, " (%"PRIu64" samples)", ost->samples_encoded); - av_log(NULL, AV_LOG_VERBOSE, "; "); - } - - av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" packets muxed (%"PRIu64" bytes); ", - atomic_load(&ost->packets_written), ost->data_size_mux); - - av_log(NULL, AV_LOG_VERBOSE, "\n"); - } - - av_log(NULL, AV_LOG_VERBOSE, " Total: %"PRIu64" packets (%"PRIu64" bytes) muxed\n", - total_packets, total_size); - } } static void print_report(int is_last_report, int64_t timer_start, int64_t cur_time) diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 9a91861bd4..5acd3b9b9d 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -637,6 +637,41 @@ static int check_written(OutputFile *of) return ret; } +static void mux_final_stats(Muxer *mux) +{ + OutputFile *of = &mux->of; + uint64_t total_packets = 0, total_size = 0; + + av_log(NULL, AV_LOG_VERBOSE, "Output file #%d (%s):\n", + of->index, of->url); + + for (int j = 0; j < of->nb_streams; j++) { + OutputStream *ost = of->streams[j]; + enum AVMediaType type = ost->st->codecpar->codec_type; + + total_size += ost->data_size_mux; + total_packets += atomic_load(&ost->packets_written); + + av_log(NULL, AV_LOG_VERBOSE, " Output stream #%d:%d (%s): ", + of->index, j, av_get_media_type_string(type)); + if (ost->enc_ctx) { + av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" frames encoded", + ost->frames_encoded); + if (type == AVMEDIA_TYPE_AUDIO) + av_log(NULL, AV_LOG_VERBOSE, " (%"PRIu64" samples)", ost->samples_encoded); + av_log(NULL, AV_LOG_VERBOSE, "; "); + } + + av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" packets muxed (%"PRIu64" bytes); ", + atomic_load(&ost->packets_written), ost->data_size_mux); + + av_log(NULL, AV_LOG_VERBOSE, "\n"); + } + + av_log(NULL, AV_LOG_VERBOSE, " Total: %"PRIu64" packets (%"PRIu64" bytes) muxed\n", + total_packets, total_size); +} + int of_write_trailer(OutputFile *of) { Muxer *mux = mux_from_of(of); @@ -668,6 +703,8 @@ int of_write_trailer(OutputFile *of) } } + mux_final_stats(mux); + // check whether anything was actually written ret = check_written(of); mux_result = err_merge(mux_result, ret); From patchwork Sun Apr 9 14:08:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41068 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1592485pzb; Sun, 9 Apr 2023 07:12:57 -0700 (PDT) X-Google-Smtp-Source: AKy350aAvBZkKpL9buUyRUuCi8vMovAnoI4TYeqDJwXJCD2aInROPsEXKtzvjXb2NNwkZTFTek+W X-Received: by 2002:a17:907:3f1d:b0:94a:8a82:9cab with SMTP id hq29-20020a1709073f1d00b0094a8a829cabmr437314ejc.42.1681049577046; Sun, 09 Apr 2023 07:12:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681049577; cv=none; d=google.com; s=arc-20160816; b=MT300aC9RIXs5WYrc//ZWkYGDLDlUcuWWfffficU7CCeb69f2PbHyW7zzXzuwTGmO9 ctvnNqVSMgCMFdKN/K/CO9F0M+IRIZJq+qbOm659vj5s/GrppHiGTl44S7XU3izZeGRQ LjX2E9h1cBHdGErJ8fGDWVerOPdY3XHc9Me2/YsJCiXpKn4UQycCSeiQE0dzhaPDQYsn 3aQkb/jFSDC3IADjFF2e6C60IztWTNVcxVrqCudLcuqLUXhJFwFiftlRy589L2D7S5cs UrITrixvF/+JMja07PRxpCdn9wWLMdiT2WtnNxXhnj+Fj9jtj396JAXr9MWMzmURz6Ry HGCA== 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=6kPZ0RLHMbl+ZRijDDzcEnNgzlNqrzLvd2N98/E9tZQ=; b=D5fEu9s5P62k2R4BBNqurjYjjId2sKBtUNIgXQ5g3wQYzwIYHEjdE9EMYNA9PK4EkW cGpppANlTXcaDLQaQniJfGK0alV4Non/Uqe/GfN5PRI/AW8Y5lQ9shGY09HauUHqDNlt dMld3wMrzVzVPZnobFuENKArO2wle9FOEnBRry4Kzp+kdDg4lbwIHWNrkqotIzrgWdAV DMN06BnjylGXatT8iJvgfIs9xxE2K2Gumr6MstJ+yT9fTvEf1n2VqR1edcmOvrETKPHH e+zxBFM0P6M44rCub/06WFdDtI8Hr5y187kRdv2T60bIZtZ8qVdk3fPdos+YWEcPLemt syJg== 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 gs15-20020a1709072d0f00b0094a5d495ca9si2661872ejc.249.2023.04.09.07.12.56; Sun, 09 Apr 2023 07:12:57 -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 0C84968BDA6; Sun, 9 Apr 2023 17:09:42 +0300 (EEST) 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 0812768BB52 for ; Sun, 9 Apr 2023 17:09:17 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 6C1312406CC for ; Sun, 9 Apr 2023 16:09:14 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id SafpnSdH2-nI for ; Sun, 9 Apr 2023 16:09:13 +0200 (CEST) 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 520242406CD for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 426813A03E5 for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Apr 2023 16:08:36 +0200 Message-Id: <20230409140853.28858-12-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230409140853.28858-1-anton@khirnov.net> References: <20230409140853.28858-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 12/29] fftools/ffmpeg_mux: reindent 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: 4pxQDNqolgL7 --- fftools/ffmpeg_mux.c | 56 ++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 5acd3b9b9d..f3a3a9b7a2 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -639,37 +639,37 @@ static int check_written(OutputFile *of) static void mux_final_stats(Muxer *mux) { - OutputFile *of = &mux->of; - uint64_t total_packets = 0, total_size = 0; - - av_log(NULL, AV_LOG_VERBOSE, "Output file #%d (%s):\n", - of->index, of->url); - - for (int j = 0; j < of->nb_streams; j++) { - OutputStream *ost = of->streams[j]; - enum AVMediaType type = ost->st->codecpar->codec_type; - - total_size += ost->data_size_mux; - total_packets += atomic_load(&ost->packets_written); - - av_log(NULL, AV_LOG_VERBOSE, " Output stream #%d:%d (%s): ", - of->index, j, av_get_media_type_string(type)); - if (ost->enc_ctx) { - av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" frames encoded", - ost->frames_encoded); - if (type == AVMEDIA_TYPE_AUDIO) - av_log(NULL, AV_LOG_VERBOSE, " (%"PRIu64" samples)", ost->samples_encoded); - av_log(NULL, AV_LOG_VERBOSE, "; "); - } + OutputFile *of = &mux->of; + uint64_t total_packets = 0, total_size = 0; + + av_log(NULL, AV_LOG_VERBOSE, "Output file #%d (%s):\n", + of->index, of->url); + + for (int j = 0; j < of->nb_streams; j++) { + OutputStream *ost = of->streams[j]; + enum AVMediaType type = ost->st->codecpar->codec_type; + + total_size += ost->data_size_mux; + total_packets += atomic_load(&ost->packets_written); + + av_log(NULL, AV_LOG_VERBOSE, " Output stream #%d:%d (%s): ", + of->index, j, av_get_media_type_string(type)); + if (ost->enc_ctx) { + av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" frames encoded", + ost->frames_encoded); + if (type == AVMEDIA_TYPE_AUDIO) + av_log(NULL, AV_LOG_VERBOSE, " (%"PRIu64" samples)", ost->samples_encoded); + av_log(NULL, AV_LOG_VERBOSE, "; "); + } - av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" packets muxed (%"PRIu64" bytes); ", - atomic_load(&ost->packets_written), ost->data_size_mux); + av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" packets muxed (%"PRIu64" bytes); ", + atomic_load(&ost->packets_written), ost->data_size_mux); - av_log(NULL, AV_LOG_VERBOSE, "\n"); - } + av_log(NULL, AV_LOG_VERBOSE, "\n"); + } - av_log(NULL, AV_LOG_VERBOSE, " Total: %"PRIu64" packets (%"PRIu64" bytes) muxed\n", - total_packets, total_size); + av_log(NULL, AV_LOG_VERBOSE, " Total: %"PRIu64" packets (%"PRIu64" bytes) muxed\n", + total_packets, total_size); } int of_write_trailer(OutputFile *of) From patchwork Sun Apr 9 14:08:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41070 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1592640pzb; Sun, 9 Apr 2023 07:13:15 -0700 (PDT) X-Google-Smtp-Source: AKy350ZTvSDrADDjRQP3c5PafhgNh3xKMcZb8cVIPYVthdSm+M5BGVWueEQcTvOI4WmAUMsv3NbL X-Received: by 2002:aa7:cb0a:0:b0:504:94b9:f21 with SMTP id s10-20020aa7cb0a000000b0050494b90f21mr2309443edt.27.1681049595146; Sun, 09 Apr 2023 07:13:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681049595; cv=none; d=google.com; s=arc-20160816; b=DAOCzNpeIiw3UdQ8IEHCRFxCr2H1pYDNqpx9KtX03QJGhPu41p2RYvIF/9neetdPEk y31NXwpNd0jxkptVYXC8AM92OHRq5klMc+CK10nh3kpNhrTzuu4/x8SOEETzl3y7z/Z6 W/rw6FEXz9Wz8gsjOFbunB8msAhFZT92Pl5PrvYFhpDdrJpxkijEGR3PJfrMqL4sRHn3 gTuzWuzE7HrDchtiqJl4NYWJzP0ptrkZulQTMDENQ8Zu4eg3y+fSQmw2eawmNBj0eSNE lInBiY3S70Rn0Ee7jB/JhjQuutqGvjkTcj2caz2SZ5lkcZ/7vUzJ2G+SCNW99UPzBP8X ooNg== 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=GP1RkIhxe5+0QpFIAXTYwd/3TX6KISvpKEIt5LDqUH0=; b=NeDl5y0hHQleyipCe4Ooxe0UHrUi0P+ADTkwG+FbVizAwNOpkpQPpeKb8w2tsEqA1Q MMzoD5sZauZZqi5fdkNPDfUv9NPcB4lN/Dw8/bs2kzAa/Wo9qiJNlBllssKCm0n7BHV1 Qrb2/7/o/jBqpq2E74D/ERt9AUKdToc6lvUudQpe8Ade00/XA9APV6O66KeEkhccy/YA +kXVD1BuO9TWHpX4fUclH8q709eiEXSSpBvS6EmR4x4Zr5x5S2NvacalEgmqEDN+QbBP U107eH+CPBDDvLSgUJEhTFACs+dVS88aEjY2Wy6CmMtuTyrDWkojkCTtg1xKVFykNP3+ KJzg== 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 k8-20020a05640212c800b004fbae1637fcsi8278299edx.479.2023.04.09.07.13.14; Sun, 09 Apr 2023 07:13:15 -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 231EE68BEA0; Sun, 9 Apr 2023 17:09:44 +0300 (EEST) 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 813E668BD51 for ; Sun, 9 Apr 2023 17:09:17 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 500EA2406CB for ; Sun, 9 Apr 2023 16:09:15 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id YqmRPaPJRP-C for ; Sun, 9 Apr 2023 16:09:14 +0200 (CEST) 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 5DE052406CE for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 4D33C3A0404 for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Apr 2023 16:08:37 +0200 Message-Id: <20230409140853.28858-13-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230409140853.28858-1-anton@khirnov.net> References: <20230409140853.28858-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 13/29] fftools/ffmpeg_mux: log final stats to muxer context 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: pNhEQl7Q6se6 --- fftools/ffmpeg_mux.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index f3a3a9b7a2..441f1cd3a7 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -642,7 +642,7 @@ static void mux_final_stats(Muxer *mux) OutputFile *of = &mux->of; uint64_t total_packets = 0, total_size = 0; - av_log(NULL, AV_LOG_VERBOSE, "Output file #%d (%s):\n", + av_log(of, AV_LOG_VERBOSE, "Output file #%d (%s):\n", of->index, of->url); for (int j = 0; j < of->nb_streams; j++) { @@ -652,23 +652,23 @@ static void mux_final_stats(Muxer *mux) total_size += ost->data_size_mux; total_packets += atomic_load(&ost->packets_written); - av_log(NULL, AV_LOG_VERBOSE, " Output stream #%d:%d (%s): ", + av_log(of, AV_LOG_VERBOSE, " Output stream #%d:%d (%s): ", of->index, j, av_get_media_type_string(type)); if (ost->enc_ctx) { - av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" frames encoded", + av_log(of, AV_LOG_VERBOSE, "%"PRIu64" frames encoded", ost->frames_encoded); if (type == AVMEDIA_TYPE_AUDIO) - av_log(NULL, AV_LOG_VERBOSE, " (%"PRIu64" samples)", ost->samples_encoded); - av_log(NULL, AV_LOG_VERBOSE, "; "); + av_log(of, AV_LOG_VERBOSE, " (%"PRIu64" samples)", ost->samples_encoded); + av_log(of, AV_LOG_VERBOSE, "; "); } - av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" packets muxed (%"PRIu64" bytes); ", + av_log(of, AV_LOG_VERBOSE, "%"PRIu64" packets muxed (%"PRIu64" bytes); ", atomic_load(&ost->packets_written), ost->data_size_mux); - av_log(NULL, AV_LOG_VERBOSE, "\n"); + av_log(of, AV_LOG_VERBOSE, "\n"); } - av_log(NULL, AV_LOG_VERBOSE, " Total: %"PRIu64" packets (%"PRIu64" bytes) muxed\n", + av_log(of, AV_LOG_VERBOSE, " Total: %"PRIu64" packets (%"PRIu64" bytes) muxed\n", total_packets, total_size); } From patchwork Sun Apr 9 14:08:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41049 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1590986pzb; Sun, 9 Apr 2023 07:10:02 -0700 (PDT) X-Google-Smtp-Source: AKy350bFWC1IxmScP0SotNSnX6tSaJTOas/GAWpKW7oWMGmshfWXRX0MV23djPttB8EzqpKC+6hR X-Received: by 2002:aa7:c0c7:0:b0:4fb:395a:6aa4 with SMTP id j7-20020aa7c0c7000000b004fb395a6aa4mr6895745edp.31.1681049402617; Sun, 09 Apr 2023 07:10:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681049402; cv=none; d=google.com; s=arc-20160816; b=ZnGGAl8ipLOXAIQSIiX3tGq/6e0xD+Brah4gp+tLLMkwh2nBzBn82eTdhYBDD5/hdA ZheqcSrjpftije+njW4OG1VXKevAG2gzcVlYuo43k/9bWnJdQKH0BfylUR+oYCGDn1db VvGyuhDcMVOHYeBZj0N2a7+2Nj4ka/ITcgNS6q5KdCaDujJqPDQjC/naLY0GE93wxtzt uBWW+gVugaRJDIHiTtYMLM32sU2wiU9xaDCcNxyhlWYcdrWqmFrh2DSopopsABSmQiOB qmA22ARKo59WFhVcfGPLutjr/m0Lohhaum8QCdwDd7/Rs7tT2LoQkrArXyqLoZw/dXEG hRVg== 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=QDVI97M1MbDAEoOSkW/4daMpJaZPT2gcOEAKMc+Rf7E=; b=ZirfxD8vfxvoXHpwaZTCJM9NKaso9Tda8io+AhwN8E3x3pw4NXUbUk95ctt3ZirC79 2oVHiiUUNUqSoyUxl5aRcQ/fyYwBoku9ElvXNSg0i0ox3a0iGd9kmypOh2ULosbHc9Bf qsENCU3/HRxMxf3p1Gp6Eg2BTdDr/2fYbYi8qRxuRluQoAgAEpCtgtZnSslIt5BOS0Ef ZRATiPOn9Eya3zvufvdlcvWuU5CFtTAEULapwZaRx4blaTaPDUHLRicL9DbzrHessfyg b3zRY1pPzeUjB5++Rm3D5LX1fUf54Yr4q417kiBT/NyM7QqT3NZLLZzAGiHC+hMRYlOf AJ/g== 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 j16-20020a50ed10000000b004f0f197861bsi8590031eds.310.2023.04.09.07.10.02; Sun, 09 Apr 2023 07:10:02 -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 F233968BAEC; Sun, 9 Apr 2023 17:09:22 +0300 (EEST) 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 F07E768BBCC for ; Sun, 9 Apr 2023 17:09:17 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id A84FB2406CE for ; Sun, 9 Apr 2023 16:09:15 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id TFvqgfASrpmz for ; Sun, 9 Apr 2023 16:09:15 +0200 (CEST) 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 67FAE2406CF for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 583053A038E for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Apr 2023 16:08:38 +0200 Message-Id: <20230409140853.28858-14-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230409140853.28858-1-anton@khirnov.net> References: <20230409140853.28858-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 14/29] fftools/ffmpeg: rewrite printing the final output sizes 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: TvEeCL0cqLts Current code in print_final_stats(), printing the final summary such as video:8851kB audio:548kB subtitle:0kB other streams:0kB global headers:20kB muxing overhead: 0.559521% was written with a single output file in mind and makes very little sense otherwise. Print this information in mux_final_stats() instead, one line per output file. Use the correct filesize, if available. --- fftools/ffmpeg.c | 37 ++----------------------------------- fftools/ffmpeg_mux.c | 36 +++++++++++++++++++++++++++++++++--- 2 files changed, 35 insertions(+), 38 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index e1748114b3..0a2dc85629 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -738,43 +738,10 @@ static int reap_filters(int flush) return 0; } -static void print_final_stats(int64_t total_size) +static void print_final_stats(void) { - uint64_t video_size = 0, audio_size = 0, extra_size = 0, other_size = 0; - uint64_t subtitle_size = 0; - uint64_t data_size = 0; - float percent = -1.0; int i, j; - for (OutputStream *ost = ost_iter(NULL); ost; ost = ost_iter(ost)) { - AVCodecParameters *par = ost->st->codecpar; - const uint64_t s = ost->data_size_mux; - - switch (par->codec_type) { - case AVMEDIA_TYPE_VIDEO: video_size += s; break; - case AVMEDIA_TYPE_AUDIO: audio_size += s; break; - case AVMEDIA_TYPE_SUBTITLE: subtitle_size += s; break; - default: other_size += s; break; - } - extra_size += par->extradata_size; - data_size += s; - } - - if (data_size && total_size>0 && total_size >= data_size) - percent = 100.0 * (total_size - data_size) / data_size; - - av_log(NULL, AV_LOG_INFO, "video:%1.0fkB audio:%1.0fkB subtitle:%1.0fkB other streams:%1.0fkB global headers:%1.0fkB muxing overhead: ", - video_size / 1024.0, - audio_size / 1024.0, - subtitle_size / 1024.0, - other_size / 1024.0, - extra_size / 1024.0); - if (percent >= 0.0) - av_log(NULL, AV_LOG_INFO, "%f%%", percent); - else - av_log(NULL, AV_LOG_INFO, "unknown"); - av_log(NULL, AV_LOG_INFO, "\n"); - /* print verbose per-stream stats */ for (i = 0; i < nb_input_files; i++) { InputFile *f = input_files[i]; @@ -1005,7 +972,7 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti first_report = 0; if (is_last_report) - print_final_stats(total_size); + print_final_stats(); } int ifilter_parameters_from_codecpar(InputFilter *ifilter, AVCodecParameters *par) diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 441f1cd3a7..01a11117a9 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -641,15 +641,30 @@ static void mux_final_stats(Muxer *mux) { OutputFile *of = &mux->of; uint64_t total_packets = 0, total_size = 0; + uint64_t video_size = 0, audio_size = 0, subtitle_size = 0, + extra_size = 0, other_size = 0; + + uint8_t overhead[16] = "unknown"; + int64_t file_size = of_filesize(of); av_log(of, AV_LOG_VERBOSE, "Output file #%d (%s):\n", of->index, of->url); for (int j = 0; j < of->nb_streams; j++) { OutputStream *ost = of->streams[j]; - enum AVMediaType type = ost->st->codecpar->codec_type; + const AVCodecParameters *par = ost->st->codecpar; + const enum AVMediaType type = par->codec_type; + const uint64_t s = ost->data_size_mux; + + switch (type) { + case AVMEDIA_TYPE_VIDEO: video_size += s; break; + case AVMEDIA_TYPE_AUDIO: audio_size += s; break; + case AVMEDIA_TYPE_SUBTITLE: subtitle_size += s; break; + default: other_size += s; break; + } - total_size += ost->data_size_mux; + extra_size += par->extradata_size; + total_size += s; total_packets += atomic_load(&ost->packets_written); av_log(of, AV_LOG_VERBOSE, " Output stream #%d:%d (%s): ", @@ -663,13 +678,28 @@ static void mux_final_stats(Muxer *mux) } av_log(of, AV_LOG_VERBOSE, "%"PRIu64" packets muxed (%"PRIu64" bytes); ", - atomic_load(&ost->packets_written), ost->data_size_mux); + atomic_load(&ost->packets_written), s); av_log(of, AV_LOG_VERBOSE, "\n"); } av_log(of, AV_LOG_VERBOSE, " Total: %"PRIu64" packets (%"PRIu64" bytes) muxed\n", total_packets, total_size); + + if (total_size && file_size > 0 && file_size >= total_size) { + snprintf(overhead, sizeof(overhead), "%f%%", + 100.0 * (file_size - total_size) / total_size); + } + + av_log(of, AV_LOG_INFO, + "video:%1.0fkB audio:%1.0fkB subtitle:%1.0fkB other streams:%1.0fkB " + "global headers:%1.0fkB muxing overhead: %s\n", + video_size / 1024.0, + audio_size / 1024.0, + subtitle_size / 1024.0, + other_size / 1024.0, + extra_size / 1024.0, + overhead); } int of_write_trailer(OutputFile *of) From patchwork Sun Apr 9 14:08:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41050 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1591072pzb; Sun, 9 Apr 2023 07:10:11 -0700 (PDT) X-Google-Smtp-Source: AKy350YkeE/K4BQXCr7QCr6iIvaQ5kjGCCyu7gPdPKPA2tO9ynlC/tmEgIamnNi1CULQ1rYQB4A2 X-Received: by 2002:a17:907:a587:b0:94a:7d39:911b with SMTP id vs7-20020a170907a58700b0094a7d39911bmr925007ejc.74.1681049411561; Sun, 09 Apr 2023 07:10:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681049411; cv=none; d=google.com; s=arc-20160816; b=yvFGkfE+s+B64ZZwCBt/iwHNV3L/s1Qb4+QM9X+RmOoPSTJLFLQm8KCGVMfUIaoga1 c1wVdlznVOT5BmLKtcCQllWKT/tHxrwJ2FboJnNMVZJIfXm+jNucVWrxtYdXRrJlNpM+ E45iIchB+I7s8KLGDil5X+0T/yH1cyXuKtXRL8docA7KRLBJyd99jy0wxPQrkQNO/156 GV52QEULE72MmrHtTQ3uR0pN6JF1EeW22lQOiHsF8alLFdbj9ud3Mq7DVqIzW8YsyUVD pALXV/fGD8VoCbAXYBNoGEZWyo2HpSfj+vH7naBjrOPQEoAHfEHlMv7ucCHjBvYqUIzp daxQ== 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=UaP7RXHxSAUVyI5lFyX4tpup7w5BAIdlNE3KMGZiQlU=; b=vLj3VGYLpa7rxXWa6TvpSRodldJOFsomzI+Ak2N8dJk0dQPPDaiJUKl3ycB7s8Z97V JoEma2y1YiZtOLCS8/N0CP74wHI4iwSbWAKelNfVmTjJQcazH3Irb5dXYxSM1lviyOIM U33qmQRQ6O515O6AJjDUrNN80hh62dQINH5Djbtv1q2vt3AzdT3jMQHtT9cwlyV4gyB9 Js5Mx3rgvy13tSD3PfUDSiSqQnvsP0WzN+1Y06IISSwVqn+Y2Xv/XeXHBJIjJLY700+C r101vpQWTUZU3rbLA0XMz2RSzXwKLmmqLNZTUcWE/ejmQnbpdZCIeQ2SMbkCxAw04fHP ck3Q== 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 v3-20020a1709061dc300b00931b174e776si3524607ejh.705.2023.04.09.07.10.11; Sun, 09 Apr 2023 07:10:11 -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 1912B68A6B5; Sun, 9 Apr 2023 17:09:24 +0300 (EEST) 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 1377668BBDD for ; Sun, 9 Apr 2023 17:09:18 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id DDEB72406CF for ; Sun, 9 Apr 2023 16:09:15 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id sVOk46aC5Ahj for ; Sun, 9 Apr 2023 16:09:15 +0200 (CEST) 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 7244B2406D0 for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 63A8B3A039B for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Apr 2023 16:08:39 +0200 Message-Id: <20230409140853.28858-15-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230409140853.28858-1-anton@khirnov.net> References: <20230409140853.28858-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 15/29] fftools/ffmpeg_mux: make data_size_mux private to ffmpeg_mux 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: Gliw99MzHzni It is no longer used outside of this file. --- fftools/ffmpeg.h | 2 -- fftools/ffmpeg_mux.c | 5 +++-- fftools/ffmpeg_mux.h | 3 +++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index ddfeeabf75..bbcbf1aa80 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -649,8 +649,6 @@ typedef struct OutputStream { int keep_pix_fmt; /* stats */ - // combined size of all the packets sent to the muxer - uint64_t data_size_mux; // combined size of all the packets received from the encoder uint64_t data_size_enc; // number of packets send to the muxer diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 01a11117a9..b316925115 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -128,7 +128,7 @@ static int write_packet(Muxer *mux, OutputStream *ost, AVPacket *pkt) } ms->last_mux_dts = pkt->dts; - ost->data_size_mux += pkt->size; + ms->data_size_mux += pkt->size; frame_num = atomic_fetch_add(&ost->packets_written, 1); pkt->stream_index = ost->index; @@ -652,9 +652,10 @@ static void mux_final_stats(Muxer *mux) for (int j = 0; j < of->nb_streams; j++) { OutputStream *ost = of->streams[j]; + MuxStream *ms = ms_from_ost(ost); const AVCodecParameters *par = ost->st->codecpar; const enum AVMediaType type = par->codec_type; - const uint64_t s = ost->data_size_mux; + const uint64_t s = ms->data_size_mux; switch (type) { case AVMEDIA_TYPE_VIDEO: video_size += s; break; diff --git a/fftools/ffmpeg_mux.h b/fftools/ffmpeg_mux.h index c76dc2e524..3fab74b2ed 100644 --- a/fftools/ffmpeg_mux.h +++ b/fftools/ffmpeg_mux.h @@ -63,6 +63,9 @@ typedef struct MuxStream { /* dts of the last packet sent to the muxer, in the stream timebase * used for making up missing dts values */ int64_t last_mux_dts; + + // combined size of all the packets sent to the muxer + uint64_t data_size_mux; } MuxStream; typedef struct Muxer { From patchwork Sun Apr 9 14:08:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41052 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1591260pzb; Sun, 9 Apr 2023 07:10:29 -0700 (PDT) X-Google-Smtp-Source: AKy350ZTNw6UnBx1kzzqllHZYggGZAc3120nttL/kY6p0Z/dGt3tcq/eTVTdSFDj9jOnI/vj3EYe X-Received: by 2002:a05:6402:c5:b0:504:923f:e657 with SMTP id i5-20020a05640200c500b00504923fe657mr3698700edu.35.1681049429016; Sun, 09 Apr 2023 07:10:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681049429; cv=none; d=google.com; s=arc-20160816; b=THSMmnIrRrVDV3LoCCMXuYRhj121nwe2nQKVqrtYtjUniiM/COgg5C6xRZcxGht5x8 CLRJRWPHRp0fxlEzGn3o7eHsG+0zWrqDc4W6MkqNfh4wC0Uusuo14PsH/sr2USq/W96j OlCSDXshPukfGSjS5pX12NQ0CkPXWfp3U6wpMGt3+/hvgqwUyKGSdS4XKG/osswQ/uoj SQzJbpyl/1GTn1Bb7MA3OIqQtN9Nu8oOrHQq4exNGsm58BlyoczBFFn64z6MNRfrFWzN VgIDXjETF0grhzP5SaS/Q4Ys+Qy9UebAenMXW4qKsbGaDhg24iXcv1qQWeLq05r3m3LH FpPQ== 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=Cy2JLxEfOS49Zii6gdOpi7HujJTSmHpOA2N/+243K7w=; b=I7VapQMJFAoL8c47r4pbQL5IRE8b6MI6tCyQiezHKIndu3Cbuw0ARuOOI8MTKneZwa NgJNLfAzC9rGJxuw63WpOAE5pf3shvdc+hnprF0jsInOOiwtCJZNkVI9auISy8WZsiBS ogp6qNLS7t7ps/X+YsejqOo+nhGYWH3Y3PLatbf8bdcBBtXq5qG5KGJ2RuPW5HhWjhFj Z95YDMaocYEhbTs0A2/XLtGeRHcwa1PctSr30cXBla/bFAIKH1eKAHmFJ85nzkwSKIad J7PTKmSuc/rLPPjmH9CLi5CN7V8YjhTB3A6uQo9v5PFylE08ZFg7aq/ccviGWHbeQOIC CuAg== 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 h15-20020aa7c94f000000b0050477df9110si5567870edt.665.2023.04.09.07.10.27; Sun, 09 Apr 2023 07:10:28 -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 D31B068BD67; Sun, 9 Apr 2023 17:09:25 +0300 (EEST) 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 3CB7068BBDD for ; Sun, 9 Apr 2023 17:09:18 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 780BF240706 for ; Sun, 9 Apr 2023 16:09:16 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id fcrxwVZsBGOf for ; Sun, 9 Apr 2023 16:09:15 +0200 (CEST) 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 7D98E240705 for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 6E6AA3A03E5 for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Apr 2023 16:08:40 +0200 Message-Id: <20230409140853.28858-16-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230409140853.28858-1-anton@khirnov.net> References: <20230409140853.28858-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 16/29] fftools/ffmpeg: move printing verbose demuxing stats to ffmpeg_demux 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: aCK2DqldhEBN This is a more appropriate place for this. --- fftools/ffmpeg.c | 43 ------------------------------------------ fftools/ffmpeg_demux.c | 38 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 43 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 0a2dc85629..02a7f20554 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -738,46 +738,6 @@ static int reap_filters(int flush) return 0; } -static void print_final_stats(void) -{ - int i, j; - - /* print verbose per-stream stats */ - for (i = 0; i < nb_input_files; i++) { - InputFile *f = input_files[i]; - uint64_t total_packets = 0, total_size = 0; - - av_log(NULL, AV_LOG_VERBOSE, "Input file #%d (%s):\n", - i, f->ctx->url); - - for (j = 0; j < f->nb_streams; j++) { - InputStream *ist = f->streams[j]; - enum AVMediaType type = ist->par->codec_type; - - total_size += ist->data_size; - total_packets += ist->nb_packets; - - av_log(NULL, AV_LOG_VERBOSE, " Input stream #%d:%d (%s): ", - i, j, av_get_media_type_string(type)); - av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" packets read (%"PRIu64" bytes); ", - ist->nb_packets, ist->data_size); - - if (ist->decoding_needed) { - av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" frames decoded", - ist->frames_decoded); - if (type == AVMEDIA_TYPE_AUDIO) - av_log(NULL, AV_LOG_VERBOSE, " (%"PRIu64" samples)", ist->samples_decoded); - av_log(NULL, AV_LOG_VERBOSE, "; "); - } - - av_log(NULL, AV_LOG_VERBOSE, "\n"); - } - - av_log(NULL, AV_LOG_VERBOSE, " Total: %"PRIu64" packets (%"PRIu64" bytes) demuxed\n", - total_packets, total_size); - } -} - static void print_report(int is_last_report, int64_t timer_start, int64_t cur_time) { AVBPrint buf, buf_script; @@ -970,9 +930,6 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti } first_report = 0; - - if (is_last_report) - print_final_stats(); } int ifilter_parameters_from_codecpar(InputFilter *ifilter, AVCodecParameters *par) diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index 354d3165c9..8fafbc3354 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -480,6 +480,41 @@ int ifile_get_packet(InputFile *f, AVPacket **pkt) return 0; } +static void demux_final_stats(Demuxer *d) +{ + InputFile *f = &d->f; + uint64_t total_packets = 0, total_size = 0; + + av_log(NULL, AV_LOG_VERBOSE, "Input file #%d (%s):\n", + f->index, f->ctx->url); + + for (int j = 0; j < f->nb_streams; j++) { + InputStream *ist = f->streams[j]; + enum AVMediaType type = ist->par->codec_type; + + total_size += ist->data_size; + total_packets += ist->nb_packets; + + av_log(NULL, AV_LOG_VERBOSE, " Input stream #%d:%d (%s): ", + f->index, j, av_get_media_type_string(type)); + av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" packets read (%"PRIu64" bytes); ", + ist->nb_packets, ist->data_size); + + if (ist->decoding_needed) { + av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" frames decoded", + ist->frames_decoded); + if (type == AVMEDIA_TYPE_AUDIO) + av_log(NULL, AV_LOG_VERBOSE, " (%"PRIu64" samples)", ist->samples_decoded); + av_log(NULL, AV_LOG_VERBOSE, "; "); + } + + av_log(NULL, AV_LOG_VERBOSE, "\n"); + } + + av_log(NULL, AV_LOG_VERBOSE, " Total: %"PRIu64" packets (%"PRIu64" bytes) demuxed\n", + total_packets, total_size); +} + static void ist_free(InputStream **pist) { InputStream *ist = *pist; @@ -512,6 +547,9 @@ void ifile_close(InputFile **pf) thread_stop(d); + if (f->ctx) + demux_final_stats(d); + for (int i = 0; i < f->nb_streams; i++) ist_free(&f->streams[i]); av_freep(&f->streams); From patchwork Sun Apr 9 14:08:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41051 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1591142pzb; Sun, 9 Apr 2023 07:10:19 -0700 (PDT) X-Google-Smtp-Source: AKy350YkOfMHgovFRwdsWv+RiKKcyDwlM4X45XcZp8k6Z4kjzsadkqtsULRiNjOrIuTLLchjDC1y X-Received: by 2002:a05:6402:38c:b0:4f9:db7b:b6b4 with SMTP id o12-20020a056402038c00b004f9db7bb6b4mr6279808edv.40.1681049419757; Sun, 09 Apr 2023 07:10:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681049419; cv=none; d=google.com; s=arc-20160816; b=yaOVRtsnfCjyzNJzuj4XTssE3Fmp2GSSeR/NdMPiJD1ptin9HK4jqohT0c6Mh9cNCM Sw1VS8tVaiW0MtK4ajGkv6IgRYCmsK4aEwrNoUhgOoz7CPMhWFB+zUFCn7htuyb4S9qV 6OX630zkzVXhjFMbeXROkxJPuSltNUJnZgRpk5p0mjGEalSUxj5aKXV6+rK1U9WOhxGy Ovpio663hIJFOCuzKAMda1HlpHmgaxnSuGmNUjs9vQ9naSmT0Qu+xFYp7LjVaE/1BQtG 6QApbXn3PvRklq4envNQDJuOOxge3HRG4laLqZsIr4IoHw6Fju7775XvlPKnili0y5Zg KEFw== 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=d/xzx/ups34+1pmsnGNtLzTxCGnbZvoeC35x7Fj8EMk=; b=ZXDIiR2G4AlTyJEJmwHzkC1lI3zH5gX4ywLyWCGmsZiQWKTraPliRAsj5VPzqHDiHa DpxjgS6wOKwYD0a5cm+TcViVZcL6K/SUxCeGqD+x2Ds3zuYaHW487lkns7T9D2v+ujJo 9Z/Qq8pYIZzEXNjoRhSPfZGXoZpcZOtWlWf3N+x2dw8sAGbvlUoCsjF3fHF2o5/dC4zh Ouy9b2Memug/3S4rtiXLLyRqPVSsqJRKvGtaJVQ8BunBxN3NYBf5gRqfH94fY3nH6Fv4 VulNfVvglePPjqIDOKLilCJ3KvN5CieweFjahFhPbebPzYuToktdf43Uiv9broJaAmqX +r5Q== 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 k3-20020aa7c383000000b005002ebedfc7si3135507edq.403.2023.04.09.07.10.19; Sun, 09 Apr 2023 07:10:19 -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 EE36B68BD8B; Sun, 9 Apr 2023 17:09:24 +0300 (EEST) 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 3144F68BBEE for ; Sun, 9 Apr 2023 17:09:18 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 35D342406D0 for ; Sun, 9 Apr 2023 16:09:16 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id jY6_DXw44WPN for ; Sun, 9 Apr 2023 16:09:15 +0200 (CEST) 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 89420240706 for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 7964A3A038E for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Apr 2023 16:08:41 +0200 Message-Id: <20230409140853.28858-17-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230409140853.28858-1-anton@khirnov.net> References: <20230409140853.28858-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 17/29] fftools/ffmpeg_demux: reindent 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: 7hsah7jK2r3O --- fftools/ffmpeg_demux.c | 52 +++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index 8fafbc3354..a2bfd0ab95 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -482,37 +482,37 @@ int ifile_get_packet(InputFile *f, AVPacket **pkt) static void demux_final_stats(Demuxer *d) { - InputFile *f = &d->f; - uint64_t total_packets = 0, total_size = 0; + InputFile *f = &d->f; + uint64_t total_packets = 0, total_size = 0; - av_log(NULL, AV_LOG_VERBOSE, "Input file #%d (%s):\n", - f->index, f->ctx->url); + av_log(NULL, AV_LOG_VERBOSE, "Input file #%d (%s):\n", + f->index, f->ctx->url); - for (int j = 0; j < f->nb_streams; j++) { - InputStream *ist = f->streams[j]; - enum AVMediaType type = ist->par->codec_type; - - total_size += ist->data_size; - total_packets += ist->nb_packets; - - av_log(NULL, AV_LOG_VERBOSE, " Input stream #%d:%d (%s): ", - f->index, j, av_get_media_type_string(type)); - av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" packets read (%"PRIu64" bytes); ", - ist->nb_packets, ist->data_size); - - if (ist->decoding_needed) { - av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" frames decoded", - ist->frames_decoded); - if (type == AVMEDIA_TYPE_AUDIO) - av_log(NULL, AV_LOG_VERBOSE, " (%"PRIu64" samples)", ist->samples_decoded); - av_log(NULL, AV_LOG_VERBOSE, "; "); - } + for (int j = 0; j < f->nb_streams; j++) { + InputStream *ist = f->streams[j]; + enum AVMediaType type = ist->par->codec_type; + + total_size += ist->data_size; + total_packets += ist->nb_packets; - av_log(NULL, AV_LOG_VERBOSE, "\n"); + av_log(NULL, AV_LOG_VERBOSE, " Input stream #%d:%d (%s): ", + f->index, j, av_get_media_type_string(type)); + av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" packets read (%"PRIu64" bytes); ", + ist->nb_packets, ist->data_size); + + if (ist->decoding_needed) { + av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" frames decoded", + ist->frames_decoded); + if (type == AVMEDIA_TYPE_AUDIO) + av_log(NULL, AV_LOG_VERBOSE, " (%"PRIu64" samples)", ist->samples_decoded); + av_log(NULL, AV_LOG_VERBOSE, "; "); } - av_log(NULL, AV_LOG_VERBOSE, " Total: %"PRIu64" packets (%"PRIu64" bytes) demuxed\n", - total_packets, total_size); + av_log(NULL, AV_LOG_VERBOSE, "\n"); + } + + av_log(NULL, AV_LOG_VERBOSE, " Total: %"PRIu64" packets (%"PRIu64" bytes) demuxed\n", + total_packets, total_size); } static void ist_free(InputStream **pist) From patchwork Sun Apr 9 14:08:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41054 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1591396pzb; Sun, 9 Apr 2023 07:10:45 -0700 (PDT) X-Google-Smtp-Source: AKy350Yx9pZibERvh/AfA82sdwl3bmEVzzsB8vjvEJGDNkvIJ0rfJCCRIzO0dO1gm50s5rh4B38t X-Received: by 2002:a17:907:7e95:b0:94a:88aa:93b3 with SMTP id qb21-20020a1709077e9500b0094a88aa93b3mr478138ejc.44.1681049444835; Sun, 09 Apr 2023 07:10:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681049444; cv=none; d=google.com; s=arc-20160816; b=BSZDkzKmK+6fzl5E8u/jILWuiTRbl8LYXja9Ts16N+tFGSnUvMMmKwXgaWb91RcFAB U73SCPNnDGO7hdv0VJOiCWGvT+EHcBgXHMmn4ujYSQJAW+Hf/4OCxJ6FV7uPgNml5T5D L43d326fNRGdJMRwc9VITcaeO1atH0rSXVzvB/5lmHqq7UuQaCxCJzUGMmh0SYvwhlto NG7hW47u0d9FqxkLDOs1KWiOzvFfZkhi68ViH2wturxZRn0QvnM5WXFD4NvI/nBrU1qo wn5dI+j4NgZ7KxDZORQpzTQkZr7TEcRtHLx7mAsxEdrqSU8LEwasIurMS0re0erBmnjh hkOQ== 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=n2LMfcpOH9oezO4x4+9K3y3eLux/i8CGMiwye7XYYuk=; b=AddDijbxDzfN9qJxth+Addu9XYavTTWn6amfqSPqS1BknV4XHLJYbpFiH0DlCoD1g0 swJIGgze8ftC826b2AVxlIFo/1zF2whiUen6Fs2VafB/4GRjZd+OsKx4ZZLopv3hi9o4 1Fq+7zoaImKYyRv+baGSlY5hk92TqrAiI7fPLFwEwyqSV4fB2DrJaO9/WTVv9488m4q6 fiV9fqZStjlH5gKJDk0nmS4GSY3etoV5YwcY0pXYJBZkj0ZP1eyLP2zPgnWby5na/rbo 8pgcLfRLp9unRrOlwaTdOBXm2+lAWPAaWxw3RCPQ1ZZ5jX1cXp/Oz6G0xzFsr73AmqXZ Y4Bw== 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 o10-20020a056402038a00b00504a27c35cbsi397562edv.313.2023.04.09.07.10.44; Sun, 09 Apr 2023 07:10:44 -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 C071168BE02; Sun, 9 Apr 2023 17:09:27 +0300 (EEST) 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 589D968BB8E for ; Sun, 9 Apr 2023 17:09:18 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 0CC81240705 for ; Sun, 9 Apr 2023 16:09:17 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id iVc8fdaYyIR3 for ; Sun, 9 Apr 2023 16:09:16 +0200 (CEST) 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 976E2240D03 for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 852253A039B for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Apr 2023 16:08:42 +0200 Message-Id: <20230409140853.28858-18-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230409140853.28858-1-anton@khirnov.net> References: <20230409140853.28858-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 18/29] fftools/ffmpeg_demux: log final stats to demuxer context 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: kHfahiq0aFNU --- fftools/ffmpeg_demux.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index a2bfd0ab95..93eed28809 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -485,7 +485,7 @@ static void demux_final_stats(Demuxer *d) InputFile *f = &d->f; uint64_t total_packets = 0, total_size = 0; - av_log(NULL, AV_LOG_VERBOSE, "Input file #%d (%s):\n", + av_log(f, AV_LOG_VERBOSE, "Input file #%d (%s):\n", f->index, f->ctx->url); for (int j = 0; j < f->nb_streams; j++) { @@ -495,23 +495,23 @@ static void demux_final_stats(Demuxer *d) total_size += ist->data_size; total_packets += ist->nb_packets; - av_log(NULL, AV_LOG_VERBOSE, " Input stream #%d:%d (%s): ", + av_log(f, AV_LOG_VERBOSE, " Input stream #%d:%d (%s): ", f->index, j, av_get_media_type_string(type)); - av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" packets read (%"PRIu64" bytes); ", + av_log(f, AV_LOG_VERBOSE, "%"PRIu64" packets read (%"PRIu64" bytes); ", ist->nb_packets, ist->data_size); if (ist->decoding_needed) { - av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" frames decoded", + av_log(f, AV_LOG_VERBOSE, "%"PRIu64" frames decoded", ist->frames_decoded); if (type == AVMEDIA_TYPE_AUDIO) - av_log(NULL, AV_LOG_VERBOSE, " (%"PRIu64" samples)", ist->samples_decoded); - av_log(NULL, AV_LOG_VERBOSE, "; "); + av_log(f, AV_LOG_VERBOSE, " (%"PRIu64" samples)", ist->samples_decoded); + av_log(f, AV_LOG_VERBOSE, "; "); } - av_log(NULL, AV_LOG_VERBOSE, "\n"); + av_log(f, AV_LOG_VERBOSE, "\n"); } - av_log(NULL, AV_LOG_VERBOSE, " Total: %"PRIu64" packets (%"PRIu64" bytes) demuxed\n", + av_log(f, AV_LOG_VERBOSE, " Total: %"PRIu64" packets (%"PRIu64" bytes) demuxed\n", total_packets, total_size); } From patchwork Sun Apr 9 14:08:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41053 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1591311pzb; Sun, 9 Apr 2023 07:10:36 -0700 (PDT) X-Google-Smtp-Source: AKy350ZL2me8JeFITX+PisFYh4DF80NIIE/jAkv04UBvjFscvOJBtua9BGwrk07ahAGs9HsyouKc X-Received: by 2002:a17:907:171e:b0:94a:5625:c29c with SMTP id le30-20020a170907171e00b0094a5625c29cmr2788220ejc.53.1681049436603; Sun, 09 Apr 2023 07:10:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681049436; cv=none; d=google.com; s=arc-20160816; b=XoJZpCYCzBKMgZl+7DDJqvBRMI+YhNv2xyGh7RPbSXrZdzDyFY2DlMxFDwVO3IsR39 1qlLFMyfimqS2BC+DLLo5Rwigvyg2x+RBTC4i1bm9fRoIy4pYuUcxBt2BZAKzUBU9cAU 3PUs2AMr/EdwsY7P+ndlvfeDHih4usbyeeZeG5waGv4twZuKnFL7WHA2UIYiOQQTHkRW fyGHWzmHQ3V/mYVrm3MfzhOx+iptH1PHsMpAGMoZOWudmG3d2PO+lnkIyAiBSqXaf0XA Gt29t0BLUIQkMC3a/ATWDUgzmAoNZ2RIE+ea/2ykzgqIXTrzXjJUqQ3/2kYKW3CNGv7A m/eA== 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=rsa0qxOSvdTk2DG3YgeM1x5q+aB27DXzAn7yIEFbvt4=; b=z7ZVW9zNGHDdtgSdMA/hOjwhneUqc95VCLJQQPzGdlSJEQELSj/lgNhRWerg/FzR17 0TfhFzZstGiRx0y1v2NQhYMhkuwLKHdPME+ByUk7BdGmZ6QjYEkm/e0ybcMx6Wb7CUlf MTSEJJDBkc6+J0eZpgcFGqZsVN+27/4eceYdlRjThhvVcEql7x2mGOTi+MKCBNj9zNs4 rbjYlKfTghNQuFtdGQAKsBEE9IapC58cl3B34P8cH/SmFzgtBqlkMAsVDvtYO/YboHZ+ TRKcYDdbpGQ8Mz3e7zXFc80jL/XRymvS1JqRHNI+m2qvpg4NyCDPeuZGepIcPMLOiZa9 /Qxw== 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 ck7-20020a170906c44700b0094a78827f1dsi938557ejb.447.2023.04.09.07.10.36; Sun, 09 Apr 2023 07:10:36 -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 D5C9068BA58; Sun, 9 Apr 2023 17:09:26 +0300 (EEST) 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 5041F68BBFD for ; Sun, 9 Apr 2023 17:09:18 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id DBFFF2404F8 for ; Sun, 9 Apr 2023 16:09:16 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id TXkXFY3pBLA8 for ; Sun, 9 Apr 2023 16:09:16 +0200 (CEST) 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 A5BB4240D0E for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 90FBC3A038E for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Apr 2023 16:08:43 +0200 Message-Id: <20230409140853.28858-19-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230409140853.28858-1-anton@khirnov.net> References: <20230409140853.28858-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 19/29] fftools/ffmpeg: disable and deprecate -qphist 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: kkl9PvsLa8Tu This option adds a long string of numbers to the progress line, where i-th number contains the base-2 logarithm of the number of times a frame with this QP value was seen by print_report(). There are multiple problems with this feature: * despite this existing since 2005, web search shows no indication that it was ever useful for any meaningful purpose; * the format of what is printed is entirely undocumented, one has to find it out from the source code; * QP values above 31 are silently ignored; * it only works with one video stream; * as it relies on global state, it is in conflict with ongoing architectural changes. It then seems that the nontrivial cost of maintaining this option is not worth its negligible (or possibly negative - since it pollutes the already large option space) value. Users who really need similar functionality can also implement it themselves using -vstats. --- doc/ffmpeg.texi | 2 -- fftools/ffmpeg.c | 10 ---------- fftools/ffmpeg.h | 2 +- fftools/ffmpeg_opt.c | 15 ++++++++++++--- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index d433d60ce9..cb8aa13df2 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -1051,8 +1051,6 @@ Specify which version of the vstats format to use. Default is @code{2}. See the top=1/bottom=0/auto=-1 field first @item -vtag @var{fourcc/tag} (@emph{output}) Force video tag/fourcc. This is an alias for @code{-tag:v}. -@item -qphist (@emph{global}) -Show QP histogram @item -vbsf @var{bitstream_filter} Deprecated see -bsf diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 02a7f20554..74aba28a9b 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -748,7 +748,6 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti int64_t pts = INT64_MIN + 1; static int64_t last_time = -1; static int first_report = 1; - static int qp_histogram[52]; int hours, mins, secs, us; const char *hours_sign; int ret; @@ -794,14 +793,6 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti ost->file_index, ost->index, q); if (is_last_report) av_bprintf(&buf, "L"); - if (qp_hist) { - int j; - int qp = lrintf(q); - if (qp >= 0 && qp < FF_ARRAY_ELEMS(qp_histogram)) - qp_histogram[qp]++; - for (j = 0; j < 32; j++) - av_bprintf(&buf, "%X", av_log2(qp_histogram[j] + 1)); - } if (enc && (enc->flags & AV_CODEC_FLAG_PSNR) && (ost->pict_type != AV_PICTURE_TYPE_NONE || is_last_report)) { @@ -2321,7 +2312,6 @@ static int check_keyboard_interaction(int64_t cur_time) } if (key == '+') av_log_set_level(av_log_get_level()+10); if (key == '-') av_log_set_level(av_log_get_level()-10); - if (key == 's') qp_hist ^= 1; if (key == 'c' || key == 'C'){ char buf[4096], target[64], command[256], arg[256] = {0}; double time; diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index bbcbf1aa80..80a1192ed0 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -54,6 +54,7 @@ #define FFMPEG_OPT_MAP_CHANNEL 1 #define FFMPEG_OPT_MAP_SYNC 1 #define FFMPEG_ROTATION_METADATA 1 +#define FFMPEG_OPT_QPHIST 1 enum VideoSyncMethod { VSYNC_AUTO = -1, @@ -738,7 +739,6 @@ extern int exit_on_error; extern int abort_on_flags; extern int print_stats; extern int64_t stats_period; -extern int qp_hist; extern int stdin_interaction; extern AVIOContext *progress_avio; extern float max_error_rate; diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 055275d813..aa9aa0e9b4 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -80,7 +80,6 @@ int debug_ts = 0; int exit_on_error = 0; int abort_on_flags = 0; int print_stats = -1; -int qp_hist = 0; int stdin_interaction = 1; float max_error_rate = 2.0/3; char *filter_nbthreads; @@ -1344,6 +1343,14 @@ int opt_timelimit(void *optctx, const char *opt, const char *arg) return 0; } +#if FFMPEG_OPT_QPHIST +static int opt_qphist(void *optctx, const char *opt, const char *arg) +{ + av_log(NULL, AV_LOG_WARNING, "Option -%s is deprecated and has no effect\n", opt); + return 0; +} +#endif + #define OFFSET(x) offsetof(OptionsContext, x) const OptionDef options[] = { /* main options */ @@ -1627,8 +1634,10 @@ const OptionDef options[] = { { "vtag", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_PERFILE | OPT_INPUT | OPT_OUTPUT, { .func_arg = opt_old2new }, "force video tag/fourcc", "fourcc/tag" }, - { "qphist", OPT_VIDEO | OPT_BOOL | OPT_EXPERT , { &qp_hist }, - "show QP histogram" }, +#if FFMPEG_OPT_QPHIST + { "qphist", OPT_VIDEO | OPT_EXPERT , { .func_arg = opt_qphist }, + "deprecated, does nothing" }, +#endif { "fps_mode", OPT_VIDEO | HAS_ARG | OPT_STRING | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(fps_mode) }, "set framerate mode for matching video streams; overrides vsync" }, From patchwork Sun Apr 9 14:08:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41055 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1591491pzb; Sun, 9 Apr 2023 07:10:53 -0700 (PDT) X-Google-Smtp-Source: AKy350bO4AoHf9yxGgd8C0sMA9FIt/QBIFCKcUpKwvR0EdQQlP8jO45GBOfWSJCzw9AAme6J5738 X-Received: by 2002:a17:907:628c:b0:94a:5602:5d6a with SMTP id nd12-20020a170907628c00b0094a56025d6amr3827362ejc.9.1681049453607; Sun, 09 Apr 2023 07:10:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681049453; cv=none; d=google.com; s=arc-20160816; b=qpADKTvMao5DMfOPfaXfcAHHvms4p6bM0G89hz5BPsIA5J4OvSHGUtAnh1QfRGNKgu OeEcYcLvWmV1qQO93pDA/gntXpEBU9dkaR6tAlY7GP41lj5SEozfWjkPG5g944sTg27j XeHAlU3/jQo5sOvUBQKqibm/QSa94NuIbfF2TsAP+jIoPU8BHVq5i1bjKE237WrGeOeV vdqpLgch5/upX3kQXNgyvwUCD5Rznk9G0/VT9XwauT7gBpBd3jsEcEfBUhCGHr32t8VX hNBgvNBKgUST2TjyujCzvKpW5b2A6SXAA1/K1e/MfG8zVNSUr7Nhbe9t56B5wilB9Bxb PxVA== 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=v0unYxpyAqCCRNXUjthbWkPmL5RN891WdGvT3fUzig8=; b=ncVWZy8wTZ64GvbXdKEJI4MbZcAPbFsfXAv/wl6zEmEUXcA4RpUNIZelk42UF5dLD4 FaF3oHFsmohHgq/NFS2CNITmMcdHpb/8Er+fjtdZA81fRobTo8Y7gynnZQgclNTA6HV2 Cs2NpKZcHWaW0E57v2h5gcCmZ5RBbQ1/Z+tpMOHW2R/zKaiSI7Z/ip6uI3LMiGrEbvme X0rPXXxNExVzROfsOI68j9M7cmCsffDlqQfTkebllLQAkvmKBeblgOBqSJ9sQl96QNDp YJxZ/AieSTp1uo0xtUbNeEOaV4PNHv7GWYZ5rFolFd19S+n/r2hDcdWA2RWy2FISwKw+ fqoQ== 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 vh8-20020a170907d38800b0094a8a803c1esi214159ejc.727.2023.04.09.07.10.53; Sun, 09 Apr 2023 07:10:53 -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 95FC168BCE9; Sun, 9 Apr 2023 17:09:28 +0300 (EEST) 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 67BB368BC29 for ; Sun, 9 Apr 2023 17:09:18 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 6282F2404EC for ; Sun, 9 Apr 2023 16:09:17 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id TEkDoDFjN1Xe for ; Sun, 9 Apr 2023 16:09:16 +0200 (CEST) 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 AB749240D1A for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 9C47B3A03E5 for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Apr 2023 16:08:44 +0200 Message-Id: <20230409140853.28858-20-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230409140853.28858-1-anton@khirnov.net> References: <20230409140853.28858-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 20/29] fftools/ffmpeg_filter: stop setting encoder channel layout unnecessarily 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: bDdvjue51e0z The channel layout is set before opening the encoder, in enc_open(). Messing with it in configure_output_audio_filter() cannot accomplish anything meaningful. --- fftools/ffmpeg_filter.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index f48ae83a40..584f51ac3f 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -699,7 +699,6 @@ static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter, { OutputStream *ost = ofilter->ost; OutputFile *of = output_files[ost->file_index]; - AVCodecContext *codec = ost->enc_ctx; AVFilterContext *last_filter = out->filter_ctx; int pad_idx = out->pad_idx; AVBPrint args; @@ -750,9 +749,6 @@ static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter, } #endif - if (codec->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) - av_channel_layout_default(&codec->ch_layout, codec->ch_layout.nb_channels); - choose_sample_fmts(ofilter, &args); choose_sample_rates(ofilter, &args); choose_channel_layouts(ofilter, &args); From patchwork Sun Apr 9 14:08:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41056 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1591564pzb; Sun, 9 Apr 2023 07:11:02 -0700 (PDT) X-Google-Smtp-Source: AKy350Yc018/C+DBFFCGSotZ1ahzhdbhp5wt/Yj58HU0SADuIsedRinG1ULA/ysnaLr5No64jLwl X-Received: by 2002:a17:906:a1d8:b0:947:df9e:4082 with SMTP id bx24-20020a170906a1d800b00947df9e4082mr5236918ejb.35.1681049462153; Sun, 09 Apr 2023 07:11:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681049462; cv=none; d=google.com; s=arc-20160816; b=i1s575IfR9J4aE3HesPLBeb5J4m8/2coJuVG9SSJk2a7G9CBEQbnpYyMlUF4VJ4seR eJm/lpfidjkXJIbRt1bCIz6OKkXuVOCtvtOdns3zuvPfj76LcpCcB8A9h7lDAgGt5UsC IAXHsPoVXe9nCO00Lf97aObm5nsk6N5HTyL+mlwtBxAjMD7n0Gu7bu3zPTCHfdKNB/h2 OTvFNvIIfnVgAVzsL8y4VlMx5FiUaTuwZAACIqWAlE0rj1YpRtoo9UgnjS3128X7FJwQ VA9RgQMG50kuM4MMjKcVj4D9v+Uf8cHuy9Dx4frt7v608UCFcpmu+4ItK9QckKe0o8Oe TWuA== 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=kNUkGT3Uik3a+/3UiwkVqE7ZObXbR4+MiJE95YkElDY=; b=Ny0ieAGQi3y8GanPM6o3wcYLOXi0QS6z22SuKOVHd2KpXimtZEuOH2L25DYNfb6a7K e40DWt2EjGXGY/auWtRcrcfkKeUiYfrqC4lc9NGlJXlT4ICF2b5SaGWyBz5wTVD+1R39 l6A74YfUUWX4HA9zU74Z5JLkCcUcc3YTPAFmyFjIXWCnkOChbD09NLwLT7bPQk1IIBAz cTIZo2lXrNjIhWhIMyw1/Imi+F1+pUZ74jZ2OQw/95HBbuvGe+R2yeBtfsBKFMwMTYdi 5zKm0Hl/NNdr4CAm2pCmTQJpRoiU1xtd4VG7Y2Qusgm2rBAoJFdvinONmt5iD3j/yh0J QFXQ== 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 n2-20020a170906118200b0093c96889d25si4798948eja.407.2023.04.09.07.11.01; Sun, 09 Apr 2023 07:11:02 -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 97C3068BE1A; Sun, 9 Apr 2023 17:09:29 +0300 (EEST) 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 6E1FC68BC86 for ; Sun, 9 Apr 2023 17:09:18 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 8665D240D03 for ; Sun, 9 Apr 2023 16:09:17 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id tp8xy7k_A2dc for ; Sun, 9 Apr 2023 16:09:17 +0200 (CEST) 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 B8978240D1C for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id A74523A0404 for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Apr 2023 16:08:45 +0200 Message-Id: <20230409140853.28858-21-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230409140853.28858-1-anton@khirnov.net> References: <20230409140853.28858-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 21/29] fftools/ffmpeg_mux_init: print more meaningful error messages 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: atgj0PUu+4IO --- fftools/ffmpeg_mux_init.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 3490c99c94..4b6c704046 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -2247,7 +2247,8 @@ int of_open(const OptionsContext *o, const char *filename) err = avformat_alloc_output_context2(&oc, NULL, o->format, filename); if (!oc) { - print_error(filename, err); + av_log(mux, AV_LOG_FATAL, "Error initializing the muxer for %s: %s\n", + filename, av_err2str(err)); exit_program(1); } mux->fc = oc; @@ -2334,11 +2335,12 @@ int of_open(const OptionsContext *o, const char *filename) } /* check filename in case of an image number is expected */ - if (oc->oformat->flags & AVFMT_NEEDNUMBER) { - if (!av_filename_number_test(oc->url)) { - print_error(oc->url, AVERROR(EINVAL)); - exit_program(1); - } + if (oc->oformat->flags & AVFMT_NEEDNUMBER && !av_filename_number_test(oc->url)) { + av_log(mux, AV_LOG_FATAL, + "Output filename '%s' does not contain a numeric pattern like " + "'%%d', which is required by output format '%s'.\n", + oc->url, oc->oformat->name); + exit_program(1); } if (!(oc->oformat->flags & AVFMT_NOFILE)) { @@ -2349,7 +2351,8 @@ int of_open(const OptionsContext *o, const char *filename) if ((err = avio_open2(&oc->pb, filename, AVIO_FLAG_WRITE, &oc->interrupt_callback, &mux->opts)) < 0) { - print_error(filename, err); + av_log(mux, AV_LOG_FATAL, "Error opening output %s: %s\n", + filename, av_err2str(err)); exit_program(1); } } else if (strcmp(oc->oformat->name, "image2")==0 && !av_filename_number_test(filename)) From patchwork Sun Apr 9 14:08:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41059 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1591777pzb; Sun, 9 Apr 2023 07:11:28 -0700 (PDT) X-Google-Smtp-Source: AKy350ZXGDk83BBpupNuz3w94XSiKTxX/Eap+yoRe/Et8vy/+JjTv+MU+jaKGzztqgCF1sqkSpOZ X-Received: by 2002:aa7:d855:0:b0:504:88fb:8841 with SMTP id f21-20020aa7d855000000b0050488fb8841mr4302021eds.21.1681049488155; Sun, 09 Apr 2023 07:11:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681049488; cv=none; d=google.com; s=arc-20160816; b=Ze79TmjZUQr55aA/cp0OpIvQ19QsQYYQuuPQu8GZcVmmh01ccT6ya0nnUfa+dd5jdb EzoNS3MqVY21sDE15jZYUdzPBl9U03/7wF223Vcs3CWMFCeR7xMKu/qqqQZNkqH8WZ7Y 0dMarwO9wysYYXxPAB/jinFThqqpoCliHr1hqx7I/oJinFhj+nKxKb93V+kgRuVztn5N 7cxecqQc8a2N9p+GSktTSvnvrM2QN1n6vgkEJt9xE1WMmlf0YbjDxD227xO1+WDM4KRs 1YzX3YNDsX2llaVmjPXfHocpT9CnaXObVdD/7XuhtesQ7Km5BrwBKxuVlOn8W+Gucdcf I6og== 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=Tv5LyIdxsflvygwtNkPUyNYmBBwINUppj9V6ddsicug=; b=IwGU3pEFwh3dW6mnXQP9YU5AXsvrT+r7/0O/Km7odpKKCZp2SeUZy09OVmAsTNkKXr ap01vsDRd5k/xKEPqmn2MCdJcnz/DobtwwYRFNQk4dLups/Ts+cbTBY5WOn0g1Xnb4bV cjBfJBvp6g6U+n5Eu6iV/bYNpJAxXophnetBgoRjUb8YWqolzMd9BVFOjKOXuBk1bBJr JKZwhP2Bl+XRrBzG6v2thLHEjeNpgL48ragc4N1xao27dRcRlhsII8fh9HTf1sr5ix4O Dhl51FZ0LiZzOUksBNU7fDYAVTFjTfQSc7s8JtWOa28JSxs8+pZPoAKqM2z80OD6hVUP 9CEQ== 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 h15-20020aa7de0f000000b004fbc39bd3a9si6079791edv.318.2023.04.09.07.11.27; Sun, 09 Apr 2023 07:11:28 -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 9916868BE2F; Sun, 9 Apr 2023 17:09:32 +0300 (EEST) 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 8F58F68BCC3 for ; Sun, 9 Apr 2023 17:09:19 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 48DE62404EC for ; Sun, 9 Apr 2023 16:09:19 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id p0xFviCEX0gf for ; Sun, 9 Apr 2023 16:09:17 +0200 (CEST) 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 C6E6E2404EE for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id B2E643A038E for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Apr 2023 16:08:46 +0200 Message-Id: <20230409140853.28858-22-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230409140853.28858-1-anton@khirnov.net> References: <20230409140853.28858-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 22/29] fftools/ffmpeg: track a list of non-lavfi outputs in InputStream 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: zVXHaJMokIUW Currently, output streams where an input stream is sent directly (i.e. not through lavfi) are determined by iterating over ALL the output streams and skipping the irrelevant ones. This is awkward and inefficient. --- fftools/ffmpeg.c | 21 +++++++++------------ fftools/ffmpeg.h | 10 ++++++++++ fftools/ffmpeg_demux.c | 7 +++++++ fftools/ffmpeg_mux_init.c | 3 +++ 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 74aba28a9b..f65ff879c7 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -948,9 +948,6 @@ static int check_output_constraints(InputStream *ist, OutputStream *ost) { OutputFile *of = output_files[ost->file_index]; - if (ost->ist != ist) - return 0; - if (ost->finished & MUXER_FINISHED) return 0; @@ -1468,7 +1465,8 @@ static int process_subtitle(InputStream *ist, AVSubtitle *subtitle, int *got_out if (!subtitle->num_rects) goto out; - for (OutputStream *ost = ost_iter(NULL); ost; ost = ost_iter(ost)) { + for (int oidx = 0; oidx < ist->nb_outputs; oidx++) { + OutputStream *ost = ist->outputs[oidx]; if (!check_output_constraints(ist, ost) || !ost->enc_ctx || ost->enc_ctx->codec_type != AVMEDIA_TYPE_SUBTITLE) continue; @@ -1830,7 +1828,8 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo } else if (!ist->decoding_needed) eof_reached = 1; - for (OutputStream *ost = ost_iter(NULL); ost; ost = ost_iter(ost)) { + for (int oidx = 0; oidx < ist->nb_outputs; oidx++) { + OutputStream *ost = ist->outputs[oidx]; if (!check_output_constraints(ist, ost) || ost->enc_ctx || (!pkt && no_eof)) continue; @@ -2577,13 +2576,11 @@ static int process_input(int file_index) } /* mark all outputs that don't go through lavfi as finished */ - for (OutputStream *ost = ost_iter(NULL); ost; ost = ost_iter(ost)) { - if (ost->ist == ist && - (!ost->enc_ctx || ost->enc_ctx->codec_type == AVMEDIA_TYPE_SUBTITLE)) { - OutputFile *of = output_files[ost->file_index]; - close_output_stream(ost); - of_output_packet(of, ost->pkt, ost, 1); - } + for (int oidx = 0; oidx < ist->nb_outputs; oidx++) { + OutputStream *ost = ist->outputs[oidx]; + OutputFile *of = output_files[ost->file_index]; + close_output_stream(ost); + of_output_packet(of, ost->pkt, ost, 1); } } diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 80a1192ed0..aef2bbc0df 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -416,6 +416,14 @@ typedef struct InputStream { InputFilter **filters; int nb_filters; + /* + * Output targets that do not go through lavfi, i.e. subtitles or + * streamcopy. Those two cases are distinguished by the OutputStream + * having an encoder or not. + */ + struct OutputStream **outputs; + int nb_outputs; + int reinit_filters; /* hwaccel options */ @@ -867,6 +875,8 @@ void ifile_close(InputFile **f); */ int ifile_get_packet(InputFile *f, AVPacket **pkt); +void ist_output_add(InputStream *ist, OutputStream *ost); + /* iterate over all input streams in all input files; * pass NULL to start iteration */ InputStream *ist_iter(InputStream *prev); diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index 93eed28809..f2da0826ad 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -528,6 +528,7 @@ static void ist_free(InputStream **pist) avsubtitle_free(&ist->prev_sub.subtitle); av_frame_free(&ist->sub2video.frame); av_freep(&ist->filters); + av_freep(&ist->outputs); av_freep(&ist->hwaccel_device); av_freep(&ist->dts_buffer); @@ -559,6 +560,12 @@ void ifile_close(InputFile **pf) av_freep(pf); } +void ist_output_add(InputStream *ist, OutputStream *ost) +{ + GROW_ARRAY(ist->outputs, ist->nb_outputs); + ist->outputs[ist->nb_outputs - 1] = ost; +} + static const AVCodec *choose_decoder(const OptionsContext *o, AVFormatContext *s, AVStream *st, enum HWAccelID hwaccel_id, enum AVHWDeviceType hwaccel_device_type) diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 4b6c704046..62e5643a04 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -647,6 +647,9 @@ static OutputStream *new_output_stream(Muxer *mux, const OptionsContext *o, if (ost->ist) { ost->ist->discard = 0; ost->ist->st->discard = ost->ist->user_set_discard; + + if (!(ost->enc && (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO))) + ist_output_add(ost->ist, ost); } ost->last_mux_dts = AV_NOPTS_VALUE; From patchwork Sun Apr 9 14:08:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41057 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1591643pzb; Sun, 9 Apr 2023 07:11:10 -0700 (PDT) X-Google-Smtp-Source: AKy350bzNw9Jqu5yr6VOqnuKnLxF+yGSkzRE4Mu47mR1Xa+OhpI0tb122wpN1cahbRsB54EovU6+ X-Received: by 2002:a50:ee99:0:b0:502:3376:7872 with SMTP id f25-20020a50ee99000000b0050233767872mr9383953edr.35.1681049470713; Sun, 09 Apr 2023 07:11:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681049470; cv=none; d=google.com; s=arc-20160816; b=i2wcaTTR41gdCTPXK0lTXrt8X7etcRstSqX9knDUkQ5DK86qZmBWLHG7UL7MWP1shV 40Lm63mM+bZvERQ/QDxtTB0rjAnogXLtqFIx8QMnheGNFDYrkF+X8LMEWZqj2Fz6VDxq tENM9wicHzuuv9+Mk/G+9U+WazBOj6Ct2+DVjONemM9VPTkW8TMuICawzVFoxu7u/A2S mdb6FnxLU+eSq7MOXszB1eyGhOH+Sg1QA62LFXKkvX1veQQxarNWLtNIIMcIa6fHr0oF V631ogHpz21gl0TUgVbD9o6ZzI5z03JCMvgwYupcH88jr9HCV2C+NdIMXv1eYWLVe5eb xrEA== 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=oj1aeIkf4V97rHX05McRfM+MIUu28+qhaINpjFI8Qts=; b=sz/7LVELJr6qLloptMtyEz4RnKEw8tV3CnQKssMMLycXn8yS5RvaKt33NWMWTV+iOC nc2SEW3ivy6jIYuO/a/4eAYMvYW2mCyAmL760GRr6l5oPoxXxJvJSCo7pee08Xy62XLC ZRucWhehJ9koILod97VJwR0a7UibPwtgu2Doev7na+iA9fpZSTEEv1Zuc9zT01sgnP05 iYDYs1q68TkF3zFs84O1VpJaQwhrhpc08zt/TpGn5+Oi+hYbREBZqR6qH1CpUehGcNHU P34KsM72pJxr4fCE+tQHcpkpBe4iw3LHvD+v+mk5nb/FgSIi3u7jtjdkrFlU0yzXkJK7 lzZg== 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 e20-20020a50ec94000000b0050493007972si2275591edr.308.2023.04.09.07.11.10; Sun, 09 Apr 2023 07:11:10 -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 A053768BE23; Sun, 9 Apr 2023 17:09:30 +0300 (EEST) 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 7469B68BC9D for ; Sun, 9 Apr 2023 17:09:18 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 05D472404F5 for ; Sun, 9 Apr 2023 16:09:18 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id u8hBWjO-rxxS for ; Sun, 9 Apr 2023 16:09:17 +0200 (CEST) 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 D0BE6240D1D for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id BF7A23A039B for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Apr 2023 16:08:47 +0200 Message-Id: <20230409140853.28858-23-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230409140853.28858-1-anton@khirnov.net> References: <20230409140853.28858-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 23/29] fftools/ffmpeg: stop calling check_output_constraints() for streamcopy 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: fe1KW79qqOtc That function only contains two checks now - whether the muxer returned EOF and whether the packet timestamp is before requested output start time. The first check is unnecessary, since the packet will just be rejected by the muxer. The second check is better combined with a related check directly in do_streamcopy(). --- fftools/ffmpeg.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index f65ff879c7..44ead4e3bc 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -976,10 +976,14 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p !ost->copy_initial_nonkeyframes) return; - if (!ost->streamcopy_started && !ost->copy_prior_start) { - if (pkt->pts == AV_NOPTS_VALUE ? - ist->pts < ost->ts_copy_start : - pkt->pts < av_rescale_q(ost->ts_copy_start, AV_TIME_BASE_Q, ist->st->time_base)) + if (!ost->streamcopy_started) { + if (!ost->copy_prior_start && + (pkt->pts == AV_NOPTS_VALUE ? + ist->pts < ost->ts_copy_start : + pkt->pts < av_rescale_q(ost->ts_copy_start, AV_TIME_BASE_Q, ist->st->time_base))) + return; + + if (of->start_time != AV_NOPTS_VALUE && ist->pts < of->start_time) return; } @@ -1830,8 +1834,7 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo for (int oidx = 0; oidx < ist->nb_outputs; oidx++) { OutputStream *ost = ist->outputs[oidx]; - if (!check_output_constraints(ist, ost) || ost->enc_ctx || - (!pkt && no_eof)) + if (ost->enc_ctx || (!pkt && no_eof)) continue; do_streamcopy(ist, ost, pkt); From patchwork Sun Apr 9 14:08:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41058 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1591733pzb; Sun, 9 Apr 2023 07:11:19 -0700 (PDT) X-Google-Smtp-Source: AKy350Yu/daLqUzj/fjdgRBVGkNQLBCNmMvNKxBccar9nbtuWOOjEECnVIjzx8v2HYF4WGWg+pF/ X-Received: by 2002:a17:906:124c:b0:93b:49e8:d7b9 with SMTP id u12-20020a170906124c00b0093b49e8d7b9mr5787032eja.40.1681049479549; Sun, 09 Apr 2023 07:11:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681049479; cv=none; d=google.com; s=arc-20160816; b=k02eoLATl+mNkWwC15pUTotz9Svk4woOM/0Y72u6L12xZu8ymqi+dp+Sa1/jrMbI+o 6ddwGZYenMFz2aO3CKwwH9Z1Vnum7fbQ/lWXsjSjEfsixkhqy3dV2AMpp7c6PzvYamrc kDF9uY9Ha6z7K1mn03HClAZNX35k3NwJ1IEedoGLkGXZumpo0D9WYl/3TfxTjyt1W1PD Og1VRvpK/aF1KDCWkaxVBIRYgw+y5f9rN2OdpKDLYKe5LRRo7NZCOMwn1eLXLpsH/5Q2 ViopJcc1RgkcljhhUVmk5VQJWCu5xOkhUJj8zK0oOLFBpp76jDtIuLbzCaOx0PPQ/VgZ gngA== 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=bNUGiYGD8OoxmVdf8fXCPYrJgneQdfP1pQf95Xj8o3I=; b=dldZ+cNhqt8QWx/oEwwD5quiA36T96gw277h4odHbPWpgCkFZHZvsnAHW5bfnEsadT xkvghbB5xEF0f1wvyO86JOm8CwFP4molXnxkb91RN7svdOqXBdIu/ehPFEV+w9nAkl/8 kOrJH1Ov/quSf02O6VOU03D9/muHxlc8dI5bE5W6CbKLuYSTOn1kedCDp29fs2t/lrAj s7JoWF4jclaO+5jCB4WQ7s6rMs8NMVXVI1buKAmMCDQt6sLdSNJcmnOHW0IqXPhf7kkb eGP8M8D0hxpG6KLe0joDWfLTGLhbxLTq/iSEDCJvGKr6Oy+B01aDMPwd5VRw4c92KtTE 7rIA== 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 g2-20020a17090669c200b00937a2b0691asi7610032ejs.298.2023.04.09.07.11.19; Sun, 09 Apr 2023 07:11:19 -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 ABE4368BE2B; Sun, 9 Apr 2023 17:09:31 +0300 (EEST) 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 CDD8968BBEE for ; Sun, 9 Apr 2023 17:09:18 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 9AF5E2404EC for ; Sun, 9 Apr 2023 16:09:18 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 0Ezk68VGuMge for ; Sun, 9 Apr 2023 16:09:18 +0200 (CEST) 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 D9C1A240D1E for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id CA1B73A03E5 for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Apr 2023 16:08:48 +0200 Message-Id: <20230409140853.28858-24-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230409140853.28858-1-anton@khirnov.net> References: <20230409140853.28858-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 24/29] fftools/ffmpeg: inline check_output_constraints() into its only caller 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: 5lp/wR3Jy9Mt Which is subtitle encoding. Also, check for AVSubtitle.pts rather than InputStream.pts, since that is the more authoritative value and is guaranteed to be valid. --- fftools/ffmpeg.c | 19 +------------------ fftools/ffmpeg_enc.c | 3 +++ 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 44ead4e3bc..95e4044dc6 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -941,22 +941,6 @@ int ifilter_parameters_from_codecpar(InputFilter *ifilter, AVCodecParameters *pa return 0; } -/* - * Check whether a packet from ist should be written into ost at this time - */ -static int check_output_constraints(InputStream *ist, OutputStream *ost) -{ - OutputFile *of = output_files[ost->file_index]; - - if (ost->finished & MUXER_FINISHED) - return 0; - - if (of->start_time != AV_NOPTS_VALUE && ist->pts < of->start_time) - return 0; - - return 1; -} - static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *pkt) { OutputFile *of = output_files[ost->file_index]; @@ -1471,8 +1455,7 @@ static int process_subtitle(InputStream *ist, AVSubtitle *subtitle, int *got_out for (int oidx = 0; oidx < ist->nb_outputs; oidx++) { OutputStream *ost = ist->outputs[oidx]; - if (!check_output_constraints(ist, ost) || !ost->enc_ctx - || ost->enc_ctx->codec_type != AVMEDIA_TYPE_SUBTITLE) + if (!ost->enc_ctx || ost->enc_ctx->codec_type != AVMEDIA_TYPE_SUBTITLE) continue; enc_subtitle(output_files[ost->file_index], ost, subtitle); diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index 2aaef806f6..a0779c45ae 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -440,6 +440,9 @@ void enc_subtitle(OutputFile *of, OutputStream *ost, AVSubtitle *sub) exit_program(1); return; } + if (ost->finished || + (of->start_time != AV_NOPTS_VALUE && sub->pts < of->start_time)) + return; enc = ost->enc_ctx; From patchwork Sun Apr 9 14:08:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41062 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1591984pzb; Sun, 9 Apr 2023 07:11:56 -0700 (PDT) X-Google-Smtp-Source: AKy350YRIRaacNQWcyBGObbcJoqOO/LzWRvFopUzNXJUbuO8gjdDQC8N0sC8vK+/vgaRlawEGZz/ X-Received: by 2002:a05:6402:409:b0:501:d3a0:30d9 with SMTP id q9-20020a056402040900b00501d3a030d9mr7128417edv.7.1681049515741; Sun, 09 Apr 2023 07:11:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681049515; cv=none; d=google.com; s=arc-20160816; b=zxukKKrBwZnBJKVwIjB2iOKGi5lV2BV6Z0WD366Ex/oYePPDwMsT64fZl6y+66+2ut UQzi0BHr8uaO3nH/HT+X/8xMmgBFh77yJI7bYG7Pk1NEhSDEwR99PkX+dW366BC2WitS +Kywk5o34gjMREilFi19e2jqcEOI6bvqxZW8VyYnXKg+c1Co3h4jibShoqoAqvwqe4AL OJSiA21t0u32GzwPMibv7OnZB9H33CJo/edvAVO2AzH1Kw8pTU12+KW0tK9f3vBk5n9W 0lEc4gbcivoNMfvu6VBs6j2m77h05/PKhd761ZV30lI75slgywp/SwKKtgfM3Xjr7IL6 zRSA== 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=BOvJNMEhmW9+HEXa9+M5o9HDIaGYeRPcMsXbbCDsFNE=; b=ANKNtv4yeI7DQ8LsR2nz042zPdNiwN/AJ5ynZXjN1O9jX0xyHv84viOltO5qKIjUQi MPmL83cUqGXKTb72sHVHeRCUWyYjhuMvPP711BocSO0ItbjE4aSUELCrFgmTIKBwX0g4 wp1PkxSAd8ttATc8awcezQd0qBTjOIyLWEwCCscCScyxRnVuDegInv12zhoU0qN0FXaV iExzuao7H7lA6jkqTAHhsTsWVXLioxMugRNYTGWcCU9iwWZ7wMVvmOTCZ6JgXSKSvA1m CU8vnBhdAUIKxKAycjjHVwonHmMDKAGehZr9MKigeqFyOJn6bPXJMQ8OB+vRJAmAUCuB 7KAw== 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 w16-20020a056402071000b005048736290asi4185617edx.342.2023.04.09.07.11.55; Sun, 09 Apr 2023 07:11:55 -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 5621368BCFB; Sun, 9 Apr 2023 17:09:35 +0300 (EEST) 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 DC46368BD38 for ; Sun, 9 Apr 2023 17:09:20 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id A7E162404EC for ; Sun, 9 Apr 2023 16:09:20 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id ZjPHyzDirWpa for ; Sun, 9 Apr 2023 16:09:18 +0200 (CEST) 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 E6215240D1F for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id D4DD23A038E for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Apr 2023 16:08:49 +0200 Message-Id: <20230409140853.28858-25-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230409140853.28858-1-anton@khirnov.net> References: <20230409140853.28858-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 25/29] fftools/ffmpeg_demux: set the timebase on demuxed packets 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: icjQFfUp+8bQ Simplifies tracking what timebase are the timestamps in. Will be useful in following commits. --- fftools/ffmpeg_demux.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index f2da0826ad..7ff57273c9 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -194,15 +194,17 @@ static void ts_fixup(Demuxer *d, AVPacket *pkt, int *repeat_pict) const int64_t start_time = ifile->start_time_effective; int64_t duration; + pkt->time_base = ist->st->time_base; + #define SHOW_TS_DEBUG(tag_) \ if (debug_ts) { \ av_log(ist, AV_LOG_INFO, "%s -> ist_index:%d:%d type:%s " \ "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s duration:%s duration_time:%s\n", \ tag_, ifile->index, pkt->stream_index, \ av_get_media_type_string(ist->st->codecpar->codec_type), \ - av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &ist->st->time_base), \ - av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &ist->st->time_base), \ - av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, &ist->st->time_base)); \ + av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &pkt->time_base), \ + av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &pkt->time_base), \ + av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, &pkt->time_base)); \ } SHOW_TS_DEBUG("demuxer"); @@ -211,7 +213,7 @@ static void ts_fixup(Demuxer *d, AVPacket *pkt, int *repeat_pict) ist->st->pts_wrap_bits < 64) { int64_t stime, stime2; - stime = av_rescale_q(start_time, AV_TIME_BASE_Q, ist->st->time_base); + stime = av_rescale_q(start_time, AV_TIME_BASE_Q, pkt->time_base); stime2= stime + (1ULL<st->pts_wrap_bits); ist->wrap_correction_done = 1; @@ -226,16 +228,16 @@ static void ts_fixup(Demuxer *d, AVPacket *pkt, int *repeat_pict) } if (pkt->dts != AV_NOPTS_VALUE) - pkt->dts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, ist->st->time_base); + pkt->dts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, pkt->time_base); if (pkt->pts != AV_NOPTS_VALUE) - pkt->pts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, ist->st->time_base); + pkt->pts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, pkt->time_base); if (pkt->pts != AV_NOPTS_VALUE) pkt->pts *= ds->ts_scale; if (pkt->dts != AV_NOPTS_VALUE) pkt->dts *= ds->ts_scale; - duration = av_rescale_q(d->duration, d->time_base, ist->st->time_base); + duration = av_rescale_q(d->duration, d->time_base, pkt->time_base); if (pkt->pts != AV_NOPTS_VALUE) { pkt->pts += duration; ds->max_pts = FFMAX(pkt->pts, ds->max_pts); From patchwork Sun Apr 9 14:08:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41060 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1591836pzb; Sun, 9 Apr 2023 07:11:37 -0700 (PDT) X-Google-Smtp-Source: AKy350buI2brbZvYodZONceEUV853D59tJnjZA46etFDiqnL2z7g9DCxTfWvLSIkPiIVUDs3wtBu X-Received: by 2002:a17:906:c78f:b0:931:636e:de5a with SMTP id cw15-20020a170906c78f00b00931636ede5amr3799458ejb.31.1681049497378; Sun, 09 Apr 2023 07:11:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681049497; cv=none; d=google.com; s=arc-20160816; b=Yes4kWiGhyEsgnnsFMqae/bGTve1ovfAA7agCsOG8eQjirO0+prhjQGbWlllpWTwfP cvxSlECysEomtR5Y/DNYgh9r/QMP+cUFT5Pn1oPU4lh3uZmwozFh1pb6Il0AlHsKUj0v lc+Y56dKbM5/CTmbEne+evbGqceT0+BAZNeVP6stXibpkl9LltL8rI/Pg1LLohMg5hwV h+Tj8ai7lnFHOkCLIdsoEgtnLq3Q+nJBRPgsxlLdB8yWsXUO3e+W9N2OQmXLLHFJQZ4O ALH1zN80QK0OBMS4/cVSOTnjkQSWEsrXaFnBSKfUNoCT2SHa+hx8ZYMNImpWOCYocj0O U75g== 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=V+UPfwrH6sE6CpezbvETV9OypObRd8RO0KeLYkReoXs=; b=DdyW46eK0IPu+pbGV1nHzoT2L06SJnvoNwEdGhQQE7/GjpKiYzTLvA97+BVWT8ZrNG uzn48VLcO98m5b0USDBq6a1arfQ6F6GyOPVFOhaDFHkVLpUGdZqVMpBohMyAv8G39TCY sF2PEnic/4jx/O6aK4Duj36f/mkLWZx9JEt9ofBS9yL+0x/1ATCx5CbBaT9lJ/E+OhcX 3o+J0gx71NsLa2Sr/G9RcdZbqKBIyrVHngBoTeuxc5JkRMIQq7D+W7JmxOyBuxlKJSKY rY9sDi6jDB6CacowQwcGSMMGf+bLYuqLs3Lghtczu6mes4OWjWDqUl5B5NYOqqjafSaB IhVw== 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 u16-20020aa7d890000000b00504a2ba01besi268900edq.653.2023.04.09.07.11.37; Sun, 09 Apr 2023 07:11:37 -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 6F7E868BE35; Sun, 9 Apr 2023 17:09:33 +0300 (EEST) 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 1BDC068BC61 for ; Sun, 9 Apr 2023 17:09:20 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id CCEFC2404EC for ; Sun, 9 Apr 2023 16:09:19 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id w0kVYyJYnYcE for ; Sun, 9 Apr 2023 16:09:19 +0200 (CEST) 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 F0242240D20 for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id DFFAB3A039B for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Apr 2023 16:08:50 +0200 Message-Id: <20230409140853.28858-26-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230409140853.28858-1-anton@khirnov.net> References: <20230409140853.28858-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 26/29] fftools/ffmpeg: use AVPacket.time_base to simplify do_streamcopy() 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: 4ZkPINl45KjT Besides making the code shorter, this also reduces the use of InputStream in this function and will allow not accessing it at all in the future. --- fftools/ffmpeg.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 95e4044dc6..f905836af6 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -964,7 +964,7 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p if (!ost->copy_prior_start && (pkt->pts == AV_NOPTS_VALUE ? ist->pts < ost->ts_copy_start : - pkt->pts < av_rescale_q(ost->ts_copy_start, AV_TIME_BASE_Q, ist->st->time_base))) + pkt->pts < av_rescale_q(ost->ts_copy_start, AV_TIME_BASE_Q, pkt->time_base))) return; if (of->start_time != AV_NOPTS_VALUE && ist->pts < of->start_time) @@ -995,7 +995,7 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p opkt->time_base = ost->mux_timebase; if (pkt->pts != AV_NOPTS_VALUE) - opkt->pts = av_rescale_q(pkt->pts, ist->st->time_base, opkt->time_base) - ost_tb_start_time; + opkt->pts = av_rescale_q(pkt->pts, pkt->time_base, opkt->time_base) - ost_tb_start_time; if (pkt->dts == AV_NOPTS_VALUE) { opkt->dts = av_rescale_q(ist->dts, AV_TIME_BASE_Q, opkt->time_base); @@ -1003,16 +1003,16 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p int duration = av_get_audio_frame_duration2(ist->par, pkt->size); if(!duration) duration = ist->par->frame_size; - opkt->dts = av_rescale_delta(ist->st->time_base, pkt->dts, + opkt->dts = av_rescale_delta(pkt->time_base, pkt->dts, (AVRational){1, ist->par->sample_rate}, duration, &ist->filter_in_rescale_delta_last, opkt->time_base); /* dts will be set immediately afterwards to what pts is now */ opkt->pts = opkt->dts - ost_tb_start_time; } else - opkt->dts = av_rescale_q(pkt->dts, ist->st->time_base, opkt->time_base); + opkt->dts = av_rescale_q(pkt->dts, pkt->time_base, opkt->time_base); opkt->dts -= ost_tb_start_time; - opkt->duration = av_rescale_q(pkt->duration, ist->st->time_base, opkt->time_base); + opkt->duration = av_rescale_q(pkt->duration, pkt->time_base, opkt->time_base); { int ret = trigger_fix_sub_duration_heartbeat(ost, pkt); From patchwork Sun Apr 9 14:08:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41061 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1591925pzb; Sun, 9 Apr 2023 07:11:48 -0700 (PDT) X-Google-Smtp-Source: AKy350YtCzavuEzUBYmiQlkTs+JUvJHUVYf6NBvYlq/wWBahnRJjc9d+HR/yJt1WWXKrgGvU572a X-Received: by 2002:a17:907:7853:b0:931:95a1:a05a with SMTP id lb19-20020a170907785300b0093195a1a05amr5320084ejc.62.1681049508185; Sun, 09 Apr 2023 07:11:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681049508; cv=none; d=google.com; s=arc-20160816; b=mteqiqLp1kaPJSQlc76qdF5AN5LR8jIFy5egO0oud7Pp+MLuE5p9HKu1yBM4YDOMA0 LTd/SsOz3LCTrN1YDBWBkYXBuE/Ipesv0cIFs1WVayanYD+VJ5AJpwNAAHVBe01YnCPA WwL1gf1L0lkFJv9yOrkwmjp8DyJ2O0HC2ljhk6php1nJRIPU/1sSvCmJ9pRPTTeu4py0 Xf4QgJsMJY+FxVmDAm3wEtNRtUNlnBo7+wbSMRimNc8f7/voIRX8Nnke/GmfKM5/FF0j WvVrpeL6kkmRK8nQZxLXnAboeg1hEzz4Q4ZuTQ/Wu28+25Rclmp4fYZi3yxjQCvywRd6 Ct8g== 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=uqJvYJfoBTobOUTSBMbeP0hwneFp0r6lWgs68U+ndO0=; b=gfgvMufg9Pe+fa2TVmqD74ldTK6gJbcfHwIG9t1Z9g/6bR6elRRdS/dNh8JfT9DHJw qvTdXULRzdXDX3OvntwXAdIVe4oHKE6+EScTgPQ9x/K4FYcUCtb3ClggsGVsF29LiHTt MYX6ljAptjd7HT0Ps1n/+SPIrBjNY7oUZjwQU2SuPXEycz9zTHT4m2FFI6xRymUpyGzr UUME5mFKE7ds5MwC0kTY5PjYrolIUw7MpwHPSX6UP7a9gVNC1ol+Ztg84ELjPtxPZRT+ s0T18ecBcdrw0iPg2G4lbZv6ivWguuVtC1Y3h4ObRMjOQEwqEkl4rrlXS0DLvwVm9HvY Jrlw== 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 u20-20020a1709067d1400b008e41fc88f2bsi3215585ejo.981.2023.04.09.07.11.46; Sun, 09 Apr 2023 07:11:48 -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 67C7368BE41; Sun, 9 Apr 2023 17:09:34 +0300 (EEST) 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 945B268BD38 for ; Sun, 9 Apr 2023 17:09:20 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 632832404EC for ; Sun, 9 Apr 2023 16:09:20 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 1-oR9zG5k3Ne for ; Sun, 9 Apr 2023 16:09:19 +0200 (CEST) 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 06119240D21 for ; Sun, 9 Apr 2023 16:09:11 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id EB6A13A03E5 for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Apr 2023 16:08:51 +0200 Message-Id: <20230409140853.28858-27-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230409140853.28858-1-anton@khirnov.net> References: <20230409140853.28858-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 27/29] fftools/ffmpeg: only set InputStream.next_pts for decoding 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: Qaf4AEdYszUi It is write-only for streamcopy. --- fftools/ffmpeg.c | 3 +-- fftools/ffmpeg.h | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index f905836af6..4d4083d474 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1670,7 +1670,7 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo if (pkt && pkt->dts != AV_NOPTS_VALUE) { ist->next_dts = ist->dts = av_rescale_q(pkt->dts, ist->st->time_base, AV_TIME_BASE_Q); if (par->codec_type != AVMEDIA_TYPE_VIDEO || !ist->decoding_needed) - ist->next_pts = ist->pts = ist->dts; + ist->pts = ist->dts; } // while we have more to decode or while the decoder did output something on EOF @@ -1811,7 +1811,6 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo break; } ist->pts = ist->dts; - ist->next_pts = ist->next_dts; } else if (!ist->decoding_needed) eof_reached = 1; diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index aef2bbc0df..50e5858385 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -370,7 +370,8 @@ typedef struct InputStream { int64_t first_dts; ///< dts of the first packet read for this stream (in AV_TIME_BASE units) int64_t dts; ///< dts of the last packet read for this stream (in AV_TIME_BASE units) - int64_t next_pts; ///< synthetic pts for the next decode frame (in AV_TIME_BASE units) + /* predicted pts of the next decoded frame, in AV_TIME_BASE */ + int64_t next_pts; int64_t pts; ///< current pts of the decoded frame (in AV_TIME_BASE units) int wrap_correction_done; From patchwork Sun Apr 9 14:08:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41065 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1592196pzb; Sun, 9 Apr 2023 07:12:22 -0700 (PDT) X-Google-Smtp-Source: AKy350aYpy45+wFIklPTPtcCt+/3CSW1ebZSdKxgQjp1d32unbsVrmTXWnFdjtYE4skVrpJ0W6tR X-Received: by 2002:a17:906:339b:b0:94a:6f0d:567e with SMTP id v27-20020a170906339b00b0094a6f0d567emr1290259eja.56.1681049542445; Sun, 09 Apr 2023 07:12:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681049542; cv=none; d=google.com; s=arc-20160816; b=ixpQcubh73aIXMmdwoAPojlLbxJCx0dJoZxAQO5PxlcrRr8DHJAVLGULpBoIHcSTS6 skepqXBlnO6ZdZfWRnOPhcsQpAvyZl5PnK0nqypXtX3aMamtxoaMmEd+eNVdTXvuMMfV LV6tivxp32+brb3hI1YptzfD+Lj+7taSAF8i5+iCnFXZaBDFrXIHb69pWKJj2hT8rYF2 DZwq3DmFvYcusZsMr9IOV0X0xZN36OcTBKIeiyq4IO6dU2OeE1vOSGN3ZkZN47RwsHj2 Ux2rVUAR1o6iDvA+rfQUTJN5PAPIMABs/rfwUY5qPD5ncKescm7gFIyV9m2GA4UrAP7a jkJQ== 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=2TX3PPAt2XBqZ+lJ0WFZpYDUqHtNR3smR5dMjaQmxvY=; b=qEag3Zv5GoVo6h4SldWpiL7BRWTp/eNVDXIH1Db3KD5l5kv3vPvQJLmbkYn6jPo812 vT0VSbEM3FJXoNRIJp3KO37GuRVn2WG6KY+IyXbJn+lQoWhB7ZuWM0PcXW+P/dE+gDqZ u8EigJsiJYvVnsbH+KQzrHmf/Ws8UJ7bECjKVw6i+UF9B4hG8Im4qvSXa3Zyzeo6zKE0 GKCmy218jX2vTEFfzONdDeHaKOGcASAxs7bsRrrG/gjs/SLdik4RYFDAFxY2hAQF3JQ/ 4SDkp/jkkZMfIdM7lO7Ps9UtAC47iVgp9a2tTuL+XcqiBjEv8DqxpeoI3UH1DZxoARLA cR2A== 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 c19-20020aa7c993000000b00504a371adf5si120708edt.433.2023.04.09.07.12.22; Sun, 09 Apr 2023 07:12:22 -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 3136868BE68; Sun, 9 Apr 2023 17:09:38 +0300 (EEST) 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 431D568BD38 for ; Sun, 9 Apr 2023 17:09:21 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id F3D4A2404EC for ; Sun, 9 Apr 2023 16:09:20 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 30xMqRupmsXF for ; Sun, 9 Apr 2023 16:09:20 +0200 (CEST) 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 1211E240D22 for ; Sun, 9 Apr 2023 16:09:11 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 024023A038E for ; Sun, 9 Apr 2023 16:09:11 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Apr 2023 16:08:52 +0200 Message-Id: <20230409140853.28858-28-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230409140853.28858-1-anton@khirnov.net> References: <20230409140853.28858-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 28/29] fftools/ffmpeg: move checking for input -t out of do_streamcopy() 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: PQqTzbLwJVfW This check is entirely about the properties of the input stream, while do_streamcopy() should contain code specific to a given output stream. --- fftools/ffmpeg.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 4d4083d474..5c80f3b65f 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -944,7 +944,6 @@ int ifilter_parameters_from_codecpar(InputFilter *ifilter, AVCodecParameters *pa static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *pkt) { OutputFile *of = output_files[ost->file_index]; - InputFile *f = input_files [ist->file_index]; int64_t start_time = (of->start_time == AV_NOPTS_VALUE) ? 0 : of->start_time; int64_t ost_tb_start_time = av_rescale_q(start_time, AV_TIME_BASE_Q, ost->mux_timebase); AVPacket *opkt = ost->pkt; @@ -977,18 +976,6 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p return; } - if (f->recording_time != INT64_MAX) { - start_time = 0; - if (copy_ts) { - start_time += f->start_time != AV_NOPTS_VALUE ? f->start_time : 0; - start_time += start_at_zero ? 0 : f->start_time_effective; - } - if (ist->pts >= f->recording_time + start_time) { - close_output_stream(ost); - return; - } - } - if (av_packet_ref(opkt, pkt) < 0) exit_program(1); @@ -1636,10 +1623,12 @@ static int send_filter_eof(InputStream *ist) /* pkt = NULL means EOF (needed to flush decoder buffers) */ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eof) { + InputFile *f = input_files[ist->file_index]; const AVCodecParameters *par = ist->par; int ret = 0; int repeating = 0; int eof_reached = 0; + int duration_exceeded; AVPacket *avpkt = ist->pkt; @@ -1814,11 +1803,27 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo } else if (!ist->decoding_needed) eof_reached = 1; + duration_exceeded = 0; + if (f->recording_time != INT64_MAX) { + int64_t start_time = 0; + if (copy_ts) { + start_time += f->start_time != AV_NOPTS_VALUE ? f->start_time : 0; + start_time += start_at_zero ? 0 : f->start_time_effective; + } + if (ist->pts >= f->recording_time + start_time) + duration_exceeded = 1; + } + for (int oidx = 0; oidx < ist->nb_outputs; oidx++) { OutputStream *ost = ist->outputs[oidx]; if (ost->enc_ctx || (!pkt && no_eof)) continue; + if (duration_exceeded) { + close_output_stream(ost); + continue; + } + do_streamcopy(ist, ost, pkt); } From patchwork Sun Apr 9 14:08:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41066 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1592279pzb; Sun, 9 Apr 2023 07:12:31 -0700 (PDT) X-Google-Smtp-Source: AKy350bl1YBI4bc6bXLiTku8z5Hda2YgmYWhSuwHE1bCF4etrf2p5h0SYPdAmd3sFFGlYKde2FHK X-Received: by 2002:a17:906:ecf2:b0:948:b300:6e9a with SMTP id qt18-20020a170906ecf200b00948b3006e9amr5138274ejb.32.1681049551168; Sun, 09 Apr 2023 07:12:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681049551; cv=none; d=google.com; s=arc-20160816; b=bZf+0q/T0g8sM7xuo7JhlBmuXtPuJPRd8DHXiFDCAyqRcvXgkGIS7TmtRGO+gfoZHW k1imGUv/a1RUuE3KuDzlI4dGj+xpFOCznjbD6YnM5VB9W44ZjRR3qfgCbXHH6XPII1ZM mtugDX0jf1ZDRN1abm+mZN8yRa2aIz44QeQNlDMKGKGQ8B0YVohwFjOdK2O0DqoO6woM 9pbKKlritxf91UgfS5h47JUZceeaPaIZyTDctFKniLAD9N4bgEGDnEoSKEN3fTHcL3Xk qjLOfH9nCkMvnLOvTwe4K5YDE5QufCfcd3D0vjT31T8dN2a+IUrXnWjI1s8DrvAcUeYs V4LQ== 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=xvTjOmf41sRw/MlAkOY1UWiZxmyF3Qtyn7Dh4LX03IU=; b=u82D1JpW/H79XCtf7vbaBwjyo+uO0PgSRq1WTyutqrVcNccf4iDusKakdW3lG3KIev o0ldnlw8t8sO0jryTXyF9S4szXq1bBlOyhcTqQkctFBSsW3KLuEookmaW8wft9R1Z4jW k26w6WcpO/53KYoG2GK/QB5Mju80hLXB8Q3EMM1XZ1eVMqZPhx4Ane3w8uzTFcsaG/dL PZt/YOUmpPLPiZMA9pqxy6ZqKIc+fZBSRtgwx0c5JzemOoisz7q4dut+ZGhwkal6pWBK gusxlRbdlp8pdUxxFRlSM9bVuQNNZ6CVaeO5MyjE9kh82HwSN05hIuN1Wq4QKNICQaKm 33Lg== 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 g5-20020a17090670c500b008d78cb027b7si5497068ejk.667.2023.04.09.07.12.30; Sun, 09 Apr 2023 07:12:31 -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 2649D68BE72; Sun, 9 Apr 2023 17:09:39 +0300 (EEST) 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 6A74568BD2C for ; Sun, 9 Apr 2023 17:09:21 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 38F952404EE for ; Sun, 9 Apr 2023 16:09:21 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id nxUhv5XRcVCR for ; Sun, 9 Apr 2023 16:09:20 +0200 (CEST) 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 1D530240D23 for ; Sun, 9 Apr 2023 16:09:11 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 0DAED3A039B for ; Sun, 9 Apr 2023 16:09:11 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Apr 2023 16:08:53 +0200 Message-Id: <20230409140853.28858-29-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230409140853.28858-1-anton@khirnov.net> References: <20230409140853.28858-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 29/29] fftools/ffmpeg: stop using InputStream.pts for streamcopy 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: jr1vtm+S7tie This field contains different value depending on whether the stream is being decoded or not. When it is, InputStream.pts is set to the timestamp of the last decoded frame. Otherwise, it is made equal to InputStream.dts. Since a given InputStream can be at the same time decoded and streamcopied to any number of output streams, this use is incorrect, as decoded frame timestamps can be delayed with respect to input packets by an arbitrary amount (e.g. depending on the thread count when frame threading is used). Replace all uses of InputStream.pts for streamcopy with InputStream.dts, which is its value when decoding is not performed. Stop setting InputStream.pts for pure streamcopy. Also, pass InputStream.dts as a parameter to do_streamcopy(), which will allow that function to be decoupled from InputStream completely in the future. --- fftools/ffmpeg.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 5c80f3b65f..d14ae62e86 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -941,7 +941,11 @@ int ifilter_parameters_from_codecpar(InputFilter *ifilter, AVCodecParameters *pa return 0; } -static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *pkt) +/** + * @param dts predicted packet dts in AV_TIME_BASE_Q + */ +static void do_streamcopy(InputStream *ist, OutputStream *ost, + const AVPacket *pkt, int64_t dts) { OutputFile *of = output_files[ost->file_index]; int64_t start_time = (of->start_time == AV_NOPTS_VALUE) ? 0 : of->start_time; @@ -962,16 +966,16 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p if (!ost->streamcopy_started) { if (!ost->copy_prior_start && (pkt->pts == AV_NOPTS_VALUE ? - ist->pts < ost->ts_copy_start : + dts < ost->ts_copy_start : pkt->pts < av_rescale_q(ost->ts_copy_start, AV_TIME_BASE_Q, pkt->time_base))) return; - if (of->start_time != AV_NOPTS_VALUE && ist->pts < of->start_time) + if (of->start_time != AV_NOPTS_VALUE && dts < of->start_time) return; } if (of->recording_time != INT64_MAX && - ist->pts >= of->recording_time + start_time) { + dts >= of->recording_time + start_time) { close_output_stream(ost); return; } @@ -985,7 +989,7 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p opkt->pts = av_rescale_q(pkt->pts, pkt->time_base, opkt->time_base) - ost_tb_start_time; if (pkt->dts == AV_NOPTS_VALUE) { - opkt->dts = av_rescale_q(ist->dts, AV_TIME_BASE_Q, opkt->time_base); + opkt->dts = av_rescale_q(dts, AV_TIME_BASE_Q, opkt->time_base); } else if (ost->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { int duration = av_get_audio_frame_duration2(ist->par, pkt->size); if(!duration) @@ -1639,7 +1643,6 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo if (pkt && pkt->pts != AV_NOPTS_VALUE && !ist->decoding_needed) { ist->first_dts = ist->dts += av_rescale_q(pkt->pts, ist->st->time_base, AV_TIME_BASE_Q); - ist->pts = ist->dts; //unused but better to set it to a value thats not totally wrong } ist->saw_first_ts = 1; } @@ -1658,7 +1661,7 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo if (pkt && pkt->dts != AV_NOPTS_VALUE) { ist->next_dts = ist->dts = av_rescale_q(pkt->dts, ist->st->time_base, AV_TIME_BASE_Q); - if (par->codec_type != AVMEDIA_TYPE_VIDEO || !ist->decoding_needed) + if (par->codec_type != AVMEDIA_TYPE_VIDEO) ist->pts = ist->dts; } @@ -1810,7 +1813,7 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo start_time += f->start_time != AV_NOPTS_VALUE ? f->start_time : 0; start_time += start_at_zero ? 0 : f->start_time_effective; } - if (ist->pts >= f->recording_time + start_time) + if (ist->dts >= f->recording_time + start_time) duration_exceeded = 1; } @@ -1824,7 +1827,7 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo continue; } - do_streamcopy(ist, ost, pkt); + do_streamcopy(ist, ost, pkt, ist->dts); } return !eof_reached;