mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-08-14 23:57:27 +00:00
Simplify export and filter manifests from dash generation.
This commit is contained in:
parent
bf0fb000e3
commit
acff16a8d4
2 changed files with 183 additions and 179 deletions
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue