Open mselgamal opened 8 months ago
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();
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();
Version information
Code to reproduce
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