From patchwork Wed Sep 28 09:55:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 38411 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp93607pzh; Wed, 28 Sep 2022 02:58:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7i9IvRJntvnSi+dvfny5jHi+9B9JZ4QiCGzlRbt7QYkGsw2DwJgH6z9XecD5xm3kFGSacb X-Received: by 2002:a17:907:d8e:b0:783:a4f0:1052 with SMTP id go14-20020a1709070d8e00b00783a4f01052mr11469968ejc.41.1664359100847; Wed, 28 Sep 2022 02:58:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664359100; cv=none; d=google.com; s=arc-20160816; b=Z06FnfQaFKUPLq/7Zoq+t4DvpuN5FEuWTtm7RAUAxueK8C4h1gIwxF0LTd7Qe5MxcV 9yKYqszOxUotEUhwNMb22sE9zcJ9ZWZMnKqF7dP6oFU5BweWh7iH7TzdyjQfnugD293J ol/vea4lT1tWsE68HY/Joyh9SXiEPunB83NnaD4ZDdh8JNqrQObcw+vUmXF8MT/Bhm9K OXTDS+b+tIcvtICoHHggtVB0mYHy0ZMDLPCOQmxMj082LrU3oYrP6Pwumjt0RZiJV+Ah dLrgEmiAXlWU8xk5TxRtifQpQLNvn2BnvY/3qRajwvi96vNPY8um33OFCxGFO2Y/4SWn Oc7g== 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=8vofKsMGjg9uoaWdjOT+eDsdgvVRtt3/Fk1dcCtfDsw=; b=0Kf+T8VLSOVXsGrzLNQgvyHLLPNBmgV92h8eePeRTU9QO7DBlpuYYKrug2976u+xxN 6gd4jpEp5ruAXP4W5oxx7zJRho62Zejl55z/QySZWNKevFql4eFzWrRjgUm6PyWAVEPr Gc2EVXhYvZ82ppqLpInAXrC+2KqtpXrWr32NkHuzql2+giWVGHqWjgrFFI91Hp9ey9+3 HH2Zi/6JM+yBU0pNhNKtcp+kTbq7c449fzAEb/YfkplQ5p8AkiQVu4b+q8WGiZX9ZNT/ B9s+CePs3cVanO0BXPzZ8s0S+Uex6jxW5UpxiyyTmHJOFKVzuBVMBS4yZOdaUYCihHGV htvg== 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 wi7-20020a170906fd4700b007826de24087si2975389ejb.228.2022.09.28.02.58.20; Wed, 28 Sep 2022 02:58:20 -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 E431668BBF8; Wed, 28 Sep 2022 12:58:09 +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 5F62068BBD8 for ; Wed, 28 Sep 2022 12:58:02 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 9FE1C240183 for ; Wed, 28 Sep 2022 11:58:01 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id gXL3wHGI5h9u for ; Wed, 28 Sep 2022 11:58:01 +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 E59312400F4 for ; Wed, 28 Sep 2022 11:58:00 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 305553A014F for ; Wed, 28 Sep 2022 11:58:01 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 28 Sep 2022 11:55:48 +0200 Message-Id: <20220928095556.28209-1-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/9] fftools/ffmpeg: drop the -async option 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: mZgNrW8BBmEr It has been deprecated in favor of the aresample filter for almost 10 years. Another thing this option can do is drop audio timestamps and have them generated by the encoding code or the muxer, but - for encoding, this can already be done with the setpts filter - for muxing this should almost never be done as timestamp generation by the muxer is deprecated, but people who really want to do this can use the setts bitstream filter --- doc/ffmpeg.texi | 12 ------------ fftools/ffmpeg.c | 2 +- fftools/ffmpeg.h | 1 - fftools/ffmpeg_filter.c | 10 ---------- fftools/ffmpeg_mux.c | 3 +-- fftools/ffmpeg_opt.c | 3 --- 6 files changed, 2 insertions(+), 29 deletions(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 42440d93b4..e9020b30d5 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -1697,18 +1697,6 @@ The default is -1.1. One possible usecase is to avoid framedrops in case of noisy timestamps or to increase frame drop precision in case of exact timestamps. -@item -async @var{samples_per_second} -Audio sync method. "Stretches/squeezes" the audio stream to match the timestamps, -the parameter is the maximum samples per second by which the audio is changed. --async 1 is a special case where only the start of the audio stream is corrected -without any later correction. - -Note that the timestamps may be further modified by the muxer, after this. -For example, in the case that the format option @option{avoid_negative_ts} -is enabled. - -This option has been deprecated. Use the @code{aresample} audio filter instead. - @item -adrift_threshold @var{time} Set the minimum difference between timestamps and audio data (in seconds) to trigger adding/dropping samples to make it match the timestamps. This option effectively is diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 69716de6b6..f84701ec75 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1048,7 +1048,7 @@ static void do_audio_out(OutputFile *of, OutputStream *ost, if (!check_recording_time(ost)) return; - if (frame->pts == AV_NOPTS_VALUE || audio_sync_method < 0) + if (frame->pts == AV_NOPTS_VALUE) frame->pts = ost->sync_opts; ost->sync_opts = frame->pts + frame->nb_samples; diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index ede0b2bd96..8acc83e92a 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -656,7 +656,6 @@ extern float audio_drift_threshold; extern float dts_delta_threshold; extern float dts_error_threshold; -extern int audio_sync_method; extern enum VideoSyncMethod video_sync_method; extern float frame_drop_threshold; extern int do_benchmark; diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 17928cea2c..82abb38a93 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -892,16 +892,6 @@ static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter, last_filter = filt_ctx; \ } while (0) - if (audio_sync_method > 0) { - char args[256] = {0}; - - av_strlcatf(args, sizeof(args), "async=%d", audio_sync_method); - av_strlcatf(args, sizeof(args), ":min_hard_comp=%f", audio_drift_threshold); - if (!fg->reconfiguration) - av_strlcatf(args, sizeof(args), ":first_pts=0"); - AUTO_INSERT_FILTER_INPUT("-async", "aresample", args); - } - snprintf(name, sizeof(name), "trim for input stream %d:%d", ist->file_index, ist->st->index); if (copy_ts) { diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index b781e1f5a6..395f7cc89f 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -102,8 +102,7 @@ static int write_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt) goto fail; } - if ((st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && ost->vsync_method == VSYNC_DROP) || - (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && audio_sync_method < 0)) + if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && ost->vsync_method == VSYNC_DROP) pkt->pts = pkt->dts = AV_NOPTS_VALUE; if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 5febe319e4..8f57b699f1 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -157,7 +157,6 @@ float audio_drift_threshold = 0.1; float dts_delta_threshold = 10; float dts_error_threshold = 3600*30; -int audio_sync_method = 0; enum VideoSyncMethod video_sync_method = VSYNC_AUTO; float frame_drop_threshold = 0; int do_benchmark = 0; @@ -3910,8 +3909,6 @@ const OptionDef options[] = { "set video sync method globally; deprecated, use -fps_mode", "" }, { "frame_drop_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, { &frame_drop_threshold }, "frame drop threshold", "" }, - { "async", HAS_ARG | OPT_INT | OPT_EXPERT, { &audio_sync_method }, - "audio sync method", "" }, { "adrift_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, { &audio_drift_threshold }, "audio drift threshold", "threshold" }, { "copyts", OPT_BOOL | OPT_EXPERT, { ©_ts }, From patchwork Wed Sep 28 09:55:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 38410 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp93548pzh; Wed, 28 Sep 2022 02:58:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6MZEuw0fGC0tckfWnGgjP44nvOnEedfChHfSzd89TFlVh9ZH5gcO7iZ3sEN3NRxHZu3SHM X-Received: by 2002:a17:906:6a24:b0:782:5c86:3589 with SMTP id qw36-20020a1709066a2400b007825c863589mr25730617ejc.747.1664359092888; Wed, 28 Sep 2022 02:58:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664359092; cv=none; d=google.com; s=arc-20160816; b=A2coTWu0Actfhfu/tLwldS20MEKnFcWijAQvS0gxFvQsgVYD5HF9er7NiWV94dpNYJ w+SutV7GZlpQuAqm5pE63VPigEtkAYvnEYOwUxkJrRWJhkz2KAg93V8FshHL7SAhedk8 fmh1b2EcSDCZg66dQNtCSbAM7KdvAgcX4yC1W+gnMlR+hNH4tbcU5sbvCfGwOa1QgixV 6fIDjvkcDeifTmQMCJrWxKHFeorl/6UinzNirt1eVczySB0Bm0PRh6AGuyeMQQW3Q1fL kKXD2rnMWEqLv4MxuiYkLrNSFLQOQ+BGDbAfkZ7ET+Sh0FMrUigA+R1l4VfLgRn4p8eh wuTA== 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=aXhMe7TW8NkITfrB+ted5PCwk+ucB3YUqtB+HqJtQpQ=; b=JFsa4sulRl+P20j1Svv6qe3KmMlhAlHLs8l0A4XK0XOsfUsP979J4pZzzaHX2uO/cr HayZq00KCUzE2faPiEYnvmNEPHdi5Dac1extXq15GI1XfjnNleX9fxx/oZdvKnl6DqFQ wNHd+8eDWs15T3Y3wSLI59C3JZsXjiktPWwzRyMthKpj3cByBZbEXo9b1RKX3Y+nIA9U U14kZZW+MJ9PTK3DngQj56dWkWSJ5uc++fr/OGpMw4dGu70GgWN31cxbFFcRxAKnYVzc 6GMP8YKAvcX7lAioaSx8iLlwQ9KJjf4WA2NtWc2BZxpmDH7AymqHUL2QDRk80WQo5GHo c28A== 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 g19-20020a1709065d1300b007313314bb73si4656428ejt.806.2022.09.28.02.58.11; Wed, 28 Sep 2022 02:58:12 -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 C949968BBEB; Wed, 28 Sep 2022 12:58:08 +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 35C6868BBD8 for ; Wed, 28 Sep 2022 12:58:02 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 74B072406C7 for ; Wed, 28 Sep 2022 11:58:01 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id azqoVDpcszBK for ; Wed, 28 Sep 2022 11:58:01 +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 F13FD240183 for ; Wed, 28 Sep 2022 11:58:00 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 3687C3A0520 for ; Wed, 28 Sep 2022 11:58:01 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 28 Sep 2022 11:55:49 +0200 Message-Id: <20220928095556.28209-2-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220928095556.28209-1-anton@khirnov.net> References: <20220928095556.28209-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/9] fftools/ffmpeg: drop always-true conditions 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: E9AbIMi9+W4h in_picture->pts cannot be AV_NOPTS_VALUE, as it is set to ost->sync_opts a few lines above. ost->sync_opts is never AV_NOPTS_VALUE. --- fftools/ffmpeg.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index f84701ec75..2054271c82 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1291,12 +1291,10 @@ static void do_video_out(OutputFile *of, in_picture->quality = enc->global_quality; in_picture->pict_type = 0; - if (ost->forced_kf_ref_pts == AV_NOPTS_VALUE && - in_picture->pts != AV_NOPTS_VALUE) + if (ost->forced_kf_ref_pts == AV_NOPTS_VALUE) ost->forced_kf_ref_pts = in_picture->pts; - pts_time = in_picture->pts != AV_NOPTS_VALUE ? - (in_picture->pts - ost->forced_kf_ref_pts) * av_q2d(enc->time_base) : NAN; + pts_time = (in_picture->pts - ost->forced_kf_ref_pts) * av_q2d(enc->time_base); if (ost->forced_kf_index < ost->forced_kf_count && in_picture->pts >= ost->forced_kf_pts[ost->forced_kf_index]) { ost->forced_kf_index++; From patchwork Wed Sep 28 09:55:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 38419 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp93887pzh; Wed, 28 Sep 2022 02:58:58 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7NdbP6TaxVmuhABvM56M/0+BblnCPxcWkg2odXJOJ6i9DTJrGpaFDR4xbXrAf1zdQUt4B6 X-Received: by 2002:a17:907:2cf0:b0:77b:2ad7:121b with SMTP id hz16-20020a1709072cf000b0077b2ad7121bmr25688374ejc.577.1664359137814; Wed, 28 Sep 2022 02:58:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664359137; cv=none; d=google.com; s=arc-20160816; b=k5xUoQBK5+gmaG2UQuhIIK/R1LaGggjy9Kv2uEUDnwbkNLHHcOuaHh1DzlAAbxrey9 b8Q32tLYOAfPU2KvheBe8+QcfWm5A9Qwk49vI9SGjKPveiOcfQHS9olstBDmmAB6Isr1 RLVwnWtHSfOL2VdqckYBXxU6X+9WDe5cNthB5glKiUVsMFQ+lwPDS5+z9Z9N7KPubjAL tzgmEStiXpwgzkQ0acCyKpeWVuNCy7V6yYLupknCmyutXyKuGwncrvlVDrAPnKjBu9qJ GD1ZxRAbrNISWaKKQ+sJSZIEfct+bxkC3EMt2lnDQNit0kLElNXtmGTv8OU5bGM+y2mB 6Ymw== 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=BRxzisx6eU37D40nebLC8ET6ujTjY7P9r+G9yBJNFzo=; b=qUAIqjXujGRMkRWDvY/WufoZG4/kIa1bHTYDACyuw/wjNvlT8Z7QGSxfrvMm2PlOaf CTeTWnoheOD5fiz4ZrAYVp9HR0DSfs3QfQB/6UI1vmLUuNQ25VNjHR1CgoG6hYI8sMdI c4hDbXRQK1SA43saCLk2oFn8nFhDeP7WGYhsiI6XHYjXcRts0Pz6Serx9Bw3hFYNu1B+ 7aI3uwg+MXEyV3R5ImmvFw+ckjZCNsr2T98C7J5uJxzEqw71sLAhHxsfvpRN3BQrNeiE b7GB2G25i7O2YC+bdEvC3P8WV6ZNvM05CioJ7o5ehC3CYZhsHpLdavdTJEJulx9KmLz/ MNhw== 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 u17-20020a50c2d1000000b00457e6752422si1998510edf.189.2022.09.28.02.58.56; Wed, 28 Sep 2022 02:58: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 0FE5E68BC14; Wed, 28 Sep 2022 12:58:15 +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 6DBCE68B8EF for ; Wed, 28 Sep 2022 12:58:07 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 607A52404E4 for ; Wed, 28 Sep 2022 11:58:03 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 29NEuRryN0CL for ; Wed, 28 Sep 2022 11:58:02 +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 02F772404F5 for ; Wed, 28 Sep 2022 11:58:01 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 37C6C3A0D7F for ; Wed, 28 Sep 2022 11:58:01 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 28 Sep 2022 11:55:50 +0200 Message-Id: <20220928095556.28209-3-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220928095556.28209-1-anton@khirnov.net> References: <20220928095556.28209-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/9] fftools/ffmpeg: move forced keyframe processing into its own function 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: 0tA+szPaxim8 --- fftools/ffmpeg.c | 108 +++++++++++++++++++++++++---------------------- 1 file changed, 58 insertions(+), 50 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 2054271c82..833df0b167 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1133,6 +1133,63 @@ static void do_subtitle_out(OutputFile *of, } } +static enum AVPictureType forced_kf_apply(OutputStream *ost, + const AVFrame *in_picture, int dup_idx) +{ + AVCodecContext *enc = ost->enc_ctx; + double pts_time; + + if (ost->forced_kf_ref_pts == AV_NOPTS_VALUE) + ost->forced_kf_ref_pts = in_picture->pts; + + pts_time = (in_picture->pts - ost->forced_kf_ref_pts) * av_q2d(enc->time_base); + if (ost->forced_kf_index < ost->forced_kf_count && + in_picture->pts >= ost->forced_kf_pts[ost->forced_kf_index]) { + ost->forced_kf_index++; + goto force_keyframe; + } else if (ost->forced_keyframes_pexpr) { + double res; + ost->forced_keyframes_expr_const_values[FKF_T] = pts_time; + res = av_expr_eval(ost->forced_keyframes_pexpr, + ost->forced_keyframes_expr_const_values, NULL); + ff_dlog(NULL, "force_key_frame: n:%f n_forced:%f prev_forced_n:%f t:%f prev_forced_t:%f -> res:%f\n", + ost->forced_keyframes_expr_const_values[FKF_N], + ost->forced_keyframes_expr_const_values[FKF_N_FORCED], + ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_N], + ost->forced_keyframes_expr_const_values[FKF_T], + ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_T], + res); + + ost->forced_keyframes_expr_const_values[FKF_N] += 1; + + if (res) { + ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_N] = + ost->forced_keyframes_expr_const_values[FKF_N] - 1; + ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_T] = + ost->forced_keyframes_expr_const_values[FKF_T]; + ost->forced_keyframes_expr_const_values[FKF_N_FORCED] += 1; + goto force_keyframe; + } + } else if ( ost->forced_keyframes + && !strncmp(ost->forced_keyframes, "source", 6) + && in_picture->key_frame==1 + && !dup_idx) { + goto force_keyframe; + } else if ( ost->forced_keyframes + && !strncmp(ost->forced_keyframes, "source_no_drop", 14) + && !dup_idx) { + ost->dropped_keyframe = 0; + if ((in_picture->key_frame == 1) || ost->dropped_keyframe) + goto force_keyframe; + } + + return AV_PICTURE_TYPE_NONE; + +force_keyframe: + av_log(NULL, AV_LOG_DEBUG, "Forced keyframe at time %f\n", pts_time); + return AV_PICTURE_TYPE_I; +} + /* May modify/reset next_picture */ static void do_video_out(OutputFile *of, OutputStream *ost, @@ -1272,8 +1329,6 @@ static void do_video_out(OutputFile *of, /* duplicates frame if needed */ for (i = 0; i < nb_frames; i++) { AVFrame *in_picture; - int forced_keyframe = 0; - double pts_time; if (i < nb0_frames && ost->last_frame->buf[0]) { in_picture = ost->last_frame; @@ -1289,54 +1344,7 @@ static void do_video_out(OutputFile *of, return; in_picture->quality = enc->global_quality; - in_picture->pict_type = 0; - - if (ost->forced_kf_ref_pts == AV_NOPTS_VALUE) - ost->forced_kf_ref_pts = in_picture->pts; - - pts_time = (in_picture->pts - ost->forced_kf_ref_pts) * av_q2d(enc->time_base); - if (ost->forced_kf_index < ost->forced_kf_count && - in_picture->pts >= ost->forced_kf_pts[ost->forced_kf_index]) { - ost->forced_kf_index++; - forced_keyframe = 1; - } else if (ost->forced_keyframes_pexpr) { - double res; - ost->forced_keyframes_expr_const_values[FKF_T] = pts_time; - res = av_expr_eval(ost->forced_keyframes_pexpr, - ost->forced_keyframes_expr_const_values, NULL); - ff_dlog(NULL, "force_key_frame: n:%f n_forced:%f prev_forced_n:%f t:%f prev_forced_t:%f -> res:%f\n", - ost->forced_keyframes_expr_const_values[FKF_N], - ost->forced_keyframes_expr_const_values[FKF_N_FORCED], - ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_N], - ost->forced_keyframes_expr_const_values[FKF_T], - ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_T], - res); - if (res) { - forced_keyframe = 1; - ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_N] = - ost->forced_keyframes_expr_const_values[FKF_N]; - ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_T] = - ost->forced_keyframes_expr_const_values[FKF_T]; - ost->forced_keyframes_expr_const_values[FKF_N_FORCED] += 1; - } - - ost->forced_keyframes_expr_const_values[FKF_N] += 1; - } else if ( ost->forced_keyframes - && !strncmp(ost->forced_keyframes, "source", 6) - && in_picture->key_frame==1 - && !i) { - forced_keyframe = 1; - } else if ( ost->forced_keyframes - && !strncmp(ost->forced_keyframes, "source_no_drop", 14) - && !i) { - forced_keyframe = (in_picture->key_frame == 1) || ost->dropped_keyframe; - ost->dropped_keyframe = 0; - } - - if (forced_keyframe) { - in_picture->pict_type = AV_PICTURE_TYPE_I; - av_log(NULL, AV_LOG_DEBUG, "Forced keyframe at time %f\n", pts_time); - } + in_picture->pict_type = forced_kf_apply(ost, in_picture, i); ret = submit_encode_frame(of, ost, in_picture); if (ret < 0 && ret != AVERROR_EOF) From patchwork Wed Sep 28 09:55:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 38416 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp93820pzh; Wed, 28 Sep 2022 02:58:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7kL7waeILANR/B0HqQddSkeCYdkEQZW3PnlNO3CGhgBa8fSs7hl4DMTPwlRV6ymktAWiLK X-Received: by 2002:a17:907:608f:b0:787:a1ae:1d3b with SMTP id ht15-20020a170907608f00b00787a1ae1d3bmr149274ejc.431.1664359127393; Wed, 28 Sep 2022 02:58:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664359127; cv=none; d=google.com; s=arc-20160816; b=t4Q/qrXw7nmCC7fwURMYnOu0EzgKXB2kl6hiKAUJA6hfyGkWMdXKR77uepWWh2fYYr j/MjKa5Z/R61JIu2iOrHkP/na/vdGwcue6NRIN3YfqhTMVA//uYlcrHL9TaesWBgO3VQ 8AFoy969N98/q387uHQKYgTuaHBjx0LLuBv5dHXn8NjYSgOQgBD6hq6iD9UBJ4Q5Mrew MoLDMhEVIELPcezjbAz7/pVuWRHHbji19+9dSNnVUcnzSErM8RzvNXxE5KFWZg+XeLBg Rjaz+Ujp3y/NfjHOrL5nupb8Igjp/rLx7hItFqozMd0n1N7CJQpcT8i4stNgAokKGycA ShJA== 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=vtrbvm2+BEVU41TEs0QWX1OEcn7IEI7hwaMWW63Vg30=; b=eAZ6wyolpbuT7S0BX2qgfS4zyoFFwv38aA8qsk0uF14CIcCHg60PKfUMdczL71Moir kSZ2RsOg5hNMRULuHRlFvxT0eEHEmCRC6MAu6dqWW5H84uA/7ImOoJey8PgGsmMi9nGN XbueOrw2PwlNPYZxTiekrmL64P+qS1eiry2knVC5Rdqg9v91f0PKKNZqkX9xAm+n+nmX fTCq6x2OxcFzpAtAgYe+Sa3d4fe0NGU4fQvIg5t1xmb/3x1T/r3zUoKF8hbgaDV4CFgP dqAIu8zNneaF3B990TvnQprgZvdnbsi3GzJdoIiM0MLDMMg709McE6gi/O98iWeYcZHp jaIA== 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 bx12-20020a170906a1cc00b007804e2f5bf5si3844515ejb.193.2022.09.28.02.58.46; Wed, 28 Sep 2022 02:58:47 -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 1724F68BC0D; Wed, 28 Sep 2022 12:58:14 +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 E544368BBF1 for ; Wed, 28 Sep 2022 12:58:03 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 317872404F8 for ; Wed, 28 Sep 2022 11:58:03 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 3_o7F2cH8b6N for ; Wed, 28 Sep 2022 11:58:01 +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 F236F2404E4 for ; Wed, 28 Sep 2022 11:58:00 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 438F13A0DA0 for ; Wed, 28 Sep 2022 11:58:01 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 28 Sep 2022 11:55:51 +0200 Message-Id: <20220928095556.28209-4-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220928095556.28209-1-anton@khirnov.net> References: <20220928095556.28209-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/9] fftools/ffmpeg: cosmetics 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: Et0JvQ7Xtj8U Reindent after previous commit, apply some style fixes. --- fftools/ffmpeg.c | 85 ++++++++++++++++++++++++------------------------ 1 file changed, 42 insertions(+), 43 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 833df0b167..697971167c 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1137,51 +1137,50 @@ static enum AVPictureType forced_kf_apply(OutputStream *ost, const AVFrame *in_picture, int dup_idx) { AVCodecContext *enc = ost->enc_ctx; - double pts_time; - - if (ost->forced_kf_ref_pts == AV_NOPTS_VALUE) - ost->forced_kf_ref_pts = in_picture->pts; - - pts_time = (in_picture->pts - ost->forced_kf_ref_pts) * av_q2d(enc->time_base); - if (ost->forced_kf_index < ost->forced_kf_count && - in_picture->pts >= ost->forced_kf_pts[ost->forced_kf_index]) { - ost->forced_kf_index++; - goto force_keyframe; - } else if (ost->forced_keyframes_pexpr) { - double res; - ost->forced_keyframes_expr_const_values[FKF_T] = pts_time; - res = av_expr_eval(ost->forced_keyframes_pexpr, - ost->forced_keyframes_expr_const_values, NULL); - ff_dlog(NULL, "force_key_frame: n:%f n_forced:%f prev_forced_n:%f t:%f prev_forced_t:%f -> res:%f\n", - ost->forced_keyframes_expr_const_values[FKF_N], - ost->forced_keyframes_expr_const_values[FKF_N_FORCED], - ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_N], - ost->forced_keyframes_expr_const_values[FKF_T], - ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_T], - res); - - ost->forced_keyframes_expr_const_values[FKF_N] += 1; - - if (res) { - ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_N] = - ost->forced_keyframes_expr_const_values[FKF_N] - 1; - ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_T] = - ost->forced_keyframes_expr_const_values[FKF_T]; - ost->forced_keyframes_expr_const_values[FKF_N_FORCED] += 1; - goto force_keyframe; - } - } else if ( ost->forced_keyframes - && !strncmp(ost->forced_keyframes, "source", 6) - && in_picture->key_frame==1 - && !dup_idx) { + double pts_time; + + if (ost->forced_kf_ref_pts == AV_NOPTS_VALUE) + ost->forced_kf_ref_pts = in_picture->pts; + + pts_time = (in_picture->pts - ost->forced_kf_ref_pts) * av_q2d(enc->time_base); + if (ost->forced_kf_index < ost->forced_kf_count && + in_picture->pts >= ost->forced_kf_pts[ost->forced_kf_index]) { + ost->forced_kf_index++; + goto force_keyframe; + } else if (ost->forced_keyframes_pexpr) { + double res; + ost->forced_keyframes_expr_const_values[FKF_T] = pts_time; + res = av_expr_eval(ost->forced_keyframes_pexpr, + ost->forced_keyframes_expr_const_values, NULL); + ff_dlog(NULL, "force_key_frame: n:%f n_forced:%f prev_forced_n:%f t:%f prev_forced_t:%f -> res:%f\n", + ost->forced_keyframes_expr_const_values[FKF_N], + ost->forced_keyframes_expr_const_values[FKF_N_FORCED], + ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_N], + ost->forced_keyframes_expr_const_values[FKF_T], + ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_T], + res); + + ost->forced_keyframes_expr_const_values[FKF_N] += 1; + + if (res) { + ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_N] = + ost->forced_keyframes_expr_const_values[FKF_N] - 1; + ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_T] = + ost->forced_keyframes_expr_const_values[FKF_T]; + ost->forced_keyframes_expr_const_values[FKF_N_FORCED] += 1; goto force_keyframe; - } else if ( ost->forced_keyframes - && !strncmp(ost->forced_keyframes, "source_no_drop", 14) - && !dup_idx) { - ost->dropped_keyframe = 0; - if ((in_picture->key_frame == 1) || ost->dropped_keyframe) - goto force_keyframe; } + } else if (ost->forced_keyframes && + !strncmp(ost->forced_keyframes, "source", 6) && + in_picture->key_frame == 1 && !dup_idx) { + goto force_keyframe; + } else if (ost->forced_keyframes && + !strncmp(ost->forced_keyframes, "source_no_drop", 14) && + !dup_idx) { + ost->dropped_keyframe = 0; + if ((in_picture->key_frame == 1) || ost->dropped_keyframe) + goto force_keyframe; + } return AV_PICTURE_TYPE_NONE; From patchwork Wed Sep 28 09:55:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 38420 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp93947pzh; Wed, 28 Sep 2022 02:59:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5FqihkteG6VxB7FvbmEb49/sp2icZuBZXEzhap8+4MlCWhcKAW2ZeyTI53YVdAiA/Mq0vJ X-Received: by 2002:a05:6402:35d6:b0:44e:f45a:8f79 with SMTP id z22-20020a05640235d600b0044ef45a8f79mr32506210edc.393.1664359146606; Wed, 28 Sep 2022 02:59:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664359146; cv=none; d=google.com; s=arc-20160816; b=VfNsAoWvGw+qgkpVrWK9zcHHESZrC9tGdkGsf7cJ4FU/xxp7TUR67rYH3EzYT2XNGd /7jKCA8PxUR7K7uzBzis7L/iYnjv7sR8SaBt+FT0TSRPDX1sqobt/MztIL5FuSUfbwxh OT1ejP0zZ9QparSVnu7JGrHGGZ01p9Dq88uXKheTuAHCZiqMEKdyQqs1UBjqbKKIn6or TqE8bZ5OK4rzoEiIyGOFQTzl0/ZMxfPEW23dhJ3Z47BBwADXiFI8JQEN95PMWL76Nf5T wFZVrF1MiJfiloWJ4RiaTFjIkiS36+6YnWfovXTWdiUetdWMqw3yhXGsNOf02CrVdtYs E9NQ== 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=3vFY5ZyUJFj1orh7IthA4YTibjE+dxUtU2FKinRrURQ=; b=eEHK1RZSKQ/Z1dY27R7erQPyMpwRdj+OkCVcVgOWNkRArdvpXK3gkgrgGHlxscDyn9 lcVylgnmB1gV+jSGTyYbFDj+px+k6HBbmbwxL44MjIxlci1TPHoXuo1uMyXa2d4EfPzl JJxGFT3fBCoUPdp5DoX3C1stZWUBoQNXTd5Tie+b/T1M38Yb50PhEqKoDM9fMtiScKCP ioUFxAmOe28U77Foiw5AXKeHmYwoxoMoH7owusl8FdX55wyzWGj0rwR67ZrDn93X7dXy fJtmGtl002Oze2ABxgTN2BEPm+CKKPi1yYTH6fVocs0/Cxh13vv/+tVh97ooqvJie5UL GlUA== 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 bo5-20020a0564020b2500b00457d66f2813si2715125edb.596.2022.09.28.02.59.06; Wed, 28 Sep 2022 02:59:06 -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 3718E68BC00; Wed, 28 Sep 2022 12:58:16 +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 76A6E68BBBB for ; Wed, 28 Sep 2022 12:58:07 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 9E86C2404F5 for ; Wed, 28 Sep 2022 11:58:03 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id ZbXvaVWM63CM for ; Wed, 28 Sep 2022 11:58:03 +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 2B83E240591 for ; Wed, 28 Sep 2022 11:58:01 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 44E353A13BB for ; Wed, 28 Sep 2022 11:58:01 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 28 Sep 2022 11:55:52 +0200 Message-Id: <20220928095556.28209-5-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220928095556.28209-1-anton@khirnov.net> References: <20220928095556.28209-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 5/9] fftools/ffmpeg: drop never-set OutputStream.first_pts 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: vKj91gMgXJEP --- fftools/ffmpeg.c | 2 +- fftools/ffmpeg.h | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 697971167c..971c146fea 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -763,7 +763,7 @@ static int check_recording_time(OutputStream *ost) OutputFile *of = output_files[ost->file_index]; if (of->recording_time != INT64_MAX && - av_compare_ts(ost->sync_opts - ost->first_pts, ost->enc_ctx->time_base, of->recording_time, + av_compare_ts(ost->sync_opts, ost->enc_ctx->time_base, of->recording_time, AV_TIME_BASE_Q) >= 0) { close_output_stream(ost); return 0; diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 8acc83e92a..a9883c0442 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -495,9 +495,6 @@ typedef struct OutputStream { /* input pts and corresponding output pts for A/V sync */ int64_t sync_opts; /* output frame counter, could be changed to some true timestamp */ // FIXME look at frame_number - /* pts of the first frame encoded for this stream, used for limiting - * recording time */ - int64_t first_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 */ From patchwork Wed Sep 28 09:55:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 38412 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp93676pzh; Wed, 28 Sep 2022 02:58:29 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7bsV94ma9V/Rk3aiFz/iUW+2B5ds3tO/be9AANi9/YfKU8En8DHNYOe2+jO0gHO7px2Mb5 X-Received: by 2002:a17:907:3e25:b0:783:29e1:c1ce with SMTP id hp37-20020a1709073e2500b0078329e1c1cemr15719912ejc.303.1664359109213; Wed, 28 Sep 2022 02:58:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664359109; cv=none; d=google.com; s=arc-20160816; b=wjx+EpisvB+jr02mFkZUXqZ4F8FAsx66ofG+VA1pjNDAgeb8vi0mPfAEABPq8sNn+F 8PxqKor0g27cYc16p9cBT471glnDJBLY4Ck6wJ90RAAYWekPjqrUanIAC0udsYph7r77 rYt3iWoWeiC/ho0m/VCSrjvUJhilRt7EXWfJM85dBDC/cfFu/52q815C/CG8LulHzY1o IWUbQlK23JuT4Qw53eoW+NuQRt/845MiOmy9z/BWzDrXFSKVjoWvl2fRkMlurNPvsnAH /jhpX4ULKN4g4RzSwIJlKwvaBUp9R/pP4HA4R/wS7SAOuODGJ8Cig/2z2Il9w05qqL1O YrlA== 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=G3JHYbVN2ZAMLnlPVnJ33hNJPI3hRMyRcQQG7mXwMbI=; b=vp7oMWZaxhqJU6pgMzinbmSXqXn9xIcWHO8XVWUcYp9lvMI4RKFlyrtUb8Hit2Qngs gQLzNixupGw9QtHXI7/Gkg/okytySYwXMMtCuSSnhAw4gm1hIwk6Tn02YUNYsLaZkJFc YcczNzZeER51Hebw/MztNTjzv3BfakCELG3M/EOAnnz06v2xB+ub7Rzv9zPlC3GAPckJ IeI98gpnB5AHycsKqsQJoUVbv9JwEJj0PbSqXnN7AfIWBuOzLlIGLHah72ap+YtBgAmA ETGq/jj37Jl5ax3RV4ROzI002Jm/B0wQZeef8xfLD4nSwxAlRBZNt4tAp0vvR95zhySj HPyA== 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 eb8-20020a0564020d0800b004570e4887desi5809874edb.437.2022.09.28.02.58.28; Wed, 28 Sep 2022 02:58: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 0679168BBDB; Wed, 28 Sep 2022 12:58:11 +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 BAE0668BBD8 for ; Wed, 28 Sep 2022 12:58:02 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 0BF622400F4 for ; Wed, 28 Sep 2022 11:58:02 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id uOSVL-EHUpHy for ; Wed, 28 Sep 2022 11:58:01 +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 03B812404F7 for ; Wed, 28 Sep 2022 11:58:01 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 45DD53A15EA for ; Wed, 28 Sep 2022 11:58:01 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 28 Sep 2022 11:55:53 +0200 Message-Id: <20220928095556.28209-6-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220928095556.28209-1-anton@khirnov.net> References: <20220928095556.28209-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 6/9] fftools/ffmpeg: stop setting OutputStream.sync_opts 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: 2bqsO85WKCsv It is not used for anything. --- fftools/ffmpeg.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 971c146fea..1a6768f6c2 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1934,8 +1934,6 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p opkt->duration = av_rescale_q(pkt->duration, ist->st->time_base, ost->mux_timebase); - ost->sync_opts += opkt->duration; - output_packet(of, opkt, ost, 0); ost->streamcopy_started = 1; From patchwork Wed Sep 28 09:55:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 38413 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp93752pzh; Wed, 28 Sep 2022 02:58:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Wi6BcFexPCRnqkTvvhkxi34sMb3Dm5I79tZ7lG+SUHC9HZfG5EOLyv+7wirKHz6jMttq7 X-Received: by 2002:a17:907:318b:b0:740:33f2:9e8 with SMTP id xe11-20020a170907318b00b0074033f209e8mr26551266ejb.138.1664359117877; Wed, 28 Sep 2022 02:58:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664359117; cv=none; d=google.com; s=arc-20160816; b=iIOEyM/ZyMSs7v18SGche0D1kvtab39GIV2m6bhgJ42jiNPjmECZ2FxQpi/ZpP8UyE xe982GAaIXp3I1/NRcf8t4Z7D0KqpYhZu4ckmRqr9WGrsN6qzvavdI1SNEb399JhZUEq EUA2a5g/aXKOUIc71Jq/85wjzNxUgqmNiaryDO5RkWCcknlcj7onF2Jw+O6d64KHpgQ7 l3VWyNbBSPNjBwrBLEUDjdLpUtwXMkLF/LGbNmIsauRscFtyL/v3QnLZvspnJdpoSxGW 1bEB3X0pa0+aR7lrTQ4Mb0PjN1ofKgdz3FEnV2cQjfwu5DF3Cq0kf0VLv8gn2rzZbZb1 GE8g== 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=HUlpByiD86zIHx7v3pHKqy8NLAzxTgeKxXIJqY9/1z4=; b=LgbCXs6Fdn8Mo/oFeOU5LiLadmyEryl1D8/8MyfNRfYbCWy/fiyS3N1qOQ+zL5IMdf utR7+XGyRyOoN3rMTCxjpG7aPpTnBj0dlDDN0pWuKS1cpxCqX3Uafxw/l+PjSaol6bly eRWeD2zIRvW8rCqS0G8G97BUMBx+mYLn7Ye2YH5Exww8O/ovhHadm3oFTwbNnQWAkC37 RXLrIm2dVct+F99sVkzpCRI7tHFGSPa6PnF8uzhpgHQOeb2gDnV4nq2t4oU4cWFUFwmQ BOr2GfIE+iXAxPSuhwSXnO+nroq4IPzFC1Q90OWczSi/PU0gpJrcVX8KaSNdxl4WzPa2 duzg== 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 g11-20020a170906c18b00b0072b7fac8a7asi3500232ejz.926.2022.09.28.02.58.37; Wed, 28 Sep 2022 02:58: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 02C3768BBDD; Wed, 28 Sep 2022 12:58:13 +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 6231668BBE1 for ; Wed, 28 Sep 2022 12:58:03 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id A4A122404F7 for ; Wed, 28 Sep 2022 11:58:02 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id udnIRlY52m1O for ; Wed, 28 Sep 2022 11:58:02 +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 053682404F8 for ; Wed, 28 Sep 2022 11:58:01 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 46BED3A168C for ; Wed, 28 Sep 2022 11:58:01 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 28 Sep 2022 11:55:54 +0200 Message-Id: <20220928095556.28209-7-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220928095556.28209-1-anton@khirnov.net> References: <20220928095556.28209-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 7/9] fftools/ffmpeg: pass the timestamp to check_recording_time() 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: Mi7jcpRP2WYK Stop setting OutputStream.sync_opts for subtitle encoding, as it is now unused. --- fftools/ffmpeg.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 1a6768f6c2..40c01b1c65 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -758,13 +758,12 @@ fail: } -static int check_recording_time(OutputStream *ost) +static int check_recording_time(OutputStream *ost, int64_t ts, AVRational tb) { OutputFile *of = output_files[ost->file_index]; if (of->recording_time != INT64_MAX && - av_compare_ts(ost->sync_opts, ost->enc_ctx->time_base, of->recording_time, - AV_TIME_BASE_Q) >= 0) { + av_compare_ts(ts, tb, of->recording_time, AV_TIME_BASE_Q) >= 0) { close_output_stream(ost); return 0; } @@ -1045,7 +1044,7 @@ static void do_audio_out(OutputFile *of, OutputStream *ost, adjust_frame_pts_to_encoder_tb(of, ost, frame); - if (!check_recording_time(ost)) + if (!check_recording_time(ost, ost->sync_opts, ost->enc_ctx->time_base)) return; if (frame->pts == AV_NOPTS_VALUE) @@ -1091,8 +1090,7 @@ static void do_subtitle_out(OutputFile *of, for (i = 0; i < nb; i++) { unsigned save_num_rects = sub->num_rects; - ost->sync_opts = av_rescale_q(pts, AV_TIME_BASE_Q, enc->time_base); - if (!check_recording_time(ost)) + if (!check_recording_time(ost, pts, AV_TIME_BASE_Q)) return; ret = av_new_packet(pkt, subtitle_out_max_size); @@ -1339,7 +1337,7 @@ static void do_video_out(OutputFile *of, in_picture->pts = ost->sync_opts; - if (!check_recording_time(ost)) + if (!check_recording_time(ost, in_picture->pts, ost->enc_ctx->time_base)) return; in_picture->quality = enc->global_quality; From patchwork Wed Sep 28 09:55:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 38421 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp94015pzh; Wed, 28 Sep 2022 02:59:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4YzlouJ4d7U0eBHEZVuo+P2F22GwnGVULRB4WRZdHbBVi7kuDBVZkwnz5MN3P06Sgm2+vu X-Received: by 2002:a17:907:16a4:b0:783:a3b4:2cf6 with SMTP id hc36-20020a17090716a400b00783a3b42cf6mr11641085ejc.620.1664359155989; Wed, 28 Sep 2022 02:59:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664359155; cv=none; d=google.com; s=arc-20160816; b=aRJokv5EN5iLwVxL0D6py0O8kKaqGl309eaRgLSOfZllT1qC+uDTZaLAzeJgRVKaEl p5i6ZZUHN63FHah7ZEEQRx/kte0RS94W8/UrAox0zpwVSv6oewlzq7Iv3f2WN3eQp44k ZbB1uIgZhwsZLisOXtA3Ydmj/yLH6ZBInOx6cB58+3PsL8FOpU1BUS4HeZdsGt0u6QWv nAm8FQzL3h90/u0mbidYNhPBqA7GdXRLy1Vr3HiKM+zIhiYEROGUtVzFmVJ2oZWD0+hP gKqpx2o/uuWg/q2GBE0NJVfoMMCbsCCl6HsyRI5LtMYceyHhSahpz35rx34R2CNDY2it lqlw== 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=aYCH0KQo4ApngsQfGTOUIWhb1JV5VDpZIGr2BHRHhjg=; b=EVuhATLfnYUCsMDx18fxeZnWpHyX/v7N6TEQAdI81OL1NGKSjWFEOFGTQ1hL57o7J+ XF3gPr4H5k+XgYcr45t1tgANaE1cyHlD8br2m1E8glMMo0vy6KW2l+UowgMSIPX4mI9T osyaT3I64A+Vihj2YPCtKc/ey4JhPC503r16YeV6ZqFEakw8xhUiWnT3qPnK3vQHgPCc twT7O8+pnf6NjSOImu6C7AGuMY18lIxWiyXVy9n1LrSSLOe6Y2LZaR7+YZvnkle20Zrn oY+fkJ+zXyk7I2cnY6ZoXQiXYzKvjn/uqYypiqppcpYswbAefZGZFRRnx+31b6AD5Iqq u6Xw== 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 l8-20020aa7d948000000b0044e9c289ae5si3775390eds.155.2022.09.28.02.59.15; Wed, 28 Sep 2022 02:59: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 4BB6868BC02; Wed, 28 Sep 2022 12:58: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 9754868BBE9 for ; Wed, 28 Sep 2022 12:58:07 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id EB500240591 for ; Wed, 28 Sep 2022 11:58:03 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id K0ZlBeBnWMWX for ; Wed, 28 Sep 2022 11:58:03 +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 36D7B2405EC for ; Wed, 28 Sep 2022 11:58:01 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 47BD73A169F for ; Wed, 28 Sep 2022 11:58:01 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 28 Sep 2022 11:55:55 +0200 Message-Id: <20220928095556.28209-8-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220928095556.28209-1-anton@khirnov.net> References: <20220928095556.28209-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 8/9] fftools/ffmpeg: rename OutputStream.sync_opts to next_pts 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: 8bBphCngUV0O The current name is confusing. --- fftools/ffmpeg.c | 22 ++++++++++++---------- fftools/ffmpeg.h | 6 +++--- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 40c01b1c65..6deca8bfbf 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1044,12 +1044,12 @@ static void do_audio_out(OutputFile *of, OutputStream *ost, adjust_frame_pts_to_encoder_tb(of, ost, frame); - if (!check_recording_time(ost, ost->sync_opts, ost->enc_ctx->time_base)) + if (!check_recording_time(ost, ost->next_pts, ost->enc_ctx->time_base)) return; if (frame->pts == AV_NOPTS_VALUE) - frame->pts = ost->sync_opts; - ost->sync_opts = frame->pts + frame->nb_samples; + frame->pts = ost->next_pts; + ost->next_pts = frame->pts + frame->nb_samples; ret = submit_encode_frame(of, ost, frame); if (ret < 0 && ret != AVERROR_EOF) @@ -1230,7 +1230,9 @@ static void do_video_out(OutputFile *of, ost->last_nb0_frames[1], ost->last_nb0_frames[2]); } else { - delta0 = sync_ipts - ost->sync_opts; // delta0 is the "drift" between the input frame (next_picture) and where it would fall in the output. + /* delta0 is the "drift" between the input frame (next_picture) and + * where it would fall in the output. */ + delta0 = sync_ipts - ost->next_pts; delta = delta0 + duration; /* by default, we output a single frame */ @@ -1245,7 +1247,7 @@ static void do_video_out(OutputFile *of, av_log(NULL, AV_LOG_VERBOSE, "Past duration %f too large\n", -delta0); } else av_log(NULL, AV_LOG_DEBUG, "Clipping frame in rate conversion by %f\n", -delta0); - sync_ipts = ost->sync_opts; + sync_ipts = ost->next_pts; duration += delta0; delta0 = 0; } @@ -1256,7 +1258,7 @@ static void do_video_out(OutputFile *of, av_log(NULL, AV_LOG_DEBUG, "Not duplicating %d initial frames\n", (int)lrintf(delta0)); delta = duration; delta0 = 0; - ost->sync_opts = llrint(sync_ipts); + ost->next_pts = llrint(sync_ipts); } case VSYNC_CFR: // FIXME set to 0.5 after we fix some dts/pts bugs like in avidec.c @@ -1275,13 +1277,13 @@ static void do_video_out(OutputFile *of, if (delta <= -0.6) nb_frames = 0; else if (delta > 0.6) - ost->sync_opts = llrint(sync_ipts); + ost->next_pts = llrint(sync_ipts); next_picture->duration = duration; break; case VSYNC_DROP: case VSYNC_PASSTHROUGH: next_picture->duration = duration; - ost->sync_opts = llrint(sync_ipts); + ost->next_pts = llrint(sync_ipts); break; default: av_assert0(0); @@ -1335,7 +1337,7 @@ static void do_video_out(OutputFile *of, if (!in_picture) return; - in_picture->pts = ost->sync_opts; + in_picture->pts = ost->next_pts; if (!check_recording_time(ost, in_picture->pts, ost->enc_ctx->time_base)) return; @@ -1347,7 +1349,7 @@ static void do_video_out(OutputFile *of, if (ret < 0 && ret != AVERROR_EOF) exit_program(1); - ost->sync_opts++; + ost->next_pts++; ost->vsync_frame_number++; } diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index a9883c0442..d466a1ff9f 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -492,9 +492,9 @@ typedef struct OutputStream { AVStream *st; /* stream in the output file */ /* number of frames emitted by the video-encoding sync code */ int64_t vsync_frame_number; - /* input pts and corresponding output pts - for A/V sync */ - int64_t sync_opts; /* output frame counter, could be changed to some true timestamp */ // FIXME look at frame_number + /* 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 */ From patchwork Wed Sep 28 09:55:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 38422 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp94072pzh; Wed, 28 Sep 2022 02:59:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7fJQUkiI7qPXDiO4NVhlRZS1NH8NseyUx2jhR6tGHOmZzyb7B8MPDBoDl3GCrNdq6DxOZz X-Received: by 2002:a17:907:2c74:b0:77d:5a0e:bb8f with SMTP id ib20-20020a1709072c7400b0077d5a0ebb8fmr25769603ejc.579.1664359164489; Wed, 28 Sep 2022 02:59:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664359164; cv=none; d=google.com; s=arc-20160816; b=zms3klk6yZaNo5AKXqJRPv5SDn4EHpGnntqbRXXpqJVpYB+HGbtWh4a5I7oQNXMLDa dtfszDqfNW21MaYoPPRbGcgMJQwLHKty1iTjKpSl1RJCChrdI6RlLpNiNxUhZsGRU0vr pbIVWtkM5vdrirvQSc+Vfa8QMPQdm7nksxq2WZ0TJH9YgsiUuVHQyDAEHGY34yh2QpRW oC5u/JnIUUl14M7UQNHuM8Ji7fWMo8S6oCqkziCvJBZOGdBTOacUdiZyoVnJzbzc0Mi/ bqWKtHvyYKBUs2Nn2iMibcR9UvvFuhVUAcPLl06nJ1ookz04adlUh3LI70v/EltcnGkv ntYQ== 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=oC/G6vAsqoSOTIelD7hncCyCfbzDOuPSsw4VmQcgjQA=; b=bgCrLhzbd2zpf5fublgKIYjGTmYVUDIFi/FCD7PkdlDj7NzIvd4J6Io1dAWonJQkxj RW0u5RCxV+ZLo/ct/6lke4MmFOYSvpAnafLP7Cf11k+Rmymd0Nn0/6t9zhVM+/Kzlz5o /Jp0ApJ5GLvQ5w3ObM4Rif9DbqyCLdKmi2oFixHgXE4vrH9p6dT8rr91OO+uv8xVtalc v+jan0sKgTxfzwA/luWid+gCUpMohJ8DJN7+kpkO8YV0P6UbZ8AyjcWMf+Sb59MsR4pN lo84e09+UhDCzF+PDsCBVfDMt/r6slaVzo7SpULApl/IdCN2neVt+3jSpT042whtDXPZ d1tg== 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 nc19-20020a1709071c1300b0078276be53d5si4678613ejc.0.2022.09.28.02.59.24; Wed, 28 Sep 2022 02:59: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 49AB568BC10; Wed, 28 Sep 2022 12:58: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 A120268BBDD for ; Wed, 28 Sep 2022 12:58:07 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 3F1A12405EC for ; Wed, 28 Sep 2022 11:58:04 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id nYmx-0f_i6NG for ; Wed, 28 Sep 2022 11:58:03 +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 36F632405F9 for ; Wed, 28 Sep 2022 11:58:01 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 48D433A1767 for ; Wed, 28 Sep 2022 11:58:01 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 28 Sep 2022 11:55:56 +0200 Message-Id: <20220928095556.28209-9-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220928095556.28209-1-anton@khirnov.net> References: <20220928095556.28209-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 9/9] fftools/ffmpeg: move some code from init_output_stream() to init_output_stream_encode() 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: 8Xjxm4j1gn2Z The code is subtitle-encoding-specific, so this is a more appropriate place for it. --- fftools/ffmpeg.c | 58 ++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 6deca8bfbf..754172e568 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -3129,6 +3129,34 @@ static int init_output_stream_encode(OutputStream *ost, AVFrame *frame) enc_ctx->width = input_streams[ost->source_index]->par->width; enc_ctx->height = input_streams[ost->source_index]->par->height; } + if (dec_ctx && dec_ctx->subtitle_header) { + /* ASS code assumes this buffer is null terminated so add extra byte. */ + ost->enc_ctx->subtitle_header = av_mallocz(dec_ctx->subtitle_header_size + 1); + if (!ost->enc_ctx->subtitle_header) + return AVERROR(ENOMEM); + memcpy(ost->enc_ctx->subtitle_header, dec_ctx->subtitle_header, + dec_ctx->subtitle_header_size); + ost->enc_ctx->subtitle_header_size = dec_ctx->subtitle_header_size; + } + if (ist && ist->dec->type == AVMEDIA_TYPE_SUBTITLE && + enc_ctx->codec_type == AVMEDIA_TYPE_SUBTITLE) { + int input_props = 0, output_props = 0; + AVCodecDescriptor const *input_descriptor = + avcodec_descriptor_get(ist->dec->id); + AVCodecDescriptor const *output_descriptor = + avcodec_descriptor_get(ost->enc_ctx->codec_id); + if (input_descriptor) + input_props = input_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB); + if (output_descriptor) + output_props = output_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB); + if (input_props && output_props && input_props != output_props) { + av_log(NULL, AV_LOG_ERROR, + "Subtitle encoding currently only possible from text to text " + "or bitmap to bitmap"); + return AVERROR_INVALIDDATA; + } + } + break; case AVMEDIA_TYPE_DATA: break; @@ -3156,23 +3184,13 @@ static int init_output_stream(OutputStream *ost, AVFrame *frame, if (ost->enc_ctx) { const AVCodec *codec = ost->enc_ctx->codec; - AVCodecContext *dec = NULL; InputStream *ist; ret = init_output_stream_encode(ost, frame); if (ret < 0) return ret; - if ((ist = get_input_stream(ost))) - dec = ist->dec_ctx; - if (dec && dec->subtitle_header) { - /* ASS code assumes this buffer is null terminated so add extra byte. */ - ost->enc_ctx->subtitle_header = av_mallocz(dec->subtitle_header_size + 1); - if (!ost->enc_ctx->subtitle_header) - return AVERROR(ENOMEM); - memcpy(ost->enc_ctx->subtitle_header, dec->subtitle_header, dec->subtitle_header_size); - ost->enc_ctx->subtitle_header_size = dec->subtitle_header_size; - } + ist = get_input_stream(ost); if (!av_dict_get(ost->encoder_opts, "threads", NULL, 0)) av_dict_set(&ost->encoder_opts, "threads", "auto", 0); @@ -3184,24 +3202,6 @@ static int init_output_stream(OutputStream *ost, AVFrame *frame, return ret; } - if (ist && ist->dec->type == AVMEDIA_TYPE_SUBTITLE && codec->type == AVMEDIA_TYPE_SUBTITLE) { - int input_props = 0, output_props = 0; - AVCodecDescriptor const *input_descriptor = - avcodec_descriptor_get(dec->codec_id); - AVCodecDescriptor const *output_descriptor = - avcodec_descriptor_get(ost->enc_ctx->codec_id); - if (input_descriptor) - input_props = input_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB); - if (output_descriptor) - output_props = output_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB); - if (input_props && output_props && input_props != output_props) { - snprintf(error, error_len, - "Subtitle encoding currently only possible from text to text " - "or bitmap to bitmap"); - return AVERROR_INVALIDDATA; - } - } - if ((ret = avcodec_open2(ost->enc_ctx, codec, &ost->encoder_opts)) < 0) { if (ret == AVERROR_EXPERIMENTAL) abort_codec_experimental(codec, 1);