aboutsummaryrefslogtreecommitdiff
path: root/web/script/player/profiles.ts
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2023-10-03 12:09:36 +0200
committermetamuffin <metamuffin@disroot.org>2023-10-03 12:09:36 +0200
commit9f97111e2f2b89fa5fcb2ff0dd69a62e31ea381f (patch)
tree864fa80f7df774d84496c2b10a3bcffe43f1e15b /web/script/player/profiles.ts
parentfffc7a3b8a8a3ead3992d400ec9ed035f1f93b39 (diff)
downloadjellything-9f97111e2f2b89fa5fcb2ff0dd69a62e31ea381f.tar
jellything-9f97111e2f2b89fa5fcb2ff0dd69a62e31ea381f.tar.bz2
jellything-9f97111e2f2b89fa5fcb2ff0dd69a62e31ea381f.tar.zst
debugging unreliable appendBuffer
Diffstat (limited to 'web/script/player/profiles.ts')
-rw-r--r--web/script/player/profiles.ts20
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