code-charity / youtube

[top~1 open YouTube & Video web-extension] Enrich your experience & choice! 🧰180+ options & clever features📌set+forget📌Longest-standing(been tough). Please join🧩us👨‍👩‍👧‍👧 ..⋮ {playback|content discovery|player|extra buttons|distractions|related videos|shorts|ads|quality|codec|full tab|full screen}
http://improvedtube.com
Other
3.4k stars 513 forks source link

Save time&co2(billion views)1.clean YouTube-DOM 2.Auto-Codec *UpdatedNOV23* #1211

Open ImprovedTube opened 2 years ago

ImprovedTube commented 2 years ago

1. youtube dom Cleaning the DOM?

clean dom
lighthouse chrome

Easy alternative/additionally

2. Auto-Codec

Nov2022: Hopefully somebody will enjoy finishing this soon, since the plan is complete & universally relevant...

youtube extension av1 vp9 vp8 h264 H.264, VP8, VP9, AV1


Afaik only 4 Options make sense:

  1. "Prefer VP9, VP8, h264 = Avoid AV1 codec & newer" ( = common in 2023, good for almost everybody, while more GPUs with VP8 & VP9 are still increasing )
    1. " Prefer VP8 & h264 = Avoid VP9 & AV1" ( still very common)
    2. " avoid VP8 codec and newer(=VP9 & AV1)" ( same as h264ify) (=old now & getting rarer)

(while also blocking h.264 is unnecessary if not counterproductive/bad in "enhanced h264ify" - as it is the oldest Codec.)


so for typical resolutions, if Hardward rendering isn't available we should just fall back to another codec. Except for 4k, which is only available in VP9 or AV1: 4k needs to be blocked by default, if:

mrangjunboon2019 commented 2 years ago

yay.

raszpl commented 1 year ago

2) I just pushed a patch fixing codec overrides https://github.com/code-charity/youtube/issues/1668 https://github.com/code-charity/youtube/pull/1670.

Problem with detecting GPU and auto disabling codecs is Browser doesnt give you hard information about what is hardware accelerated and what isnt. Same GPU can accelerate with one driver and not with another (case of HD 3000 in my mediacenter Thinkpad x220). Thats why h264ify doesnt F around and just does whats promised on the tin. The best you can do is query browser for codecs and going off of "true" vs "maybe" from .isTypeSupported() .canPlayType(), maybe adding GPU/Platform to your heuristics. Imo sensible solution would be suggesting optimal combination of codecs to the user on first run or first time he opens settings with explanation to whats going on and how to verify yourself. Maybe optional rechecking GPU/platform once a day/week to catch situations where someone upgraded hardware - but this might be dicey with browsers allowing Syncing settings/extensions across multiple computers.

Blocking 4K just because someone has 1080p monitor is bad idea as I mentioned in https://github.com/code-charity/youtube/issues/1580

ImprovedTube commented 1 year ago

hi, @raszpl TYSM! Which decoding can x220 do before & after?

Our GPU & CPU specs data can act flawlessly on confirmed hardware limitations only.
A GPU built before a codec was released can not hardware-accelerate that codec, so that codec can always be avoided by an eco-feature if the same resolution is provided in an older codec - or if the user's cpu alone can't possibly keep up with the higest resolution) (+ in some cases, like Thinkpad x220, additional limitations could optionally be considered, if the new driver isnt released for every OS or so)

(While 'collecting (some) data' doesnt sound like a programming job to some developers, it often is the only solution. Assuming this feature isnt written elsewhere already, then it would surely help other applications too in budgeting user's GPU & CPU ressources and can include overall performance info.)

Yes, GPU can be checked every time We are not yet syncing storage https://github.com/code-charity/youtube/discussions/1656 (but people import/export.)

raszpl commented 1 year ago

Which decoding can x220 do before & after? depending on the driver can be

HD Graphics 3000 Video Acceleration Information
Decode h264 baseline 64x64 to 1920x1088 pixels
Decode h264 main 64x64 to 1920x1088 pixels
Decode h264 high 64x64 to 1920x1088 pixels

or

Video Decode: Unavailable

Never know which driver user uses. Hardware decoded h264 is better, but software decoded VP9 can be slightly faster.

Browsers are syncing whole configs. Vivaldi

Currently, Vivaldi supports synchronisation of the following items: Extensions

so you cant blindly force Extension settings without expecting eventual trouble when user shares profile between multiple computers (maybe even a phone/tablet).

Imo the best that can be offered is a mild suggestion during install and when user is browsing Player Settings. Display tooltip with detected GPU and info about its hardware capabilities when hovering over "Codec h.264" and "Codecs", replace "Avoid CPU rendering when possible" submenu with something like "Auto Optimize Codec for low CPU usage" button. Maybe even make it display red when detected GPU is on a list with no hardware VP9/AV1 decoding etc, and green if settings already match GPU hardware capabilities. Ill think about ways of implementing that.

raszpl commented 1 year ago

https://github.com/code-charity/youtube/pull/1671 implements preliminary mechanism for setting codecs according to detected GPU, plus finetuning codec selection portion of Settings menu.

ImprovedTube commented 1 year ago

hi @raszpl sorry, considering syncing like that / Vivaldi, the brainstorming "GPUs changes rarely" wasnt necessary/misleading (striked now)




Misc, since i started (might just add this to satus.js at once) :

connectivity could also be considered 
resource.domainLookupEnd - resource.domainLookupStart
resource.connectEnd - resource.connectStart
resource.responseEnd - resource.startTime

& navigator.getBattery()
ImprovedTube commented 1 year ago

hi,

we cant :) because in order to be fast enough to patch YT we need to have block list prepared in advance

yes, might take 10ms to create canvas & see GPU name, so for example every time a video stops playing. (or just some proportional interval as we said.)
( While other hardward & software values, can make an near-unique Fingerprint, wont take a 1 millionth of a second, so mostly you can be sure nothing changed... )

0.1s benchmark ... consent,

sorry, *0.1ms? 😀 Could run a bunch of times randomly in the last 1 second of a video playback, and the first second beyond, to learn the difference.

battery

battery values could put estimated measurements in proportion since Battery correlates with decreased clockspeeds

afaik YT does that automatically

yes (just tending to be complete 😀 / wondering to call satus a separate project, shall we? Will satus make it to a hackernews post within X month/years from now?)

ImprovedTube commented 1 year ago

https://stackoverflow.com/questions/23666003/any-way-to-undelete-pull-request-comments 🙉 good night