working with tv

This commit is contained in:
david 2025-03-31 15:59:40 -07:00
parent 5f9771ddb6
commit 795fd0cd38
3 changed files with 35 additions and 5 deletions

View File

@ -1,6 +1,6 @@
curl https://git.linuxtv.org/dtv-scan-tables.git/plain/atsc/us-ATSC-center-frequencies-8VSB
dvbv5-zap -c dvb_channel.conf -CUS -IZAP "ION"
dvbv5-zap -r -c dvb_channel.conf -CUS -IZAP "ION"
dvbv5-scan -Cus -o dvb_channel.conf -O zap -v us-ATSC-center-frequencies-8VSB

View File

@ -14,7 +14,8 @@ import { i420ToRgba, RTCVideoSource } from '@roamhq/wrtc/types/nonstandard';
// const {mediaDevices} = wrtc
// Constants
const VIDEO_DEVICE = '/dev/video0'; // Video source device
// const VIDEO_DEVICE = '/dev/video0'; // Video source device
const VIDEO_DEVICE = '/dev/dvb/adapter0/dvr0'; // Video source device
const WIDTH = 640; // Video width
const HEIGHT = 480; // Video height
const FRAME_SIZE = WIDTH * HEIGHT * 1.5; // YUV420p frame size (460800 bytes)
@ -40,15 +41,37 @@ class VideoStream extends Readable {
// Function to start FFmpeg and capture raw video
function startFFmpeg(): ChildProcessWithoutNullStreams {
return spawn('ffmpeg', [
'-f', 'v4l2', // Use Video4Linux2 for video capture
const p = spawn('ffmpeg', [
'-loglevel', 'debug',
'-i', VIDEO_DEVICE, // Input device
'-vf', `scale=${WIDTH}:${HEIGHT}`, // Scale video resolution
'-vcodec', 'rawvideo', // Output raw video codec
'-pix_fmt', 'yuv420p', // Pixel format for WebRTC
'-f', 'rawvideo', // Output format
'pipe:1' // Pipe to stdout
]);
], {
// stdio: ['ignore', 'pipe', 'pipe'],
// detached: true
});
process.on('SIGINT', () => {
console.log('🔻 Server shutting down... KILLING');
let b = p.kill('SIGINT');
// let b = process.kill(p.pid)
process.exit(0);
});
process.on('SIGTERM', () => {
console.log('🔻 SIGTERM received');
p.kill('SIGTERM');
process.exit(0);
});
process.on('exit', () => {
p.kill('SIGHUP'); //this one
let b = p.kill('SIGTERM');
console.log("b ",b)
});
return p;
}
// const videoSource =
@ -58,6 +81,8 @@ function startFFmpeg(): ChildProcessWithoutNullStreams {
let frameBuffer = Buffer.alloc(0);
const ffmpegProcess = startFFmpeg();
const videoSource = new nonstandard.RTCVideoSource();
// Function to create a WebRTC PeerConnection
async function createPeerConnection(): Promise<RTCPeerConnection> {
@ -99,10 +124,14 @@ async function createPeerConnection(): Promise<RTCPeerConnection> {
// console.error('FFmpeg Error:', data.toString());
});
ffmpegProcess.on('exit', (code) => {
console.log(`FFmpeg exited with code ${code}`);
});
// Add the track to the PeerConnection
const track: MediaStreamTrack = videoSource.createTrack();
console.log('vdei src ',videoSource.isScreencast)

View File

@ -42,6 +42,7 @@
ws.onopen = async () => {
pc.addTransceiver('video', { direction: 'recvonly' });
pc.addTransceiver('audio', { direction: 'recvonly' })
const offer = await pc.createOffer();
await pc.setLocalDescription(offer);
// ws.send(JSON.stringify(offer));