diff mbox series

[FFmpeg-devel] fftools/ffmpeg: Added ability to set a input burst time before readrate is enforced

Message ID b3a9a2a8-f8f6-0a52-123f-d23097f3851c@davyandbeth.com
State New
Headers show
Series [FFmpeg-devel] fftools/ffmpeg: Added ability to set a input burst time before readrate is enforced | expand

Checks

Context Check Description
yinshiyou/configure_loongarch64 warning Failed to apply patch
andriy/configure_x86 warning Failed to apply patch

Commit Message

Davy Durham April 7, 2023, 7:50 a.m. UTC
Implemented is the -irb <seconds> 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 <ddurham@users.sourceforge.net>
---
  doc/ffmpeg.texi      | 2 ++
  fftools/ffmpeg.h     | 2 ++
  fftools/ffmpeg_opt.c | 3 +++
  3 files changed, 7 insertions(+)

      { "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" },

Comments

Davy Durham April 7, 2023, 7:54 a.m. UTC | #1
Apologies.. ignore this patch, it was accidentally incomplete.  Complete 
patch on the way.

On 4/7/23 02:50, Davy Durham wrote:
> Implemented is the -irb <seconds> 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 <ddurham@users.sourceforge.net>
> ---
>  doc/ffmpeg.texi      | 2 ++
>  fftools/ffmpeg.h     | 2 ++
>  fftools/ffmpeg_opt.c | 3 +++
>  3 files changed, 7 insertions(+)
>
> 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_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" },
diff mbox series

Patch

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_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" },