mirror of
https://github.com/wukko/cobalt.git
synced 2024-11-15 12:50:01 +00:00
api/youtube: prefer higher quality even if premuxed video is available
This commit is contained in:
parent
555625878e
commit
281ae25d4a
1 changed files with 7 additions and 6 deletions
|
@ -184,8 +184,6 @@ export default async function(o) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let bestQuality, hasAudio;
|
|
||||||
|
|
||||||
const filterByCodec = (formats) =>
|
const filterByCodec = (formats) =>
|
||||||
formats
|
formats
|
||||||
.filter(e =>
|
.filter(e =>
|
||||||
|
@ -201,10 +199,12 @@ export default async function(o) {
|
||||||
adaptive_formats = filterByCodec(info.streaming_data.adaptive_formats)
|
adaptive_formats = filterByCodec(info.streaming_data.adaptive_formats)
|
||||||
}
|
}
|
||||||
|
|
||||||
bestQuality = adaptive_formats.find(i => i.has_video && i.content_length);
|
let bestQuality;
|
||||||
hasAudio = adaptive_formats.find(i => i.has_audio && i.content_length);
|
|
||||||
|
|
||||||
if (bestQuality) bestQuality = qual(bestQuality);
|
const bestVideo = adaptive_formats.find(i => i.has_video && i.content_length);
|
||||||
|
const hasAudio = adaptive_formats.find(i => i.has_audio && i.content_length);
|
||||||
|
|
||||||
|
if (bestVideo) bestQuality = qual(bestVideo);
|
||||||
|
|
||||||
if ((!bestQuality && !o.isAudioOnly) || !hasAudio)
|
if ((!bestQuality && !o.isAudioOnly) || !hasAudio)
|
||||||
return { error: "youtube.codec" };
|
return { error: "youtube.codec" };
|
||||||
|
@ -279,7 +279,8 @@ export default async function(o) {
|
||||||
|
|
||||||
let match, type, urls;
|
let match, type, urls;
|
||||||
|
|
||||||
if (!o.isAudioOnly && !o.isAudioMuted && format === 'h264') {
|
// prefer good premuxed videos if available
|
||||||
|
if (!o.isAudioOnly && !o.isAudioMuted && format === "h264" && bestVideo.fps <= 30) {
|
||||||
match = info.streaming_data.formats.find(checkSingle);
|
match = info.streaming_data.formats.find(checkSingle);
|
||||||
type = "proxy";
|
type = "proxy";
|
||||||
urls = match?.decipher(yt.session.player);
|
urls = match?.decipher(yt.session.player);
|
||||||
|
|
Loading…
Reference in a new issue