working with tv
This commit is contained in:
parent
5f9771ddb6
commit
795fd0cd38
@ -1,6 +1,6 @@
|
|||||||
curl https://git.linuxtv.org/dtv-scan-tables.git/plain/atsc/us-ATSC-center-frequencies-8VSB
|
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
|
dvbv5-scan -Cus -o dvb_channel.conf -O zap -v us-ATSC-center-frequencies-8VSB
|
@ -14,7 +14,8 @@ import { i420ToRgba, RTCVideoSource } from '@roamhq/wrtc/types/nonstandard';
|
|||||||
// const {mediaDevices} = wrtc
|
// const {mediaDevices} = wrtc
|
||||||
|
|
||||||
// Constants
|
// 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 WIDTH = 640; // Video width
|
||||||
const HEIGHT = 480; // Video height
|
const HEIGHT = 480; // Video height
|
||||||
const FRAME_SIZE = WIDTH * HEIGHT * 1.5; // YUV420p frame size (460800 bytes)
|
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 to start FFmpeg and capture raw video
|
||||||
function startFFmpeg(): ChildProcessWithoutNullStreams {
|
function startFFmpeg(): ChildProcessWithoutNullStreams {
|
||||||
return spawn('ffmpeg', [
|
const p = spawn('ffmpeg', [
|
||||||
'-f', 'v4l2', // Use Video4Linux2 for video capture
|
'-loglevel', 'debug',
|
||||||
'-i', VIDEO_DEVICE, // Input device
|
'-i', VIDEO_DEVICE, // Input device
|
||||||
'-vf', `scale=${WIDTH}:${HEIGHT}`, // Scale video resolution
|
'-vf', `scale=${WIDTH}:${HEIGHT}`, // Scale video resolution
|
||||||
'-vcodec', 'rawvideo', // Output raw video codec
|
'-vcodec', 'rawvideo', // Output raw video codec
|
||||||
'-pix_fmt', 'yuv420p', // Pixel format for WebRTC
|
'-pix_fmt', 'yuv420p', // Pixel format for WebRTC
|
||||||
'-f', 'rawvideo', // Output format
|
'-f', 'rawvideo', // Output format
|
||||||
'pipe:1' // Pipe to stdout
|
'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 =
|
// const videoSource =
|
||||||
@ -58,6 +81,8 @@ function startFFmpeg(): ChildProcessWithoutNullStreams {
|
|||||||
|
|
||||||
let frameBuffer = Buffer.alloc(0);
|
let frameBuffer = Buffer.alloc(0);
|
||||||
const ffmpegProcess = startFFmpeg();
|
const ffmpegProcess = startFFmpeg();
|
||||||
|
|
||||||
|
|
||||||
const videoSource = new nonstandard.RTCVideoSource();
|
const videoSource = new nonstandard.RTCVideoSource();
|
||||||
// Function to create a WebRTC PeerConnection
|
// Function to create a WebRTC PeerConnection
|
||||||
async function createPeerConnection(): Promise<RTCPeerConnection> {
|
async function createPeerConnection(): Promise<RTCPeerConnection> {
|
||||||
@ -99,10 +124,14 @@ async function createPeerConnection(): Promise<RTCPeerConnection> {
|
|||||||
// console.error('FFmpeg Error:', data.toString());
|
// console.error('FFmpeg Error:', data.toString());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ffmpegProcess.on('exit', (code) => {
|
ffmpegProcess.on('exit', (code) => {
|
||||||
console.log(`FFmpeg exited with code ${code}`);
|
console.log(`FFmpeg exited with code ${code}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Add the track to the PeerConnection
|
// Add the track to the PeerConnection
|
||||||
const track: MediaStreamTrack = videoSource.createTrack();
|
const track: MediaStreamTrack = videoSource.createTrack();
|
||||||
console.log('vdei src ',videoSource.isScreencast)
|
console.log('vdei src ',videoSource.isScreencast)
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
|
|
||||||
ws.onopen = async () => {
|
ws.onopen = async () => {
|
||||||
pc.addTransceiver('video', { direction: 'recvonly' });
|
pc.addTransceiver('video', { direction: 'recvonly' });
|
||||||
|
pc.addTransceiver('audio', { direction: 'recvonly' })
|
||||||
const offer = await pc.createOffer();
|
const offer = await pc.createOffer();
|
||||||
await pc.setLocalDescription(offer);
|
await pc.setLocalDescription(offer);
|
||||||
// ws.send(JSON.stringify(offer));
|
// ws.send(JSON.stringify(offer));
|
||||||
|
Loading…
Reference in New Issue
Block a user