diff options
Diffstat (limited to 'web/script/player/profiles.ts')
-rw-r--r-- | web/script/player/profiles.ts | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/web/script/player/profiles.ts b/web/script/player/profiles.ts index 5993e6f..11b27c9 100644 --- a/web/script/player/profiles.ts +++ b/web/script/player/profiles.ts @@ -18,9 +18,9 @@ export class ProfileSelector { if (p.video) this.profiles_video.push({ id, order: 0, ...p }) if (p.subtitles) this.profiles_subtitles.push({ id, order: 0, ...p }) } - this.profiles_audio.sort((a, b) => profile_bw(b) - profile_bw(a)) - this.profiles_video.sort((a, b) => profile_bw(b) - profile_bw(a)) - this.profiles_subtitles.sort((a, b) => profile_bw(b) - profile_bw(a)) + this.profiles_audio.sort((a, b) => profile_byterate(b) - profile_byterate(a)) + this.profiles_video.sort((a, b) => profile_byterate(b) - profile_byterate(a)) + this.profiles_subtitles.sort((a, b) => profile_byterate(b) - profile_byterate(a)) for (let i = 0; i < this.profiles_audio.length; i++) this.profiles_audio[i].order = i for (let i = 0; i < this.profiles_video.length; i++) this.profiles_video[i].order = i for (let i = 0; i < this.profiles_subtitles.length; i++) this.profiles_subtitles[i].order = i @@ -36,21 +36,23 @@ export class ProfileSelector { const profs = this.profile_list_for_track(track) const co = profile.value?.order ?? -1 - const current_bitrate = profile_bw(profs[co], 5000 * 1000) - const next_bitrate = profile_bw(profs[co - 1], 5000 * 1000) - console.log({ current_bitrate, next_bitrate, co, bandwidth: this.bandwidth.value * 8 }); - if (current_bitrate > this.bandwidth.value * 8 * PROFILE_DOWN_FAC && co + 1 < profs.length) { + const current_bitrate = profile_byterate(profs[co], 5000 * 1000) + const next_bitrate = profile_byterate(profs[co - 1], 5000 * 1000) + // console.log({ current_bitrate, next_bitrate, co, bandwidth: this.bandwidth.value * 8 }); + if (current_bitrate > this.bandwidth.value * PROFILE_DOWN_FAC && co + 1 < profs.length) { console.log("profile up"); profile.value = profs[co + 1] } - if (next_bitrate < this.bandwidth.value * 8 * PROFILE_UP_FAC && co >= 0) { + if (next_bitrate < this.bandwidth.value * PROFILE_UP_FAC && co >= 0) { console.log("profile down"); profile.value = profs[co - 1] } + + // profile.value = profs[0] } } -function profile_bw(p?: EncodingProfile, fallback = 0): number { +function profile_byterate(p?: EncodingProfile, fallback = 0): number { if (p?.audio) return p.audio.bitrate / 8 if (p?.video) return p.video.bitrate / 8 if (p?.subtitles) return 100 |