From 9c292fe0818bdc9aa526be93aca80bed78c0f66e Mon Sep 17 00:00:00 2001 From: bordun Date: Wed, 17 Feb 2021 10:14:16 +0100 Subject: [PATCH] docs: rtsp custom module example --- resources/docs/docs/custom-module/examples.md | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/resources/docs/docs/custom-module/examples.md b/resources/docs/docs/custom-module/examples.md index 84704694..19464b55 100644 --- a/resources/docs/docs/custom-module/examples.md +++ b/resources/docs/docs/custom-module/examples.md @@ -274,3 +274,31 @@ module.exports = { } ``` + +## Display RTSP Stream + +```js +// requires ffmpeg installed on the system +// and rtsp-ffmpeg installed in the custom module's folder (by running npm install rtsp-ffmpeg) + +var rtsp = nativeRequire('rtsp-ffmpeg') + +var stream = new rtsp.FFMpeg({ + input: 'rtsp://freja.hiof.no:1935/rtplive/_definst_/hessdalen03.stream', +}) + +stream.on('data', (data)=>{ + + // send frame to image widget with address set to "/stream" + receive('/stream', 'data:image/jpeg;base64,' + data.toString('base64')) + +}) + +module.exports = { + + unload: ()=>{ + stream.stop() + } + +} +```