Skip to content

Commit

Permalink
fix: get additional format properties from dash manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
fent committed Oct 21, 2020
1 parent 646a5cf commit c3594b6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
17 changes: 16 additions & 1 deletion lib/info.js
Expand Up @@ -260,7 +260,22 @@ const getDashManifest = (url, options) => new Promise((resolve, reject) => {
if (node.name === 'REPRESENTATION') {
const itag = parseInt(node.attributes.ID);
if (!isNaN(itag)) {
formats[itag] = { itag, url };
formats[itag] = {
itag, url,
bitrate: parseInt(node.attributes.BANDWIDTH),
codecs: node.attributes.CODECS,
};
if (node.attributes.HEIGHT) {
Object.assign(formats[itag], {
width: parseInt(node.attributes.WIDTH),
height: parseInt(node.attributes.HEIGHT),
fps: parseInt(node.attributes.FRAMERATE),
});
} else {
Object.assign(formats[itag], {
audioSampleRate: node.attributes.AUDIOSAMPLINGRATE,
});
}
}
}
};
Expand Down
2 changes: 2 additions & 0 deletions lib/util.js
Expand Up @@ -331,6 +331,8 @@ exports.validateURL = string => {
*/
exports.addFormatMeta = format => {
format = Object.assign({}, FORMATS[format.itag], format);
format.qualityLabel =
format.qualityLabel || (format.height ? `${format.height}p${format.fps >= 60 ? format.fps : ''}` : null);
format.hasVideo = !!format.qualityLabel;
format.hasAudio = !!format.audioBitrate;
format.container = format.mimeType ?
Expand Down
1 change: 1 addition & 0 deletions test/util-test.js
Expand Up @@ -508,6 +508,7 @@ describe('util.addFormatMeta()', () => {
assert.deepEqual(format, {
itag: -1,
url: 'http://video.com/3/4.ts',
qualityLabel: null,
container: null,
codecs: null,
videoCodec: null,
Expand Down

0 comments on commit c3594b6

Please sign in to comment.