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

fix: use audio offset for id3 with audio-only #1386

Merged
merged 4 commits into from
Apr 4, 2023

Conversation

mister-ben
Copy link
Contributor

@mister-ben mister-ben commented Mar 29, 2023

Description

id3 cues are not added correctly to audio-only streams, as the test for an audio-only stream is broken. videoTimestampOffset() will never be null as it defaults to 0, so the audio offset is not used.

Specific Changes proposed

Uses the videoTimestampOffset() when segmentInfo.trackInfo.hasVideo is false rather than when videoTimestampOffset() is null

Fixes #130

Requirements Checklist

  • Feature implemented / Bug fixed
  • If necessary, more likely in a feature request than a bug fix
    • Unit Tests updated or fixed
    • Example created (below)
  • Reviewed by Two Core Contributors

Example

  • Open the deploy preview and https://videojs-http-streaming.netlify.app to compare.
  • In each console, add
    const printCueData = (cues) => {
      Array.from(cues).forEach((cue) => {
        if ("value" in cue && cue?.value?.data) {
          const value = new TextDecoder()
            .decode(cue.value.data)
            .replace("\x03", "")
            .replace("\x00", "");
          console.log({
            value,
            start: cue.startTime,
            end: cue.endTime,
          });
        }
      });
    };
    
    const onAddTrack = ({ track }) => {
      if (
        !(track?.kind === "metadata" && track.label === "Timed Metadata")
      ) {
        return;
      }
    
      const onCueChange = () => {
        if (!track.activeCues) {
          return;
        }
    
        const cues = printCueData(track.activeCues);
      };
    
      track.mode = "hidden";
      track.addEventListener("cuechange", onCueChange);
    };
    
    player.textTracks().addEventListener("addtrack", onAddTrack);
    
  • In each load https://cue-points-test.vercel.app/audio/master.m3u8 and play
  • Observe cues logged to the console in deploy preview (like {value: '{"webcastId":"635fc...)

Thanks to @berrutti for the test streams from #130

@codecov
Copy link

codecov bot commented Mar 29, 2023

Codecov Report

Merging #1386 (1a9c09f) into main (b4f44e4) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #1386   +/-   ##
=======================================
  Coverage   85.40%   85.40%           
=======================================
  Files          40       40           
  Lines        9963     9963           
  Branches     2308     2308           
=======================================
  Hits         8509     8509           
  Misses       1454     1454           
Impacted Files Coverage Δ
src/playlist-controller.js 95.16% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@berrutti
Copy link

Hey @mister-ben, thanks a lot. This is great. Have a great weekend.

Copy link
Contributor

@adrums86 adrums86 left a comment

Choose a reason for hiding this comment

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

Good fix. Thanks for this @mister-ben

@adrums86
Copy link
Contributor

adrums86 commented Apr 3, 2023

My apologies @mister-ben, moving the common metadata functionality up to accommodate EventStream messed up your fix. The timestamp offset ternary now lives in

const timestampOffset = this.sourceUpdater_.videoTimestampOffset() === null ?

I think it could be done without the segmentData like this: const timestampOffset = this.sourceUpdater_.videoBuffer ?

@mister-ben
Copy link
Contributor Author

I think it could be done without the segmentData like this: const timestampOffset = this.sourceUpdater_.videoBuffer ?

That works with the test stream, but there's a videoBuffer present in the tests...

@mister-ben mister-ben requested a review from adrums86 April 4, 2023 09:38
Copy link
Contributor

@adrums86 adrums86 left a comment

Choose a reason for hiding this comment

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

:shipit:

@mister-ben mister-ben merged commit e6d8b08 into videojs:main Apr 4, 2023
@mister-ben mister-ben deleted the fix-id3-audio branch April 4, 2023 16:21
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.

cuechange event not being triggered on audio only HLS streams
4 participants