From patchwork Fri Apr 5 16:12:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47851 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1071203pzd; Fri, 5 Apr 2024 09:16:42 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWdcxb5uPGv1mv20vzseS0uAW0ALb+KHZMV+FliSIPn6COzOBbEjfgCVEF/IuPAWi8TTwjug9y79Bb5tJ+MOnGXJ1LWDqGchM+mQA== X-Google-Smtp-Source: AGHT+IFjcr/0XFYUK/xhcQoxIoVE4ElaylbXNaX7/i75jJ7rWF6tsJkUptEQ32VfHidilWmsOfwN X-Received: by 2002:a17:907:9611:b0:a46:f279:8f77 with SMTP id gb17-20020a170907961100b00a46f2798f77mr1724889ejc.43.1712333801894; Fri, 05 Apr 2024 09:16:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712333801; cv=none; d=google.com; s=arc-20160816; b=yfWcTghtkN02I8Q6/5SQF6iqPhb015xdJWb0IiogZxaoRpjuJ4IfLv/dDHVgfVufKr ueflni34gHS+Xzxj+ICtjRKBlZkZQXZfNHb1mWm2LXC7wvJ0DNkWEXCjpdTQq1CA/vRQ +N1O8XpnbpaZdZ8pvCgykSZQEmJM+V3lxncuTJUiJrd+fRpr23Ah/FgRmII/VULGaf1D QN08LDgdxbJGsz/NbvTnYrNm50ok7/qRViPw0mV49JyieeVi7tgqPvWXs15tvI4bw5Nb TIeGMoRtCMlds1l9XSonixNC2refW244HVqJ0+giycFmG0cAQTYVYxNURKv2xglhrnEX ejsw== 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:dkim-signature:delivered-to; bh=M8l2J4h9FQniaOlJFRK0Zw8GXVfjwZDihhER7UO/8+k=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=iVZiEPm+SCOBNvlo+YWddkWsFymUr7PtCCdBxNv+eUC1kGe9kXMSkKSe0sFcqMorL4 lrrOMihJZCFToV5wFjEcuSKXxbaGPFh7EASxLzd0Y5m6yLyOh6MgvnFrHOiVU3Nths4U JIYE+4ehXUQiuEWN9vFsCPHznG8csQP/hDZ2zRkrPYl4Z30RfKmQDAUNvWgjeUxIteXl rD1guvjLgxtnOyXfPPEHF1DVdqPYHozbvM/Ri6U7OTe9PMcMKukOIQYj97lhfUVWHIYG Pikc7qaltq8btH39BAnpEMaiE7v1+Rb0saH5vKwJkc2AA+J4EXiajP9UOBkbZzLTcyfy EeJw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b="WG/sDNsr"; 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 um10-20020a170906cf8a00b00a51a9b05607si532333ejb.411.2024.04.05.09.16.41; Fri, 05 Apr 2024 09:16:41 -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; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b="WG/sDNsr"; 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 E77EE68D2E9; Fri, 5 Apr 2024 19:13:33 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8B7F268D16D for ; Fri, 5 Apr 2024 19:13:10 +0300 (EEST) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=WG/sDNsr; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 46A6B4D8E for ; Fri, 5 Apr 2024 18:13:07 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id DLcwAeNwRc3B for ; Fri, 5 Apr 2024 18:13:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1712333583; bh=HQ/ZYQ+11mo4mitQI7BDA34AAvVpoB2M6liSOctdMm4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=WG/sDNsrmaa61vWppsa4krr9EanNV1h3kd/CcLs7DTLXe1aKy8bOMvwrQ/gl6lxsM RyzXjwxrl+6rzY31wqkWdivD3/0CQBGDE+xB5EHrM1KwuoZtcfZACJEEOP911sWLWL XtiQWtPo/1ufEb6vUIYhZnQ8V+f9AElUvspkffV+ToZ2Dfy+XUk/sTZjGbx3gBjeB6 ryn+dhyrgZTBiF44OhO7INfJw6rGRHNUlL1sb9JcikYvi1uGR9siPiU6p9zEhCIbKS oVGad3rJ2oJc5Fzk8hE7esCxd4qK6t29XgFplSLAh/s2Ld+Pb9xRMxwfxVlgnhrX8M Z1YYDpYQKlAXg== 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 mail1.khirnov.net (Postfix) with ESMTPS id D93164D96 for ; Fri, 5 Apr 2024 18:13:02 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 6A1C63A16DC for ; Fri, 5 Apr 2024 18:12:56 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Apr 2024 18:12:02 +0200 Message-ID: <20240405161212.26167-21-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240405161212.26167-1-anton@khirnov.net> References: <20240405161212.26167-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 21/31] fftools/ffmpeg_filter: pass trim parameters through OutputFilterOptions 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: udTrnecLPqUU Do not read them from OutputStream directly. Will allow decoupling filtering from encoding in future commits. --- fftools/ffmpeg.h | 2 ++ fftools/ffmpeg_filter.c | 11 +++++++---- fftools/ffmpeg_mux_init.c | 2 ++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 4059b1dcc3..8e773165da 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -279,6 +279,8 @@ typedef struct OutputFilterOptions { // Overrides encoder pixel formats when set. const enum AVPixelFormat *pix_fmts; + int64_t trim_start_us; + int64_t trim_duration_us; int64_t ts_offset; /* Desired output timebase. diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index dc9556bbc1..225fa4bda2 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -220,6 +220,8 @@ typedef struct OutputFilterPriv { const int *sample_rates; AVRational enc_timebase; + int64_t trim_start_us; + int64_t trim_duration_us; // offset for output timestamps, in AV_TIME_BASE_Q int64_t ts_offset; int64_t next_pts; @@ -812,6 +814,9 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, ofp->ts_offset = opts->ts_offset; ofp->enc_timebase = opts->output_tb; + ofp->trim_start_us = opts->trim_start_us; + ofp->trim_duration_us = opts->trim_duration_us; + ofp->name = av_strdup(opts->name); if (!ofp->name) return AVERROR(EINVAL); @@ -1349,8 +1354,6 @@ static int configure_output_video_filter(FilterGraph *fg, AVFilterGraph *graph, OutputFilter *ofilter, AVFilterInOut *out) { OutputFilterPriv *ofp = ofp_from_ofilter(ofilter); - OutputStream *ost = ofilter->ost; - OutputFile *of = ost->file; AVFilterContext *last_filter = out->filter_ctx; AVBPrint bprint; int pad_idx = out->pad_idx; @@ -1411,7 +1414,7 @@ static int configure_output_video_filter(FilterGraph *fg, AVFilterGraph *graph, } snprintf(name, sizeof(name), "trim_out_%s", ofp->name); - ret = insert_trim(of->start_time, of->recording_time, + ret = insert_trim(ofp->trim_start_us, ofp->trim_duration_us, &last_filter, &pad_idx, name); if (ret < 0) return ret; @@ -1503,7 +1506,7 @@ static int configure_output_audio_filter(FilterGraph *fg, AVFilterGraph *graph, } snprintf(name, sizeof(name), "trim for output %s", ofp->name); - ret = insert_trim(of->start_time, of->recording_time, + ret = insert_trim(ofp->trim_start_us, ofp->trim_duration_us, &last_filter, &pad_idx, name); if (ret < 0) goto fail; diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 51c31eeb72..6e19b98abd 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -1389,6 +1389,8 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, .sws_opts = o->g->sws_dict, .swr_opts = o->g->swr_opts, .output_tb = enc_tb, + .trim_start_us = mux->of.start_time, + .trim_duration_us = mux->of.recording_time, .ts_offset = mux->of.start_time == AV_NOPTS_VALUE ? 0 : mux->of.start_time, .flags = OFILTER_FLAG_DISABLE_CONVERT * !!keep_pix_fmt |