Ultra-quality 1080p 60fps optimizations

This commit is contained in:
srtk 2026-02-13 22:53:10 +05:30
parent 0167aeb7b9
commit f2cfb87b13
3 changed files with 14 additions and 13 deletions

View file

@ -223,9 +223,9 @@ export class NetworkManager extends EventEmitter {
sendEncodedVideoChunk(chunk: any, isKeyFrame: boolean, timestamp: number, streamType: 'video' | 'screen' = 'video') {
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) return;
// Backpressure check: If we have > 2.5MB buffered, drop this frame.
// Backpressure check: If we have > 4MB buffered, drop this frame.
// For video, it's better to drop than to lag.
if (this.ws.bufferedAmount > 2.5 * 1024 * 1024) {
if (this.ws.bufferedAmount > 4 * 1024 * 1024) {
this.dropCount++;
if (this.dropCount % 60 === 0) {
console.warn(`[Network] Backpressure! Dropped ${this.dropCount} video frames. Buffered: ${this.ws.bufferedAmount} bytes`);

View file

@ -434,7 +434,7 @@ function App() {
for (const k of map.keys()) {
if (k.startsWith(`${user_id}-${type}-`) && k !== key) {
const kSeq = parseInt(k.split('-')[2]);
if (kSeq < seq - 10) map.delete(k);
if (kSeq < seq - 60) map.delete(k);
}
}
@ -480,8 +480,8 @@ function App() {
addLog("Requesting Webcam Access...");
stream = await navigator.mediaDevices.getUserMedia({
video: {
width: 1280,
height: 720,
width: 1920,
height: 1080,
frameRate: 60,
deviceId: selectedVideoDevice ? { exact: selectedVideoDevice } : undefined
}

View file

@ -48,23 +48,24 @@ export class MediaEngine extends SimpleEventEmitter {
// private videoDecoders: Map<string, VideoDecoder> = new Map(); // Already declared above
private audioDecoders: Map<string, AudioDecoder> = new Map();
private videoConfig: VideoEncoderConfig = {
codec: 'avc1.42001f', // H.264 Baseline Profile Level 3.1 (720p safe)
width: 1280,
height: 720,
bitrate: 4_000_000,
codec: 'avc1.64002a', // H.264 High Profile Level 4.2
width: 1920,
height: 1080,
bitrate: 6_000_000,
framerate: 60,
latencyMode: 'realtime',
hardwareAcceleration: 'prefer-hardware',
avc: { format: 'annexb' }
};
private screenConfig: VideoEncoderConfig = {
// High Profile Level 4.2
codec: 'avc1.64002a',
codec: 'avc1.64002a', // H.264 High Profile Level 4.2
width: 1920,
height: 1080,
bitrate: 8_000_000, // Reduced to 2 Mbps for better stability/FPS
bitrate: 10_000_000,
framerate: 60,
latencyMode: 'realtime', // Changed from 'quality' to 'realtime' for lower latency
latencyMode: 'realtime',
hardwareAcceleration: 'prefer-hardware',
avc: { format: 'annexb' }
};