I can’t transmit the webcam to the server and to the website. Before, I was able to transmit the webcam (I don’t remember how), but I only see frames continuously sent in cmd and don’t see anything at localhost:3000 or
I installed socket.io, ffmpeg and nodejs path
And when i try this one, everything fine on udp, but to server and website is impossible.
ffplay udp://
ffmpeg -f dshow -framerate 30 -video_size 640×480 -i video=”Integrated Camera” -vcodec mpeg4 -f mpegts udp://

My server.js code:

const http = require('http');
const fs = require('fs');
const server = http.createServer((req, res) => {
  res.writeHead(200, {'Content-Type': 'text/html'});
  fs.readFile(__dirname + '/index.html', (err, data) => {
    if (err) {
const io = require('socket.io')(server);

io.on('connection', (socket) => {
  console.log('A user connected');

  socket.on('disconnect', () => {
    console.log('User disconnected');

server.listen(3000, () => {
  console.log('Server is running on http://localhost:3000');

const spawn = require('child_process').spawn;

const ffmpeg = spawn('ffmpeg', [
  '-f', 'dshow',
  '-i', 'video="Integrated Camera"', // i'm sure this is my webcam window
  '-vcodec', 'libx264',
  '-preset', 'veryfast',
  '-tune', 'zerolatency',
  '-f', 'hls',
  '-hls_time', '2',
  '-hls_list_size', '6',
  '-hls_flags', 'delete_segments',
  '-hls_segment_filename', 'public/hls/stream%03d.ts',

ffmpeg.stderr.on('data', (data) => {
  console.error(`ffmpeg error: ${data}`);

My index.html:

<!DOCTYPE html>
<html lang="en">
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Streaming Camera</title>
  <video id="videoPlayer" width="640" height="480" controls></video>
  <script src="/socket.io/socket.io.js"></script>
    const socket = io();

    const video = document.getElementById('videoPlayer');
    const stream = new MediaStream();

    video.srcObject = stream;

    socket.on('stream', (data) => {
      const byteArray = new Uint8Array(data);
      const blob = new Blob([byteArray], { type: 'video/mp4' });
      const url = window.URL.createObjectURL(blob);

      const reader = new FileReader();
      reader.onloadend = () => {
        video.src = reader.result;

New contributor

dintel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.