aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
Diffstat (limited to 'web')
-rw-r--r--web/script/player/download.ts2
-rw-r--r--web/script/player/mod.ts6
-rw-r--r--web/script/player/player.ts6
-rw-r--r--web/script/player/profiles.ts20
-rw-r--r--web/script/player/track.ts13
5 files changed, 30 insertions, 17 deletions
diff --git a/web/script/player/download.ts b/web/script/player/download.ts
index 86a899f..1799070 100644
--- a/web/script/player/download.ts
+++ b/web/script/player/download.ts
@@ -16,7 +16,7 @@ export class SegmentDownloader {
const buf = await res.arrayBuffer()
const dl_body = performance.now();
- if (buf.byteLength > 500 * 1000) {
+ if (buf.byteLength > 100 * 1000) {
const m = {
time: dl_start,
duration: (dl_body - dl_header) / 1000,
diff --git a/web/script/player/mod.ts b/web/script/player/mod.ts
index e6d3ea0..aea12a8 100644
--- a/web/script/player/mod.ts
+++ b/web/script/player/mod.ts
@@ -69,7 +69,7 @@ function initialize_player(el: HTMLElement, node_id: string) {
)),
show_stats.map(do_show => player.tracks.map(tracks =>
!do_show ? e("div") : e("div", { class: "jsp-stats" },
- player.downloader.bandwidth.map(b => e("pre", `estimated bandwidth: ${show.metric(b, "B/s")} / ${show.metric(b * 8, "b/s")}`)),
+ player.downloader.bandwidth.map(b => e("pre", `estimated bandwidth: ${show.metric(b, "B/s")} | ${show.metric(b * 8, "b/s")}`)),
...tracks.map((t, i) => t.profile.map(p =>
e("pre", `track ${i}: ` + (p ? `profile ${p.id} (${show_profile(p)})` : `remux`))
))
@@ -122,8 +122,8 @@ function mouse_idle(e: HTMLElement, timeout: number, cb: (b: boolean) => unknown
}
function show_profile(profile: EncodingProfile): string {
- if (profile.audio) return `codec=${profile.audio.codec} ${profile.audio.sample_rate ? `ar=${show.metric(profile.audio.sample_rate, "Hz")} ` : ""}abr=${show.metric(profile.audio.bitrate, "b/s")}`
- if (profile.video) return `codec=${profile.video.codec} vw=${profile.video.width} vbr=${show.metric(profile.video.bitrate, "b/s")} preset=${profile.video.preset}`
+ if (profile.audio) return `codec=${profile.audio.codec} br=${show.metric(profile.audio.bitrate, "b/s")}${profile.audio.sample_rate ? ` sr=${show.metric(profile.audio.sample_rate, "Hz")}` : ""}`
+ if (profile.video) return `codec=${profile.video.codec} br=${show.metric(profile.video.bitrate, "b/s")} w=${profile.video.width} preset=${profile.video.preset}`
if (profile.subtitles) return `codec=${profile.subtitles.codec}`
return `???`
}
diff --git a/web/script/player/player.ts b/web/script/player/player.ts
index f3a1f6e..9365658 100644
--- a/web/script/player/player.ts
+++ b/web/script/player/player.ts
@@ -57,6 +57,12 @@ export class Player {
console.log("seeked");
this.buffering_status.value = undefined
}
+ this.video.onerror = e => {
+ console.error("video element error:", e);
+ }
+ this.video.onabort = e => {
+ console.error("video element abort:", e);
+ }
this.fetch_meta()
}
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
diff --git a/web/script/player/track.ts b/web/script/player/track.ts
index bcff607..890176c 100644
--- a/web/script/player/track.ts
+++ b/web/script/player/track.ts
@@ -21,7 +21,7 @@ export class PlayerTrack {
private track_index: number,
private metadata: JhlsTrack
) {
- this.source_buffer = this.player.media_source.addSourceBuffer("video/webm")
+ this.source_buffer = this.player.media_source.addSourceBuffer("video/webm; codecs=\"opus,vorbis,vp8,vp9,av1\"")
this.source_buffer.mode = "segments"
this.source_buffer.addEventListener("updateend", () => {
if (this.current_load) {
@@ -35,6 +35,9 @@ export class PlayerTrack {
this.source_buffer.addEventListener("error", e => {
console.error("sourcebuffer error", e);
})
+ this.source_buffer.addEventListener("abort", e => {
+ console.error("sourcebuffer abort", e);
+ })
}
update_buf_ranges() {
@@ -90,11 +93,13 @@ export class PlayerTrack {
if (this.source_buffer.updating) return
if (this.append_queue.length) {
const seg = this.append_queue[0];
- this.source_buffer.timestampOffset = seg.start
- // TODO why is pushing so unreliable?! sometimes it does not add it
- this.source_buffer.appendBuffer(seg.buf);
this.append_queue.splice(0, 1)
this.current_load = seg
+ // TODO why is appending so unreliable?! sometimes it does not add it
+ this.source_buffer.changeType("video/webm; codecs=\"opus,vorbis,vp8,vp9,av1\"")
+ this.source_buffer.timestampOffset = seg.start
+ this.source_buffer.appendBuffer(seg.buf);
+
}
}
}