diff options
-rw-r--r-- | doc/muxers.texi | 8 | ||||
-rw-r--r-- | libavformat/dashenc.c | 18 | ||||
-rw-r--r-- | libavformat/version.h | 2 |
3 files changed, 25 insertions, 3 deletions
diff --git a/doc/muxers.texi b/doc/muxers.texi index 856ed74e56..d341827a86 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -356,6 +356,14 @@ protocol. Applicable only for HTTP output. Set an intended target latency in seconds (fractional value can be set) for serving. Applicable only when @var{streaming} and @var{write_prft} options are enabled. This is an informative fields clients can use to measure the latency of the service. +@item min_playback_rate @var{min_playback_rate} +Set the minimum playback rate indicated as appropriate for the purposes of automatically +adjusting playback latency and buffer occupancy during normal playback by clients. + +@item max_playback_rate @var{max_playback_rate} +Set the maximum playback rate indicated as appropriate for the purposes of automatically +adjusting playback latency and buffer occupancy during normal playback by clients. + @end table @anchor{framecrc} diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index ef1bedd18d..86329b7f9a 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -194,6 +194,8 @@ typedef struct DASHContext { int profile; int64_t target_latency; int target_latency_refid; + AVRational min_playback_rate; + AVRational max_playback_rate; } DASHContext; static struct codec_string { @@ -1203,14 +1205,19 @@ static int write_manifest(AVFormatContext *s, int final) av_free(escaped); } avio_printf(out, "\t</ProgramInformation>\n"); + + avio_printf(out, "\t<ServiceDescription id=\"0\">\n"); if (!final && c->target_latency && c->target_latency_refid >= 0) { - avio_printf(out, "\t<ServiceDescription id=\"0\">\n"); avio_printf(out, "\t\t<Latency target=\"%"PRId64"\"", c->target_latency / 1000); if (s->nb_streams > 1) avio_printf(out, " referenceId=\"%d\"", c->target_latency_refid); avio_printf(out, "/>\n"); - avio_printf(out, "\t</ServiceDescription>\n"); } + if (av_cmp_q(c->min_playback_rate, (AVRational) {1, 1}) || + av_cmp_q(c->max_playback_rate, (AVRational) {1, 1})) + avio_printf(out, "\t\t<PlaybackRate min=\"%.2f\" max=\"%.2f\"/>\n", + av_q2d(c->min_playback_rate), av_q2d(c->max_playback_rate)); + avio_printf(out, "\t</ServiceDescription>\n"); if (c->window_size && s->nb_streams > 0 && c->streams[0].nb_segments > 0 && !c->use_template) { OutputStream *os = &c->streams[0]; @@ -1423,6 +1430,11 @@ static int dash_init(AVFormatContext *s) c->target_latency = 0; } + if (av_cmp_q(c->max_playback_rate, c->min_playback_rate) < 0) { + av_log(s, AV_LOG_WARNING, "Minimum playback rate value is higer than the Maximum. Both will be ignored\n"); + c->min_playback_rate = c->max_playback_rate = (AVRational) {1, 1}; + } + av_strlcpy(c->dirname, s->url, sizeof(c->dirname)); ptr = strrchr(c->dirname, '/'); if (ptr) { @@ -2370,6 +2382,8 @@ static const AVOption options[] = { { "dvb_dash", "DVB-DASH profile", 0, AV_OPT_TYPE_CONST, {.i64 = MPD_PROFILE_DVB }, 0, UINT_MAX, E, "mpd_profile"}, { "http_opts", "HTTP protocol options", OFFSET(http_opts), AV_OPT_TYPE_DICT, { .str = NULL }, 0, 0, E }, { "target_latency", "Set desired target latency for Low-latency dash", OFFSET(target_latency), AV_OPT_TYPE_DURATION, { .i64 = 0 }, 0, INT_MAX, E }, + { "min_playback_rate", "Set desired minimum playback rate", OFFSET(min_playback_rate), AV_OPT_TYPE_RATIONAL, { .dbl = 1.0 }, 0.5, 1.5, E }, + { "max_playback_rate", "Set desired maximum playback rate", OFFSET(max_playback_rate), AV_OPT_TYPE_RATIONAL, { .dbl = 1.0 }, 0.5, 1.5, E }, { NULL }, }; diff --git a/libavformat/version.h b/libavformat/version.h index 18c2f5fec2..719cda6b98 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -33,7 +33,7 @@ // Also please add any ticket numbers that you believe might be affected here #define LIBAVFORMAT_VERSION_MAJOR 58 #define LIBAVFORMAT_VERSION_MINOR 42 -#define LIBAVFORMAT_VERSION_MICRO 100 +#define LIBAVFORMAT_VERSION_MICRO 101 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ |