Simplify export and filter manifests from dash generation.

This commit is contained in:
Kavin 2023-03-02 14:18:53 +00:00
parent bf0fb000e3
commit acff16a8d4
No known key found for this signature in database
GPG key ID: 49451E4482CC5BCD
2 changed files with 183 additions and 179 deletions

View file

@ -283,9 +283,10 @@ export default {
mime = "application/x-mpegURL";
} else if (this.video.audioStreams.length > 0 && !lbry && MseSupport) {
if (!this.video.dash) {
const dash = (
await import("@/utils/DashUtils.js").then(mod => mod.default)
).generate_dash_file_from_formats(streams, this.video.duration);
const dash = (await import("../utils/DashUtils.js")).generate_dash_file_from_formats(
streams,
this.video.duration,
);
uri = "data:application/dash+xml;charset=utf-8;base64," + btoa(dash);
} else {

View file

@ -4,12 +4,12 @@ import { Buffer } from "buffer";
window.Buffer = Buffer;
import { json2xml } from "xml-js";
const DashUtils = {
generate_dash_file_from_formats(VideoFormats, VideoLength) {
const generatedJSON = this.generate_xmljs_json_from_data(VideoFormats, VideoLength);
export function generate_dash_file_from_formats(VideoFormats, VideoLength) {
const generatedJSON = generate_xmljs_json_from_data(VideoFormats, VideoLength);
return json2xml(generatedJSON);
},
generate_xmljs_json_from_data(VideoFormatArray, VideoLength) {
}
function generate_xmljs_json_from_data(VideoFormatArray, VideoLength) {
const convertJSON = {
declaration: {
attributes: {
@ -32,22 +32,26 @@ const DashUtils = {
{
type: "element",
name: "Period",
elements: this.generate_adaptation_set(VideoFormatArray),
elements: generate_adaptation_set(VideoFormatArray),
},
],
},
],
};
return convertJSON;
},
generate_adaptation_set(VideoFormatArray) {
}
function generate_adaptation_set(VideoFormatArray) {
const adaptationSets = [];
let mimeAudioObjs = [];
VideoFormatArray.forEach(videoFormat => {
// the dual formats should not be used
if (videoFormat.mimeType.indexOf("video") != -1 && !videoFormat.videoOnly) {
if (
(videoFormat.mimeType.includes("video") && !videoFormat.videoOnly) ||
videoFormat.mimeType.includes("application")
) {
return;
}
@ -97,17 +101,18 @@ const DashUtils = {
for (var i = 0; i < mimeAudioObj.videoFormats.length; i++) {
const videoFormat = mimeAudioObj.videoFormats[i];
if (isVideoFormat) {
adapSet.elements.push(this.generate_representation_video(videoFormat));
adapSet.elements.push(generate_representation_video(videoFormat));
} else {
adapSet.elements.push(this.generate_representation_audio(videoFormat));
adapSet.elements.push(generate_representation_audio(videoFormat));
}
}
adaptationSets.push(adapSet);
});
return adaptationSets;
},
generate_representation_audio(Format) {
}
function generate_representation_audio(Format) {
const representation = {
type: "element",
name: "Representation",
@ -154,8 +159,9 @@ const DashUtils = {
],
};
return representation;
},
generate_representation_video(Format) {
}
function generate_representation_video(Format) {
const representation = {
type: "element",
name: "Representation",
@ -198,7 +204,4 @@ const DashUtils = {
],
};
return representation;
},
};
export default DashUtils;
}