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: support automatic configuration of audio and video only DRM sources #1090

Merged
merged 6 commits into from
Apr 5, 2021

Conversation

gesinger
Copy link
Contributor

@gesinger gesinger commented Mar 8, 2021

Description

To test, encrypted video creator can be used to create three streams with the following options:

$ npm run start -- --source [some video].mp4 --destination [some video]-audio-and-video-widevine --key-system widevine
$ npm run start -- --source [some video].mp4 --audio-only --destination [some video]-audio-only-widevine --key-system widevine
$ npm run start -- --source [some video].mp4 --video-only --destination [some video]-video-only-widevine --key-system widevine

Requirements Checklist

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

gkatsev
gkatsev previously approved these changes Mar 11, 2021
codecs.video.split(',').forEach(function(codec) {
codec = codec.trim();
if (mainPlaylist && mainPlaylist.attributes && mainPlaylist.attributes.CODECS) {
const mainCodecs = mainPlaylist.attributes.CODECS;
Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps we should use parseCodecs from vhs utils and loop through that. Should we make sure that we can support the codec here as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will switch to using parseCodecs. On support, since this should be called on createdsourcebuffers, I think we should be safe.

if (audioPlaylist && audioPlaylist.attributes && audioPlaylist.attributes.CODECS) {
codecs.audio = audioPlaylist.attributes.CODECS;
}

const videoContentType = codecs.video ? `video/mp4;codecs="${codecs.video}"` : null;
Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps we should use the vhs utils getMimeForCodec function here.

if (!codecs.audio && codecs.video && codecs.video.split(',').length > 1) {
codecs.video.split(',').forEach(function(codec) {
codec = codec.trim();
if (mainPlaylist && mainPlaylist.attributes && mainPlaylist.attributes.CODECS) {
Copy link
Contributor

Choose a reason for hiding this comment

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

should we use src/util/codecsForPlaylist for this instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looking into it, there is one slight difference in that codecsForPlaylist would grab the default audio codec, whereas this should grab the currently used audio playlist's codec. They should, in theory, be the same (or at least compatible), so it may not be a big issue, but in practice who knows what people do. I can see either side though. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we might need to use codecsForPlaylist for the edge case described here: https://github.com/videojs/http-streaming/blob/main/src/util/codecs.js#L116

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That should be covered by using the audio playlist below, since that playlist will have the attributes on it and will overwrite any audio codecs (or overwrite a missing codec if the video rendition doesn't list audio). And in the event that a non default alternate audio playlist is selected, we'd want to use the attributes there over the default one used by codecsForPlaylist

Copy link
Contributor

Choose a reason for hiding this comment

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

:shipit:

@codecov
Copy link

codecov bot commented Mar 29, 2021

Codecov Report

Merging #1090 (0e0928d) into main (99480d5) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1090      +/-   ##
==========================================
- Coverage   86.13%   86.13%   -0.01%     
==========================================
  Files          38       38              
  Lines        8967     8966       -1     
  Branches     2020     2017       -3     
==========================================
- Hits         7724     7723       -1     
  Misses       1243     1243              
Impacted Files Coverage Δ
src/videojs-http-streaming.js 90.56% <100.00%> (-0.03%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 99480d5...0e0928d. Read the comment docs.

Copy link
Member

@gkatsev gkatsev left a comment

Choose a reason for hiding this comment

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

Tested and verified that things work well. Interestingly, video-only worked fine without this. Now, audio-only works as well.

@gkatsev gkatsev merged commit 9b116ce into main Apr 5, 2021
@gkatsev gkatsev deleted the fix/audio-and-video-only-drm branch April 5, 2021 18:22
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.

3 participants