Dash-Industry-Forum / dash.js

A reference client implementation for the playback of MPEG DASH via Javascript and compliant browsers.
http://reference.dashif.org/dash.js/nightly/samples/dash-if-reference-player/index.html
Other
5.09k stars 1.67k forks source link

Version 1 event messages appear late in media timeline #3196

Closed mpegdash-user closed 4 years ago

mpegdash-user commented 4 years ago

When using version 1 event messages, their presentation time in the media timeline is bumped out (roughly) double the expected time from the start time.

When playing video with inband version 1 event messages (emsg), theDashAdapter.js code uses version 0 logic and adds the presentation_time_delta field of the eventBox object to the presentation time of the current segment to create the presentationTime for the event.

// grab the presentation time delta
const presentationTimeDelta = eventBox.presentation_time_delta;
... // then use it to calculate a presentation time in the future.
const presentationTime = startTime * timescale + presentationTimeDelta;

The code overloads the eventBox.presentation_time_delta field such that it contains the presentation_time_delta for version 0 event messages and presentation_time for version 1 event messages.

Propose modifying the code to treat the presentation_time_delta variable differently depending on the version of event message box you are using. Here is a diff:

302c302,308
diff orig/DashAdapter.js new/DashAdapter.js
<         const presentationTimeDelta = eventBox.presentation_time_delta;
---
>         if (eventBox.version === 0 ) {
>           const presentationTimeDelta = eventBox.presentation_time_delta;
>           const presentationTime = startTime * timescale + presentationTimeDelta;
>         } else {
>           const presentationTimeDelta = 0;
>           const presentationTime = eventBox.presentation_time_delta;
>         }
306c312
<         const presentationTime = startTime * timescale + presentationTimeDelta;
---
>

This produces the expected behavior.

Environment
Steps to reproduce
  1. create a video stream composed of multiple 2 second segments
  2. place two (2) version 1 emsg boxes at the beginning of each segment. The presentation_time should be set to (segment number) * (segment duration.)
  3. be sure to modify your .mpd file to signal inband events: <InbandEventStream schemeIdUri="urn:scte:scte35:2013:xml";" value="999" />
  4. modify the samples/advanced/listening-to-SCTE-EMSG-events.html page
Observed behaviour
  1. Load the modified events.html page.
  2. Move the timebar scrubber to time 00:00:00.
  3. Allow the video to play for a few seconds.
  4. You should see a notification at time 00:00 with PresentationTime 00000 and PresentationTimeDelta 00000
  5. a notification will probably not appear at time 00:01
  6. the notification at time 00:02 will have PresentationTime 180000 and PresentationTimeDelta 90000
  7. a notification will probably not appear at time 00:03
dsilhavy commented 4 years ago

@mpegdash-user Can you provide a sample stream with version 1 emsg boxes?

dsilhavy commented 4 years ago

I will defer that until we have a testvector

dsilhavy commented 4 years ago

Implemented here https://github.com/Dash-Industry-Forum/dash.js/pull/3325, thanks