dual tuners fully working

This commit is contained in:
david 2025-04-01 18:33:17 -07:00
parent d1ad73fbf0
commit e8a007a4a9
2 changed files with 17 additions and 2 deletions

View File

@ -6,7 +6,7 @@ const HTTP_PORT = process.env.HTTP_PORT ? parseInt(process.env.HTTP_PORT, 10) :
const WS_PORT = process.env.WS_PORT ? parseInt(process.env.WS_PORT, 10) : 3001; const WS_PORT = process.env.WS_PORT ? parseInt(process.env.WS_PORT, 10) : 3001;
const STATIC_ROOT = process.cwd() + "/dist/static"; const STATIC_ROOT = process.cwd() + "/dist/static";
const TV_DEV_0 = process.env.TV_DEV_0 ?? '/dev/dvb/adapter0/dvr0' const TV_DEV_0 = process.env.TV_DEV_0 ?? '/dev/dvb/adapter0/dvr0'
const TV_DEV_1 = process.env.TV_DEV_1 ?? '/dev/dvb/adapter0/dvr1'; const TV_DEV_1 = process.env.TV_DEV_1 ?? '/dev/dvb/adapter1/dvr0';
const zap = new Zap(); const zap = new Zap();
@ -25,7 +25,7 @@ const getChannels = () =>
const httpServer = new HttpServer(HTTP_PORT, STATIC_ROOT, tune, getChannels); const httpServer = new HttpServer(HTTP_PORT, STATIC_ROOT, tune, getChannels);
const tvWebSocket0 = new TVWebSocket(WS_PORT, TV_DEV_0); const tvWebSocket0 = new TVWebSocket(WS_PORT, TV_DEV_0);
// const tvWebSocket1 = new TVWebSocket(WS_PORT + 1, TV_DEV_1); const tvWebSocket1 = new TVWebSocket(WS_PORT + 1, TV_DEV_1);
httpServer.start(); httpServer.start();

View File

@ -15,6 +15,11 @@ export default class TVWebSocket {
const videoTrack = this.createVideoTrack(ffmpegProcess); const videoTrack = this.createVideoTrack(ffmpegProcess);
const audioTrack = this.createAudioTrack(ffmpegProcess); const audioTrack = this.createAudioTrack(ffmpegProcess);
ffmpegProcess.stdio[2].on('data',data=>{
// console.log("stdio[2] ",data.toString())
})
// WebSocket signaling server // WebSocket signaling server
const wss = new ws.WebSocketServer({ port }); const wss = new ws.WebSocketServer({ port });
@ -70,6 +75,13 @@ export default class TVWebSocket {
'-vcodec', 'rawvideo', '-vcodec', 'rawvideo',
'-pix_fmt', 'yuv420p', '-pix_fmt', 'yuv420p',
'-f', 'rawvideo', '-f', 'rawvideo',
//quality
'-fflags', '+discardcorrupt',
'-err_detect', 'ignore_err',
'-analyzeduration', '100M',
'-probesize', '100M',
'pipe:3', 'pipe:3',
// Audio // Audio
@ -109,6 +121,9 @@ export default class TVWebSocket {
// Start FFmpeg and pipe video frames to the source // Start FFmpeg and pipe video frames to the source
videoStream.on('data', (chunk: Buffer) => { videoStream.on('data', (chunk: Buffer) => {
videoBuffer = Buffer.concat([videoBuffer, chunk]); videoBuffer = Buffer.concat([videoBuffer, chunk]);
if (videoBuffer.length > FRAME_SIZE * 2) {
console.warn('Video buffer overrun — possible freeze trigger');
}
while (videoBuffer.length >= FRAME_SIZE) { while (videoBuffer.length >= FRAME_SIZE) {
const frameData = videoBuffer.slice(0, FRAME_SIZE); const frameData = videoBuffer.slice(0, FRAME_SIZE);
videoBuffer = videoBuffer.slice(FRAME_SIZE); videoBuffer = videoBuffer.slice(FRAME_SIZE);