pstream is dead; long live pstream taciturnaxolotl.github.io/pstream-ng/
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

thumbnail queue algorithm

Co-authored-by: Jip Frijlink <JipFr@users.noreply.github.com>

mrjvs 46cb7793 3f9f072a

+17 -6
+17 -6
src/components/player/internals/ThumbnailScraper.tsx
··· 5 5 import { usePlayerStore } from "@/stores/player/store"; 6 6 import { LoadableSource, selectQuality } from "@/stores/player/utils/qualities"; 7 7 8 + function makeQueue(layers: number): number[] { 9 + const output = [0, 1]; 10 + let segmentSize = 0.5; 11 + let lastSegmentAmount = 0; 12 + for (let layer = 0; layer < layers; layer += 1) { 13 + const segmentAmount = 1 / segmentSize - 1; 14 + for (let i = 0; i < segmentAmount - lastSegmentAmount; i += 1) { 15 + const offset = i * segmentSize * 2; 16 + output.push(offset + segmentSize); 17 + } 18 + lastSegmentAmount = segmentAmount; 19 + segmentSize /= 2; 20 + } 21 + return output; 22 + } 23 + 8 24 class ThumnbnailWorker { 9 25 interrupted: boolean; 10 26 ··· 86 102 if (!vid) return; 87 103 await this.initVideo(); 88 104 89 - // TODO make a queue based on refinement algorithm 90 - 91 - const sections = 50; 92 - const queue = Array(sections + 1) 93 - .fill(0) 94 - .map((_, i) => i / sections); 105 + const queue = makeQueue(6); // 7 layers is 63 thumbnails evenly distributed 95 106 for (let i = 0; i < queue.length; i += 1) { 96 107 if (this.interrupted) return; 97 108 await this.takeSnapshot(vid.duration * queue[i]);