diff options
author | metamuffin <metamuffin@disroot.org> | 2023-10-02 22:35:53 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-10-02 22:35:53 +0200 |
commit | f50a0e48df9ee2ffdfccd013cb4165c7994f8ee4 (patch) | |
tree | ce647bbda7a0b34aa1448cdf2f53844d3eff2ed4 | |
parent | 7450134996a94c4629f1e112e90ad458a84c0c04 (diff) | |
download | jellything-f50a0e48df9ee2ffdfccd013cb4165c7994f8ee4.tar jellything-f50a0e48df9ee2ffdfccd013cb4165c7994f8ee4.tar.bz2 jellything-f50a0e48df9ee2ffdfccd013cb4165c7994f8ee4.tar.zst |
prepare automatic track selection
-rw-r--r-- | web/js-player.css | 7 | ||||
m--------- | web/script/jshelper | 0 | ||||
-rw-r--r-- | web/script/player/mod.ts | 17 | ||||
-rw-r--r-- | web/script/player/profiles.ts | 22 | ||||
-rw-r--r-- | web/script/player/track.ts | 3 |
5 files changed, 46 insertions, 3 deletions
diff --git a/web/js-player.css b/web/js-player.css index 490c8dd..3df8cde 100644 --- a/web/js-player.css +++ b/web/js-player.css @@ -78,6 +78,11 @@ } .jsp-stats { position: absolute; + background-color: rgba(0, 0, 0, 0.404); bottom: var(--csize); - right: 30px; + right: 0px; + padding: 1em; +} +.jsp-stats pre { + margin: 0.1em; } diff --git a/web/script/jshelper b/web/script/jshelper -Subproject 78fe4b0459dd34737303ec97647a83cecfbd1dc +Subproject 338394f25b9db43a41e4615f77483f7e36fe9a8 diff --git a/web/script/player/mod.ts b/web/script/player/mod.ts index bf294aa..9c1b060 100644 --- a/web/script/player/mod.ts +++ b/web/script/player/mod.ts @@ -5,6 +5,7 @@ */ import { OVar, show } from "../jshelper/mod.ts"; import { e } from "../jshelper/mod.ts"; +import { EncodingProfile } from "./jhls.d.ts"; import { Player } from "./player.ts"; document.addEventListener("DOMContentLoaded", () => { @@ -66,8 +67,13 @@ function initialize_player(el: HTMLElement, node_id: string) { player.buffering_status.map(b => e("div", { class: "jsp-overlay" }, b ? e("p", { class: "jsp-buffering" }, b) : undefined )), - show_stats.map(do_show => !do_show ? e("div") : e("div", {class: "jsp-stats"}, - player.downloader.bandwidth.map(b => e("pre", `estimated bandwidth: ${show.byte_size(b)}`)) + 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")}`)), + ...tracks.map((t, i) => t.profile.map(p => + e("pre", `track ${i}: ` + (p ? `profile ${p.id} (${show_profile(p)})` : `remux`)) + )) + ) )), controls, ) @@ -114,3 +120,10 @@ function mouse_idle(e: HTMLElement, timeout: number, cb: (b: boolean) => unknown }, timeout) } } + +function show_profile(profile: EncodingProfile): string { + if (profile.audio) return `codec=${profile.audio.codec} ar=${show.metric(profile.audio.sample_rate ?? -1, "Hz")} abr=${show.metric(profile.audio.bitrate, "b/s")}` + if (profile.video) return `codec=${profile.video.codec} vw=${show.metric(profile.video.width ?? -1, "Hz")} vbr=${show.metric(profile.video.bitrate, "b/s")} preset=${profile.video.preset}` + if (profile.subtitles) return `codec=${profile.subtitles.codec}` + return `???` +}
\ No newline at end of file diff --git a/web/script/player/profiles.ts b/web/script/player/profiles.ts new file mode 100644 index 0000000..3b3379a --- /dev/null +++ b/web/script/player/profiles.ts @@ -0,0 +1,22 @@ +import { OVar } from "../jshelper/mod.ts"; +import { EncodingProfile, JhlsMetadata } from "./jhls.d.ts"; + +export interface EncodingProfileExt extends EncodingProfile { id: number } +export class ProfileSelector { + profiles_video: EncodingProfileExt[] = [] + profiles_audio: EncodingProfileExt[] = [] + profiles_subtitles: EncodingProfileExt[] = [] + + constructor(private bandwidth: OVar<number>, private metadata: JhlsMetadata) { + for (let id = 0; id < metadata.extra_profiles.length; id++) { + const p = metadata.extra_profiles[id]; + if (p.audio) this.profiles_audio.push({ id, ...p }) + if (p.video) this.profiles_video.push({ id, ...p }) + if (p.subtitles) this.profiles_subtitles.push({ id, ...p }) + } + } + + select_optimal_profile(track: number, profile: OVar<EncodingProfileExt>) { + // TODO + } +} diff --git a/web/script/player/track.ts b/web/script/player/track.ts index e64cdf3..59690c3 100644 --- a/web/script/player/track.ts +++ b/web/script/player/track.ts @@ -1,6 +1,7 @@ import { OVar } from "../jshelper/mod.ts"; import { JhlsTrack, TimeRange } from "./jhls.d.ts"; import { BufferRange, Player } from "./player.ts"; +import { EncodingProfileExt } from "./profiles.ts"; const TARGET_BUFFER_DURATION = 15 const MIN_BUFFER_DURATION = 1 @@ -12,6 +13,8 @@ export class PlayerTrack { private loading = new Set<number>() public buffered = new OVar<BufferRange[]>([]) private append_queue: AppendRange[] = [] + public profile = new OVar<EncodingProfileExt | undefined>(undefined) + constructor( private player: Player, private node_id: string, |