Fix player attempting load wrong quality video
This commit is contained in:
parent
9affde5097
commit
ce11918e4e
@ -102,7 +102,6 @@ module.exports = [
|
||||
}, 1000 * 2))
|
||||
// 404
|
||||
else if (!downloader.videoExists(fname)) {
|
||||
console.log(`dlstatus for ${fname}: ${dlStatus}`)
|
||||
return {
|
||||
statusCode: 404,
|
||||
contentType: "text/html; charset=UTF-8",
|
||||
|
@ -191,7 +191,7 @@ module.exports = [
|
||||
let largestSavedFormat
|
||||
let qualities = {} // When searching for a specific quality, if the specified one doesn't exist, retrieve the closest match
|
||||
|
||||
let videoPath = `/getVideo?v=${id}&q=${q || "360p"}`
|
||||
let videoPath = `/getVideo?v=${id}&q=${q || startingFormat.qualityLabel}`
|
||||
|
||||
for (const format of formats) {
|
||||
// apply media fragment to all sources + get largest format that is currently on disk
|
||||
@ -253,7 +253,6 @@ module.exports = [
|
||||
|
||||
// Download base video
|
||||
if (!qSet && willDownload && !largestSavedFormat) {
|
||||
console.log(`Starting download for ${id} (${startingFormat.qualityLabel})`);
|
||||
dlQueue.enqueue(id, startingFormat.qualityLabel)
|
||||
// Wait for a second to give the default noscript player at least a small portion of bytes to play
|
||||
await new Promise(resolve => setTimeout(resolve, 1000))
|
||||
|
@ -79,7 +79,9 @@ async function enqueue(videoID, quality) {
|
||||
else
|
||||
sortedQueues = dlQueues.sort((a, b) => (a.hq.length + (2 - a.downloadCount)) - (b.hq.length + (2 - b.downloadCount)))
|
||||
|
||||
return await sortedQueues[0].enqueue(videoID, quality)
|
||||
const out = sortedQueues[0].enqueue(videoID, quality)
|
||||
// console.log(dlQueues)
|
||||
return await out
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
@ -15,6 +15,7 @@ const qualitySort = require("./quality-sort")
|
||||
const downloadInPartsSize = 9_000_000 // 9 MB
|
||||
|
||||
const cuda_enabled = childProcess.execSync("ffmpeg -hide_banner -loglevel error -hwaccel cuda -i html/static/images/bow.png bow.png && rm bow.png") == ""
|
||||
const codec = childProcess.execSync("ffmpeg -hide_banner -loglevel error -decoders").includes("h264_cuvid") ? "h264_cuvid" : "h264";
|
||||
|
||||
function downloadStatus(videoID) {
|
||||
let dlData = cacheManager.read("download")[videoID]
|
||||
@ -270,7 +271,7 @@ async function saveMp4Android(id, quality) {
|
||||
|
||||
let cmd = [
|
||||
"ffmpeg",
|
||||
cuda_enabled ? "-hwaccel cuda -c:v h264_cuvid" : null,
|
||||
cuda_enabled ? `-hwaccel cuda -c:v ${codec}` : null,
|
||||
`-y -i ${path.join(pathBase, videoPath)}`,
|
||||
`-i ${path.join(pathBase, audioPath)}`,
|
||||
`-c:v copy -c:a copy`,
|
||||
@ -523,6 +524,7 @@ module.exports = {
|
||||
return videoData
|
||||
},
|
||||
|
||||
/** @returns {Promise<object[]>} */
|
||||
sortFormats: async function(video, targetQuality) {
|
||||
// if (video.formatStreams == undefined || video.formatStreams.length == 0)
|
||||
// return []
|
||||
|
@ -8,7 +8,7 @@ export default (modules, q, qa) => {
|
||||
let downloading = false
|
||||
if (modules.globals.dlStatus > 0 && modules.globals.dlStatus < 3) {
|
||||
downloading = true
|
||||
modules.cacheInfo.pingCache(`${modules.globals.data.videoId}-${videoSource.split("&quality=")[1] || "360p"}`, () => {
|
||||
modules.cacheInfo.pingCache(`${modules.globals.data.videoId}-${videoSource.split("&quality=")[1] || modules.globals.startingFormat.qualityLabel}`, () => {
|
||||
downloading = false
|
||||
self.reloadSource()
|
||||
}, 1000 * 2)
|
||||
@ -59,7 +59,7 @@ export default (modules, q, qa) => {
|
||||
})
|
||||
},
|
||||
qualitySelected: quality => {
|
||||
quality = quality || "360p"
|
||||
quality = quality || modules.globals.startingFormat.qualityLabel
|
||||
|
||||
modules.controls.setQualityButtonActive(quality)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user