* [FFmpeg-devel] [PATCH] fftools/ffmpeg: Added ability to set a input burst time before readrate is enforced
@ 2023-04-07 7:50 Davy Durham
2023-04-07 7:54 ` Davy Durham
0 siblings, 1 reply; 6+ messages in thread
From: Davy Durham @ 2023-04-07 7:50 UTC (permalink / raw)
To: ffmpeg-devel
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" },
--
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".
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [FFmpeg-devel] [PATCH] fftools/ffmpeg: Added ability to set a input burst time before readrate is enforced
2023-04-07 7:50 [FFmpeg-devel] [PATCH] fftools/ffmpeg: Added ability to set a input burst time before readrate is enforced Davy Durham
@ 2023-04-07 7:54 ` Davy Durham
0 siblings, 0 replies; 6+ messages in thread
From: Davy Durham @ 2023-04-07 7:54 UTC (permalink / raw)
To: ffmpeg-devel
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" },
_______________________________________________
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".
^ permalink raw reply [flat|nested] 6+ messages in thread
* [FFmpeg-devel] [PATCH] fftools/ffmpeg: Added ability to set a input burst time before readrate is enforced
@ 2023-04-07 7:57 Davy Durham
2023-04-28 8:01 ` Anton Khirnov
0 siblings, 1 reply; 6+ messages in thread
From: Davy Durham @ 2023-04-07 7:57 UTC (permalink / raw)
To: ffmpeg-devel
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_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".
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [FFmpeg-devel] [PATCH] fftools/ffmpeg: Added ability to set a input burst time before readrate is enforced
2023-04-07 7:57 Davy Durham
@ 2023-04-28 8:01 ` Anton Khirnov
0 siblings, 0 replies; 6+ messages in thread
From: Anton Khirnov @ 2023-04-28 8:01 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Your email client mangled the patch, so it cannot be applied as is.
Quoting Davy Durham (2023-04-07 09:57:54)
> 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_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}
I think 'irb' is too short for an option that modifies behavior of
another, rather obscure, option. How about -readrate_burst or
-readrate_delay or something along these lines?
> @@ -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;
Use f as the log context, then you can drop the input file number in the
string itself.
Same below.
Otherwise seems reasonable.
--
Anton Khirnov
_______________________________________________
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".
^ permalink raw reply [flat|nested] 6+ messages in thread
* [FFmpeg-devel] [PATCH] fftools/ffmpeg: Added ability to set a input burst time before readrate is enforced
@ 2023-02-23 8:05 Davy Durham
2023-03-17 6:50 ` Davy Durham
0 siblings, 1 reply; 6+ messages in thread
From: Davy Durham @ 2023-02-23 8:05 UTC (permalink / raw)
To: ffmpeg-devel
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.c | 3 ++-
fftools/ffmpeg.h | 2 ++
fftools/ffmpeg_opt.c | 13 +++++++++++++
4 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 767df69b7f..16ab1a336f 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -1633,6 +1633,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.c b/fftools/ffmpeg.c
index e7384f052a..e4697c8772 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -3768,6 +3768,7 @@ static int get_input_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 = input_streams[f->ist_index + i];
int64_t stream_ts_offset, pts, now;
@@ -3775,7 +3776,7 @@ static int get_input_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);
}
}
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 391a35cf50..aa079ab3e9 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -116,6 +116,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;
@@ -422,6 +423,7 @@ typedef struct InputFile {
int nb_streams_warn; /* number of streams that the user was
warned of */
int rate_emu;
float readrate;
+ double initial_read_burst;
int accurate_seek;
AVPacket *pkt;
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 6e18a4a23e..57aa4929fa 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -1378,6 +1378,16 @@ static int open_input_file(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;
+ }
+
f->pkt = av_packet_alloc();
if (!f->pkt)
exit_program(1);
@@ -3734,6 +3744,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".
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [FFmpeg-devel] [PATCH] fftools/ffmpeg: Added ability to set a input burst time before readrate is enforced
2023-02-23 8:05 Davy Durham
@ 2023-03-17 6:50 ` Davy Durham
0 siblings, 0 replies; 6+ messages in thread
From: Davy Durham @ 2023-03-17 6:50 UTC (permalink / raw)
To: ffmpeg-devel
Any update on this submission? I never heard anything back, and I don't
see it included in any branch. Or, is it that I just don't know where to
look for the status of patches?
Thanks
On 2/23/23 02:05, 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.c | 3 ++-
> fftools/ffmpeg.h | 2 ++
> fftools/ffmpeg_opt.c | 13 +++++++++++++
> 4 files changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
> index 767df69b7f..16ab1a336f 100644
> --- a/doc/ffmpeg.texi
> +++ b/doc/ffmpeg.texi
> @@ -1633,6 +1633,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.c b/fftools/ffmpeg.c
> index e7384f052a..e4697c8772 100644
> --- a/fftools/ffmpeg.c
> +++ b/fftools/ffmpeg.c
> @@ -3768,6 +3768,7 @@ static int get_input_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 = input_streams[f->ist_index + i];
> int64_t stream_ts_offset, pts, now;
> @@ -3775,7 +3776,7 @@ static int get_input_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);
> }
> }
> diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
> index 391a35cf50..aa079ab3e9 100644
> --- a/fftools/ffmpeg.h
> +++ b/fftools/ffmpeg.h
> @@ -116,6 +116,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;
> @@ -422,6 +423,7 @@ typedef struct InputFile {
> int nb_streams_warn; /* number of streams that the user was
> warned of */
> int rate_emu;
> float readrate;
> + double initial_read_burst;
> int accurate_seek;
> AVPacket *pkt;
> diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
> index 6e18a4a23e..57aa4929fa 100644
> --- a/fftools/ffmpeg_opt.c
> +++ b/fftools/ffmpeg_opt.c
> @@ -1378,6 +1378,16 @@ static int open_input_file(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;
> + }
> +
> f->pkt = av_packet_alloc();
> if (!f->pkt)
> exit_program(1);
> @@ -3734,6 +3744,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" },
_______________________________________________
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".
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-04-28 8:01 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-07 7:50 [FFmpeg-devel] [PATCH] fftools/ffmpeg: Added ability to set a input burst time before readrate is enforced Davy Durham
2023-04-07 7:54 ` Davy Durham
-- strict thread matches above, loose matches on Subject: below --
2023-04-07 7:57 Davy Durham
2023-04-28 8:01 ` Anton Khirnov
2023-02-23 8:05 Davy Durham
2023-03-17 6:50 ` Davy Durham
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git