Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No such file or directory for rtsp url #1260

Open
3 tasks done
mselgamal opened this issue Mar 29, 2024 · 1 comment
Open
3 tasks done

No such file or directory for rtsp url #1260

mselgamal opened this issue Mar 29, 2024 · 1 comment

Comments

@mselgamal
Copy link

Version information

  • fluent-ffmpeg version: 2.1.2
  • ffmpeg version: 5.1.4-0+rpt3+deb12u1
  • OS: Debian 12.2.0-14

Code to reproduce

ffmpegProcess = ffmpeg()
        .input("'rtsp://172.16.1.21:554/stream0?username=admin&password=<insert-pass>'")
        .inputOptions([
            '-loglevel debug',
            '-hide_banner',
            '-fflags nobuffer',
            '-flags low_delay',
            '-rtsp_transport udp'
        ])
        .outputOptions([
            '-c:v copy',
            '-an',
            '-preset veryfast',
            '-ssrc 0x'+ssrc,
            '-f rtp'
        ])
        .output("'rtp://52.86.222.93:43900?rtcpport=47929&pkt_size=1200'")
        .on('start', (commandLine) => {
            console.log('Spawned Ffmpeg with command: ' + commandLine);
        })
        .on('error', (err, stdout, stderr) => {
            console.error('An error occurred: ' + err.message);
            console.log('ffmpeg stdout:', stdout);
            console.log('ffmpeg stderr:', stderr);
        })
        .on('end', () => {
            console.log('Stream ended for camera');
        });
        
ffmpegProcess.run();

Expected results

ffmpeg process that streams rtp to a media server (output path)

everything works fine when using CLI to run identical command

Observed results

"rtsp://172.16.1.21:554/stream0?username=admin&password=E10ADC3949BA59ABBE56E057F20F883E": No such file or directory

Checklist

  • I have read the FAQ
  • I tried the same with command line ffmpeg and it works correctly (hint: if the problem also happens this way, this is an ffmpeg problem and you're not reporting it to the right place)
  • I have included full stderr/stdout output from ffmpeg
@johnnykoo84
Copy link

johnnykoo84 commented Aug 7, 2024

I am not sure if I have similar issue. I can send stream videos to my client with files ok, but with rtsp url, I cannot.

i get these logs and cannot play rtps url

2024-08-07 21:51:08 Processing: undefined% done
2024-08-07 21:51:08 Processing error
2024-08-07 21:51:08 File not exist
2024-08-07 21:51:21 Processing: undefined% done
2024-08-07 21:51:21 Processing error
2024-08-07 21:51:21 File not exist
2024-08-07 21:51:21 Processing: undefined% done
2024-08-07 21:51:21 Processing error
2024-08-07 21:51:21 File not exist
2024-08-07 21:51:28 Processing: undefined% done
2024-08-07 21:51:28 Processing error
2024-08-07 21:51:28 File not exist
2024-08-07 21:51:41 Processing: undefined% done
2024-08-07 21:51:41 Processing error
2024-08-07 21:51:41 File not exist

my code is below

ffmpeg(rtspUrl, { timeout: 432000 })
    .addOptions([
      "-profile:v baseline",
      "-fflags -nobuffer",
      "-probesize 32",
      "-s 480x360",
      "-level 3.0",
      "-start_number 0",
      "-hls_time 2",
      "-hls_list_size 0",
      "-f hls",
    ])
    .output("videos/output.m3u8")
    .on("end", () => {
      console.log("end");
    })
    .on("progress", function (progress: { percent: string }) {
      console.log("Processing: " + progress.percent + "% done");

      fs.access("videos/output.m3u8", fs.constants.F_OK, function (err: any) {
        if (err) {
          console.log("Processing error");
          console.log("File not exist");
        } else {
          if (headersSent === false) {
            console.log("Processing success");
            console.log("File exists");

            console.log("==========");
            console.log("==========m3u8 file detected==========");
            console.log("==========");

            headersSent = true;

            res.sendStatus(200);
          }
        }
      });
    })
    .run();

update

I got it work with below code and options

ffmpeg(rtspUrl, { timeout: 432000 })
    .addOptions([
      "-rtsp_transport tcp", // Use TCP for RTSP
      "-c:v libx264", // Set video codec to H.264
      "-profile:v baseline", // Use baseline profile for HLS compatibility
      "-fflags -nobuffer", // Disable buffering
      "-probesize 32", // Set probe size
      "-s 480x360", // Set output resolution
      "-level 3.0", // Set H.264 level
      "-start_number 0", // Start segment numbering
      "-hls_time 2", // Set segment duration to 2 seconds
      "-hls_list_size 3", // Unlimited playlist size
      "-hls_delete_threshold 5",
      "-hls_flags delete_segments",
      "-f hls", // Set output format to HLS
    ])
    .output(path.join(videosDir, "output.m3u8"))
    .on("end", () => {
      console.log("end");
    })
    .on("progress", function (progress: { percent: string }) {
      console.log("Processing: " + progress.percent + "% done");

      fs.access("videos/output.m3u8", fs.constants.F_OK, function (err: any) {
        if (err) {
          console.log("Processing error");
          console.log("File not exist");
          console.log(err);
        } else {
          if (headersSent === false) {
            console.log("Processing success");
            console.log("File exists");

            console.log("==========");
            console.log("==========m3u8 file detected==========");
            console.log("==========");

            headersSent = true;

            res.sendStatus(200);
          }
        }
      });
    })
    .run();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants