Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: parse mp4 webvtt segments #1545

Merged
merged 12 commits into from
Oct 29, 2024
Merged

feat: parse mp4 webvtt segments #1545

merged 12 commits into from
Oct 29, 2024

Conversation

adrums86
Copy link
Contributor

@adrums86 adrums86 commented Oct 11, 2024

Description

Feature

This pull request adds support for parsing mp4 encapsulated webvtt segments by modifying the existing vtt-segment-loader and associated functions to interface with the transmuxer to parse fmp4 webvtt initialization and content segments.

Specific Changes proposed

  • Update mux.js to include the WebVttParser for use in the transmuxer worker.
  • Modify the vtt-segment-loader to be able to handle fragmented mp4 segments.
  • Parse wvtt initialization segments and content segments with the help of the transmuxer.
  • Parse the cues provided by the transmuxer into VTTCue objects and add them to the subtitles text tracks.

Demo

See the deployed demo page here
with the simulated live DASH manifest from DASH-IF with mp4 encapsulated webvtt: https://livesim2.dashif.org/livesim2/timesubswvtt_en/testpic_2s/Manifest.mpd

Requirements Checklist

  • Feature implemented / Bug fixed
  • If necessary, more likely in a feature request than a bug fix
  • Reviewed by Two Core Contributors

Copy link

codecov bot commented Oct 11, 2024

Codecov Report

Attention: Patch coverage is 98.11321% with 1 line in your changes missing coverage. Please review.

Project coverage is 84.06%. Comparing base (8456cb3) to head (3618bdc).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/transmuxer-worker.js 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1545      +/-   ##
==========================================
- Coverage   86.39%   84.06%   -2.34%     
==========================================
  Files          43       43              
  Lines       11165    11627     +462     
  Branches     2552     2604      +52     
==========================================
+ Hits         9646     9774     +128     
- Misses       1519     1853     +334     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@adrums86 adrums86 marked this pull request as ready for review October 16, 2024 07:02
@@ -282,6 +277,11 @@ export default class VTTSegmentLoader extends SegmentLoader {
}

const segmentInfo = this.pendingSegment_;
const isMp4WebVttSegment = result.mp4VttCues && result.mp4VttCues.length;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor but would isMp4WebVttSegmentWithCues be a more accurate name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, much more descriptive.

segmentInfo.mp4VttCues.forEach((cue) => {
const start = cue.start + timestampOffset;
const end = cue.end + timestampOffset;
const vttCue = new window.VTTCue(start, end, cue.cueText);
Copy link
Contributor

@alex-barstow alex-barstow Oct 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth confirming the existence/data type of these cue values or are we guaranteed they will be correct at this point?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sample duration and cueText must be defined coming from the transmuxer, so I think we're guaranteed these values will be correct with regards to type at this point. https://github.com/videojs/mux.js/blob/e1b4d161f51782e4712d020b66d5087bd6febb3d/lib/mp4/webvtt-parser.js#L107

src/vtt-segment-loader.js Outdated Show resolved Hide resolved
src/vtt-segment-loader.js Outdated Show resolved Hide resolved
src/transmuxer-worker.js Show resolved Hide resolved
src/transmuxer-worker.js Show resolved Hide resolved
src/media-segment-request.js Show resolved Hide resolved
@adrums86 adrums86 merged commit 9f1c4ad into main Oct 29, 2024
14 of 15 checks passed
@adrums86 adrums86 deleted the feat-mp4-vtt branch October 29, 2024 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants