Open erikmartinjordan opened 3 years ago
Ok, I figured out that you can install ffmpeg-static
to include FFMpeg as a binary library (no need to preinstall FFMPeg in your computer).
Then, you can include ffmpegPath
as an option in the stream:
const express = require('express');
const ffmpegPath = require('ffmpeg-static');
Stream = require('node-rtsp-stream');
let app = express();
let server = app.listen(3000);
app.get('/video', function(req, res){
stream = new Stream({
name: 'name',
streamUrl: 'rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov',
wsPort: 9000,
ffmpegPath: ffmpegPath
});
res.send(
`<!DOCTYPE html>
<html>
<head>
<meta name = "viewport" content = "width=640, initial-scale=1"/>
<style type = "text/css">
html, body {
width: 800px;
height: 600px;
margin: 0;
}
canvas {
margin: 0;
}
</style>
</head>
<body>
<canvas id = "video"></canvas>
<script src = "https://cdnjs.cloudflare.com/ajax/libs/jsmpeg/0.2/jsmpg.js"></script>
<script>
var client = new WebSocket( 'ws://localhost:9000/' );
var canvas = document.getElementById('video');
var player = new jsmpeg(client, {canvas: canvas});
</script>
</body>
</html>`
);
});
Props to Alexander Cleasby, and his useful article.
@erikmartinjordan for me my pc have ffpmpeg install but when we build the app to .app for macos the ffmpeg is not loaded even i try using static
Could you share your code @punjasin?
I'm building an Electron application, which launches an Express server in the background and sends back a stream as a response.
Sample code:
It seems that
node-rtsp-stream
isn't creating the WebSocket and sending the stream. I guess it's failing because FFMpeg isn't installed on the server.The problem is that it's a client application and I don't have control if the user has FFMpeg installed on his computer.
Is there a way to make
node-rtsp-stream
work? Can I force the application to install FFMpeg in some way? Can I combineffmpeg
Node.js package to make it work?