diff mbox series

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

Message ID 50e536e2-ca80-85fe-ecf7-8526643ac617@gmail.com
State New
Headers show
Series [FFmpeg-devel] dashenc: more accurate time values in playlist.mpd
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork warning Failed to apply patch

Commit Message

Alfred E. Heggestad March 5, 2020, 10:01 a.m. UTC
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@gmail.com>
---
  libavformat/dashenc.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)

  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());

Comments

Moritz Barsnick March 5, 2020, 10:40 a.m. UTC | #1
On Thu, Mar 05, 2020 at 11:01:19 +0100, Alfred E. Heggestad wrote:
> -            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);

Your patch is corrupted by newlines, which makes it impossible to apply
it easily (or even automatically). Please resend it as an attachment,
or using "git send-email".

Thanks,
Moritz
Alfred E. Heggestad March 5, 2020, 10:43 a.m. UTC | #2
On 05/03/2020 11:40, Moritz Barsnick wrote:
> On Thu, Mar 05, 2020 at 11:01:19 +0100, Alfred E. Heggestad wrote:
>> -            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);
> 
> Your patch is corrupted by newlines, which makes it impossible to apply
> it easily (or even automatically). Please resend it as an attachment,
> or using "git send-email".
> 

thanks,

here is the patch attached.



/alfred
From c569a1d970d27e814f54dbacf5dac7a337efb0d6 Mon Sep 17 00:00:00 2001
From: "Alfred E. Heggestad" <alfred.heggestad@gmail.com>
Date: Thu, 5 Mar 2020 10:52:29 +0100
Subject: [PATCH] dashenc: more accurate time values in playlist.mpd

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@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());
Carl Eugen Hoyos March 5, 2020, 2:37 p.m. UTC | #3
Am Do., 5. März 2020 um 11:08 Uhr schrieb Alfred E. Heggestad
<alfred.heggestad@gmail.com>:

> -        int64_t update_period = c->last_duration / AV_TIME_BASE;
> +        double update_period = (double)c->last_duration / AV_TIME_BASE;

Can't you instead do int64 update_period = last_duration * 1000 / AV_TIME_BASE
to avoid using doubles that will potentially break automatic testing?

Carl Eugen
Alfred E. Heggestad March 5, 2020, 3:32 p.m. UTC | #4
On 05/03/2020 15:37, Carl Eugen Hoyos wrote:
> Am Do., 5. März 2020 um 11:08 Uhr schrieb Alfred E. Heggestad
> <alfred.heggestad@gmail.com>:
> 
>> -        int64_t update_period = c->last_duration / AV_TIME_BASE;
>> +        double update_period = (double)c->last_duration / AV_TIME_BASE;
> 
> Can't you instead do int64 update_period = last_duration * 1000 / AV_TIME_BASE
> to avoid using doubles that will potentially break automatic testing?
> 

in this case the update_period will be in [milliseconds] units.
how should I print that ?


or we can use write_time() to print it, in AV_TIME_BASE units:


             int64_t update_period = c->last_duration;

             avio_printf(out, "\tminimumUpdatePeriod=\"");
             write_time(out, update_period);
             avio_printf(out, "\"\n");





/alfred
Jeyapal, Karthick March 9, 2020, 3:36 a.m. UTC | #5
On 3/5/20 9:02 PM, Alfred E. Heggestad wrote:
>
>
> On 05/03/2020 15:37, Carl Eugen Hoyos wrote:
>> Am Do., 5. März 2020 um 11:08 Uhr schrieb Alfred E. Heggestad
>> <alfred.heggestad@gmail.com>:
>>
>>> -        int64_t update_period = c->last_duration / AV_TIME_BASE;
>>> +        double update_period = (double)c->last_duration / AV_TIME_BASE; 
>>
>> Can't you instead do int64 update_period = last_duration * 1000 / AV_TIME_BASE
>> to avoid using doubles that will potentially break automatic testing?
>>
>
> in this case the update_period will be in [milliseconds] units.
> how should I print that ?
I guess in any case a . will be present that can break any automatic testing.
I would suggest having this feature of printing double(.3f) under an option with default as false.
In that way there anyone relying on the current behavior is not affected.
>
>
> or we can use write_time() to print it, in AV_TIME_BASE units:
>
>
>             int64_t update_period = c->last_duration;
>
>             avio_printf(out, "\tminimumUpdatePeriod=\"");
>             write_time(out, update_period);
>             avio_printf(out, "\"\n");
>
>
>
>
>
> /alfred
> _______________________________________________
> 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".
diff mbox series

Patch

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);
  }