[5/5] dashenc: Force the start timestamp to zero

Message ID 1416234526-54560-5-git-send-email-martin@martin.st
State Deferred
Headers show

Commit Message

Martin Storsjö Nov. 17, 2014, 2:28 p.m.
This works around an issue in the current git version of dash.js.
---
 libavformat/dashenc.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Derek Buitenhuis Nov. 17, 2014, 2:32 p.m. | #1
On 11/17/2014 2:28 PM, Martin Storsjö wrote:
> This works around an issue in the current git version of dash.js.
> ---
>  libavformat/dashenc.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)

Hacks shouldn't really be exposed by default, IMO...

- Derek
Martin Storsjö Nov. 17, 2014, 2:37 p.m. | #2
On Mon, 17 Nov 2014, Derek Buitenhuis wrote:

> On 11/17/2014 2:28 PM, Martin Storsjö wrote:
>> This works around an issue in the current git version of dash.js.
>> ---
>>  libavformat/dashenc.c | 9 ++++++++-
>>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> Hacks shouldn't really be exposed by default, IMO...

Yeah, I'll see if I can dig into dash.js and see what's happening and why, 
and if I can fix it before the next release is made there.

// Martin

Patch

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 19f8ab6..d12c56e 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -716,8 +716,15 @@  static int dash_write_packet(AVFormatContext *s, AVPacket *pkt)
             return ret;
     }
 
-    if (!os->packets_written)
+    if (!os->packets_written) {
         os->start_pts = pkt->pts;
+        if (os->segment_index == 0 && s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_MAKE_ZERO &&
+            c->use_template && c->use_timeline) {
+            // Newer dash.js versions have problems when the start pts
+            // isn't zero, even if using a proper Period start.
+            os->start_pts = os->first_pts = 0;
+        }
+    }
     os->max_pts = FFMAX(os->max_pts, pkt->pts + pkt->duration);
     os->packets_written++;
     return ff_write_chained(os->ctx, 0, pkt, s);