From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 345CE45D56 for ; Fri, 7 Apr 2023 07:58:06 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CB5FA68AF6C; Fri, 7 Apr 2023 10:58:03 +0300 (EEST) Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C5EE36807B4 for ; Fri, 7 Apr 2023 10:57:56 +0300 (EEST) Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-54c0c86a436so83495667b3.6 for ; Fri, 07 Apr 2023 00:57:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=davyandbeth-com.20210112.gappssmtp.com; s=20210112; t=1680854275; h=content-transfer-encoding:content-language:to:subject:from :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=9BWNsDCDE6QKo6f1AQwY+tk5iBlLVQN3UfueyrXMCv8=; b=Q8fPPhPKFOux1o2eO+OtoEPxRaaY3ktOJGwZQWb6Zum8mq9Bba1aFbQlFzwk3pkaSN /hsyhZ/pa2TG65989XBv3a7muXdCKdUzJIpU1fzJsIe62Snz2z8Dv6AQIacgM+dQcBQO ltvSU/28n3sUdoF8ANl6yPFXGPy9SG+cq79ah70ViPWSgG8nxW20ZiL/8xoKea0FjiyE HipGg3D4cuAM0ZeK+YS8Qwk8k0ersr+dhUYRDUsAKy2W5YNlyKxoE80Fm2BWmjJxew7g YD0xSXeRkRQL6dOmM1Ael5RF5+ZGravUQxruq2jOBr/Ucz9XH1tdv7YRlnOhukBjnIKd NfwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680854275; h=content-transfer-encoding:content-language:to:subject:from :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=9BWNsDCDE6QKo6f1AQwY+tk5iBlLVQN3UfueyrXMCv8=; b=atYoiC98hUxuxBoeWQV8iJ6upLvTj2pjZyNwDsQ2JOAIv/KqqQrxfH6K5hh/j41IZv pYmoh059YhmyTwb+0Yd4bb6OeBbsZWQgGWFKSDRIS4tNhW/Ef1IJoXSlQBlsI77Jrdjl sbFq0+0GF19UFZFQKeHEj6U6QAu2lnkSCvrLCb6YayReHZBLPSEimVTRCfjF1lv6m/gl L4v5OOVF6BBTifqD00gODW9CKE8P8q9he9F2qn80JS/3aKeu+/cONRG062AGK89Nv8ry YvLFRGG1z70mlpq/3yk1j0xx819RPw1qVAODXu3RHV6b5BsXE3ZHIGWSi+QboS2xhOYw /26w== X-Gm-Message-State: AAQBX9dTvZzY4v2pBVe2Mf50xO0QR/ku4aa00LGS8B1XK0nH4eB/E0Lu aZF12aK98yniSXwh0pTTdzKMmqTtiDtQhUw44l3ZMQ== X-Google-Smtp-Source: AKy350ZjE6KLkqBDLysW86GoEvQKgXTDemklZgd4E1dUU/k/ZI5riuxoYcFx96I3a3qRZlQ4p19K9Q== X-Received: by 2002:a0d:ebce:0:b0:54d:c121:6c88 with SMTP id u197-20020a0debce000000b0054dc1216c88mr308822ywe.20.1680854275015; Fri, 07 Apr 2023 00:57:55 -0700 (PDT) Received: from [192.168.1.92] ([68.249.219.17]) by smtp.googlemail.com with ESMTPSA id 145-20020a810b97000000b0054601bc6ce2sm856668ywl.118.2023.04.07.00.57.54 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 07 Apr 2023 00:57:54 -0700 (PDT) Message-ID: <98e50dd9-c85e-3f18-654c-228ea6cb8113@davyandbeth.com> Date: Fri, 7 Apr 2023 02:57:54 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 From: Davy Durham To: ffmpeg-devel@ffmpeg.org Content-Language: en-US Subject: [FFmpeg-devel] [PATCH] fftools/ffmpeg: Added ability to set a input burst time before readrate is enforced X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Implemented is the -irb flag (i.e. "initial read burst") that causes ffmpeg to read the specified number of seconds of input before a given readrate starts to be enforced. All inputs have to reach this point before the readrate is enforced. The reason for this change is, in the scenario of live-streaming by transcoding from an pre-recorded or delayed source to an HLS or DASH webroot, we can more quickly prime the system of the first few seconds before the real-world read rate is imposed. Else, one must wait for an entire segment length before the data can be fetched from the web server. Signed-off-by: Davy Durham --- doc/ffmpeg.texi | 2 ++ fftools/ffmpeg.h | 2 ++ fftools/ffmpeg_demux.c | 13 ++++++++++++- fftools/ffmpeg_opt.c | 3 +++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index d433d60ce9..a519fea192 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -1709,6 +1709,8 @@ it may cause packet loss. It is useful for when flow speed of output packets is important, such as live streaming. @item -re (@emph{input}) Read input at native frame rate. This is equivalent to setting @code{-readrate 1}. +@item -irb @var{seconds} +Set an initial read burst time, in seconds, after which any specified readrate will be enforced. @item -vsync @var{parameter} (@emph{global}) @itemx -fps_mode[:@var{stream_specifier}] @var{parameter} (@emph{output,per-stream}) Set video sync method / framerate mode. vsync is applied to all output video streams diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 823218e214..e057e6da3a 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -124,6 +124,7 @@ typedef struct OptionsContext { int loop; int rate_emu; float readrate; + double initial_read_burst; int accurate_seek; int thread_queue_size; int input_sync_ref; @@ -475,6 +476,7 @@ typedef struct InputFile { int rate_emu; float readrate; + double initial_read_burst; int accurate_seek; /* when looping the input file, this queue is used by decoders to report diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index db05ddb8e9..af423c9be4 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -453,6 +453,7 @@ int ifile_get_packet(InputFile *f, AVPacket **pkt) (f->start_time != AV_NOPTS_VALUE ? f->start_time : 0) ); float scale = f->rate_emu ? 1.0 : f->readrate; + int64_t burst_until = AV_TIME_BASE * f->initial_read_burst; for (i = 0; i < f->nb_streams; i++) { InputStream *ist = f->streams[i]; int64_t stream_ts_offset, pts, now; @@ -460,7 +461,7 @@ int ifile_get_packet(InputFile *f, AVPacket **pkt) stream_ts_offset = FFMAX(ist->first_dts != AV_NOPTS_VALUE ? ist->first_dts : 0, file_start); pts = av_rescale(ist->dts, 1000000, AV_TIME_BASE); now = (av_gettime_relative() - ist->start) * scale + stream_ts_offset; - if (pts > now) + if (pts - burst_until > now) return AVERROR(EAGAIN); } } @@ -1159,6 +1160,16 @@ int ifile_open(const OptionsContext *o, const char *filename) f->rate_emu = 0; } + f->initial_read_burst = o->initial_read_burst ? o->initial_read_burst : 0.0; + if (f->initial_read_burst < 0.0) { + av_log(NULL, AV_LOG_ERROR, "Option -irb for Input #%d is %0.3f; it must be non-negative.\n", nb_input_files, f->initial_read_burst); + exit_program(1); + } + if ((!f->readrate && !f->rate_emu) && f->initial_read_burst) { + av_log(NULL, AV_LOG_WARNING, "Option -irb ignored since neither -readrate nor -re were given\n"); + f->initial_read_burst = 0; + } + d->thread_queue_size = o->thread_queue_size; /* update the current parameters so that they match the one of the input stream */ diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 055275d813..6c55b6cb01 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -1443,6 +1443,9 @@ const OptionDef options[] = { { "readrate", HAS_ARG | OPT_FLOAT | OPT_OFFSET | OPT_EXPERT | OPT_INPUT, { .off = OFFSET(readrate) }, "read input at specified rate", "speed" }, + { "irb", HAS_ARG | OPT_DOUBLE | OPT_OFFSET | + OPT_EXPERT | OPT_INPUT, { .off = OFFSET(initial_read_burst) }, + "The initial amount of input to burst read before imposing any readrate", "seconds" }, { "target", HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_target }, "specify target file type (\"vcd\", \"svcd\", \"dvd\", \"dv\" or \"dv50\" " "with optional prefixes \"pal-\", \"ntsc-\" or \"film-\")", "type" }, -- 2.25.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".