aboutsummaryrefslogtreecommitdiff
path: root/web/script
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2023-10-23 21:09:46 +0200
committermetamuffin <metamuffin@disroot.org>2023-10-23 21:09:46 +0200
commit13a6887415547f5e3bafec80d5088ff90ae94aa6 (patch)
tree77eddba5c2dba8ba9f8cfdaa31b7a741b949fee2 /web/script
parent57fccd01d487284bb317fb1ff778e0fd2e140c12 (diff)
downloadjellything-13a6887415547f5e3bafec80d5088ff90ae94aa6.tar
jellything-13a6887415547f5e3bafec80d5088ff90ae94aa6.tar.bz2
jellything-13a6887415547f5e3bafec80d5088ff90ae94aa6.tar.zst
hard-coded codec support check
Diffstat (limited to 'web/script')
-rw-r--r--web/script/player/profiles.ts20
1 files changed, 18 insertions, 2 deletions
diff --git a/web/script/player/profiles.ts b/web/script/player/profiles.ts
index a768d47..adaa717 100644
--- a/web/script/player/profiles.ts
+++ b/web/script/player/profiles.ts
@@ -33,19 +33,35 @@ export class ProfileSelector {
if (i.subtitles) return this.profiles_subtitles
return []
}
+ remux_supported(track: number): boolean {
+ // TODO use media capability API
+ // like so: await navigator.mediaCapabilities.decodingInfo({type:"file",video:{contentType:"video/webm; codecs=av1",bitrate:5*1000*1000/8,framerate:60,height:1080,width:1920}})
+ const codec = this.metadata.tracks[track].info.codec
+ return [
+ "V_AV1",
+ "V_VP8",
+ "V_VP9",
+ "A_OPUS",
+ "A_VORBIS",
+ "S_TEXT/WEBVTT"
+ ].includes(codec)
+ }
select_optimal_profile(track: number, profile: OVar<EncodingProfileExt | undefined>) {
const profs = this.profile_list_for_track(track)
- const co = profile.value?.order ?? -1
+ const sup_remux = this.remux_supported(track);
+ const min_prof = sup_remux ? -1 : 0
+ const co = profile.value?.order ?? min_prof
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 (!sup_remux && !profile.value) profile.value = profs[co];
if (current_bitrate > this.bandwidth.value * PROFILE_DOWN_FAC && co + 1 < profs.length) {
console.log("profile up");
profile.value = profs[co + 1]
this.log_change(track, profile.value)
}
- if (next_bitrate < this.bandwidth.value * PROFILE_UP_FAC && co >= 0) {
+ if (next_bitrate < this.bandwidth.value * PROFILE_UP_FAC && co > min_prof) {
console.log("profile down");
profile.value = profs[co - 1]
this.log_change(track, profile.value)