[FFmpeg-devel] [PATCH] dashenc: more accurate time values in playlist.mpd

Alfred E. Heggestad alfred.heggestad at gmail.com
Thu Mar 5 12:01:19 EET 2020


use 3 decimals for the following items:

- minBufferTime
- minimumUpdatePeriod
- timeShiftBufferDepth
- suggestedPresentationDelay

This improves buffering with shaka player

Signed-off-by: Alfred E. Heggestad <alfred.heggestad at gmail.com>
---
  libavformat/dashenc.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 94d463972a..37fbbbc1d2 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -774,7 +774,7 @@ static void write_time(AVIOContext *out, int64_t time)
          avio_printf(out, "%dH", hours);
      if (hours || minutes)
          avio_printf(out, "%dM", minutes);
-    avio_printf(out, "%d.%dS", seconds, fractions / (AV_TIME_BASE / 10));
+    avio_printf(out, "%d.%03dS", seconds, (fractions * 1000) / 
AV_TIME_BASE);
  }

  static void format_date(char *buf, int size, int64_t time_us)
@@ -1171,13 +1171,13 @@ static int write_manifest(AVFormatContext *s, 
int final)
          write_time(out, c->total_duration);
          avio_printf(out, "\"\n");
      } else {
-        int64_t update_period = c->last_duration / AV_TIME_BASE;
+        double update_period = (double)c->last_duration / AV_TIME_BASE;
          char now_str[100];
          if (c->use_template && !c->use_timeline)
              update_period = 500;
-        avio_printf(out, "\tminimumUpdatePeriod=\"PT%"PRId64"S\"\n", 
update_period);
+        avio_printf(out, "\tminimumUpdatePeriod=\"PT%.3fS\"\n", 
update_period);
          if (!c->ldash)
-            avio_printf(out, 
"\tsuggestedPresentationDelay=\"PT%"PRId64"S\"\n", c->last_duration / 
AV_TIME_BASE);
+            avio_printf(out, 
"\tsuggestedPresentationDelay=\"PT%.3fS\"\n", (double)c->last_duration / 
AV_TIME_BASE);
          if (c->availability_start_time[0])
              avio_printf(out, "\tavailabilityStartTime=\"%s\"\n", 
c->availability_start_time);
          format_date(now_str, sizeof(now_str), av_gettime());
-- 
2.20.1 (Apple Git-117)



More information about the ffmpeg-devel mailing list