Sending rtsp camera streaming over internet

I was originally trying to use a single mqtt, but couldn't get the subscribing side correct. Thanks for the info. I find the mqtt very interesting. If only I had a 2nd machine to play with.

2 Likes

I was originally trying to use a single mqtt, but couldn't get the subscribing side correct. Thanks for the info. I find the mqtt very interesting. If only I had a 2nd machine to play with.

Easy enough. There are lot's of mqtt brokers (i.e. https://console.hivemq.cloud/). You can subscribe to one for free and just use your node-red instance. The mqtt out node will send the message to the broker, and the mqtt in will get the msg you already posted.

I use BeeBottle as my MQTT broker. It has a free account with daily limits.

Firstly I would thanks you all again, this Forum is for sure the best and quick one I have ever seen, not only for the admins but even for all the users that share their knowledge. Thanks again so much.

I know, you're right but that's it, unfortunately. In this place I have a sim for internet connection, and here all provider, for not business uses, give you a private IP. Otherwise you can take an M2M sim, but cost increases and the amount of available traffic is very low.

MQTT works in a really impressive way. Honestly I thought it was designed for quick and light messages, and that wouldn't be the best solution for video stream. Well, probably I was wrong.

I made some test but apparently without any change as result, using within mp4frag "Repeated true or false" or even "Time Limit = -1) in order to disable Repeated option. Anyway, in my particular situation I don't care if some segments are corrupted or missed. Spo at the end I set: Size=5 Extra=1 Pre Buffer=1 Time Limit=-1

  1. Last thing.

At the end, using mqtt the streaming flow must be always active. I mean the publisher must start it and keep the flow running, for ever. if I'm not wrong. This mean lots of unused streaming messages. There is a build in solution that you think can be utilized in order to start the streaming only when the mqtt client is "listening"? Or should I think to some kind of feedback, like a first message published by the client that tell to node-red to starts sending the video.

If you use this example you could send both start write and stop write from the listening client. Just some more MQTT nodes or dedicated topics and some switch nodes. The thing eventually to handle is if you have more clients listening, you would not like the streaming to stop as long as at least one client is listening

Yep, I didnt really document that yet. I was building out that feature for someone who wanted to do recordings from the mp4 buffer. I added a couple convenience features to output in 3 different ways: unlimited mp4 with no end, time limited mp4 output, and then repeated mode that starts a new mp4 output after the previous output ends due to time limit.

I think I will be adding an option to "automatically start" the buffer output instead of always requiring an input command. Also, might have options to turn on or off the http server, etc. In your situation, there may not need to be a http or socket .io server running if you are only needing the buffer to transmit via mqtt.

Thanks. I have signed up for both free tiers. If I shared my secure mqtt url with someone else, could it be used for me to transmit video to them without needing to open ports? Reminds me of an experiment in the early days of shinobi cctv when we were experimenting with sending video off site. I was able to transmit video to guy in the other country using a ffmpeg to ffmpeg connection. Had to open ports and video was very choppy. It would be interesting to explore what mqtt can handle with large buffer packets.

Yes, you could! If you just want to test to verify, you could create some unique topics to use. You could test also on the test.mosquitto.org mqtt broker. I'll leave a stream running at the topic "mp4_123_test"

I could not stop myself from trying a flow like below. With this you can start & stop the stream from the client dashboard (it is however not handling/counting number of multiple connected clients if you would need that)

To avoid that we "overwrite" buffers and turn off servers when we run this flow, please configure your own personal topics for the MQTT nodes

Like change "mp4_123_test" and "mp4_123_server_on_off" to something personal. Otherwise you would maybe get other peoples camera views and turn on/off their servers :wink:


The flow:

[{"id":"d353460.3cd53b8","type":"mqtt in","z":"e193914.078e67","name":"","topic":"mp4_123_test","qos":"2","datatype":"auto","broker":"ed237c6b.40d1b","nl":false,"rap":true,"rh":0,"x":120,"y":700,"wires":[["d8444f28.0523"]]},{"id":"96a55dd1.544a7","type":"ui_mp4frag","z":"e193914.078e67","name":"","group":"9c7f211e.e2d06","order":1,"width":6,"height":4,"readyPoster":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAyAAAAJYCAMAAACtqHJCAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA2hpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8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BBAICAYGAQEAgIBAQCAgEBAIIBAQCAgGBgEBAICAQEAgIBAQCCAQEAgIBgYBAQCAgEBAICAQEAggEBAICAYGAQEAgIBAQCAgEEAgIBAQCAgGBgEBAICAQEAgIBBAICAQEAgIBgYBAQCAgEBAIIBAQCAgEBAICAYGAQEAgIBAQCCAQEAgIBAQCAgGBgEBAICAQQCAgEBAICAQEAgIBgYBAQCAgEEAgIBAQCAgEBAICAYGAQEAggEBAICAQEAgIBAQCAgGBgEBAIIBAQCAgEBAICAQEAgIBgYBAQCCAQEAgIBAQCAgEBAICAYGAQACBgEBAICAQEAgIBAQCAgGBgEAAgYBAQCAgEBAICAQEAgIBgQACAYGAQEAgIBAQCAgEBAICAYEAAgGBgEBAICAQEAgIBAQCAgEEAgIBgYBAQCAgEBAICAQEAgIBIv8Djt0c3tPuuskAAAAASUVORK5CYII=","hlsJsConfig":"{\"liveDurationInfinity\":true,\"liveBackBufferLength\":5,\"maxBufferLength\":10,\"manifestLoadingTimeOut\":1000,\"manifestLoadingMaxRetry\":10,\"manifestLoadingRetryDelay\":500}","retry":true,"play":true,"unload":true,"threshold":0.5,"players":["socket.io","hls.js","hls","mp4"],"x":700,"y":730,"wires":[[]]},{"id":"5c03658f.ca806c","type":"mp4frag","z":"e193914.078e67","name":"","migrate":2e-9,"hlsPlaylistSize":4,"hlsPlaylistExtra":0,"basePath":"123client","repeated":"false","timeLimit":"10000","preBuffer":"1","x":510,"y":730,"wires":[["96a55dd1.544a7"],[]]},{"id":"d8444f28.0523","type":"switch","z":"e193914.078e67","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"close","vt":"str"},{"t":"istype","v":"buffer","vt":"buffer"}],"checkall":"true","repair":false,"outputs":2,"x":310,"y":700,"wires":[["f64b8385.04e23"],["5c03658f.ca806c"]]},{"id":"f64b8385.04e23","type":"json","z":"e193914.078e67","name":"","property":"payload","action":"","pretty":false,"x":470,"y":670,"wires":[["5c03658f.ca806c"]]},{"id":"e5574b65.3a9308","type":"mqtt in","z":"e193914.078e67","name":"","topic":"mp4_123_server_on_off","qos":"2","datatype":"auto","broker":"ed237c6b.40d1b","nl":false,"rap":true,"rh":0,"x":170,"y":520,"wires":[["ac466242.598ef"]]},{"id":"ac466242.598ef","type":"json","z":"e193914.078e67","name":"","property":"payload","action":"","pretty":false,"x":180,"y":460,"wires":[["9ca7c9c3.171a78"]]},{"id":"ccb74ab3.5b1278","type":"mqtt out","z":"e193914.078e67","name":"","topic":"mp4_123_server_on_off","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"ed237c6b.40d1b","x":530,"y":800,"wires":[]},{"id":"371dc912.1723b6","type":"ui_button","z":"e193914.078e67","name":"","group":"9c7f211e.e2d06","order":2,"width":"6","height":"1","passthru":false,"label":"{{msg.txt}}","tooltip":"","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"true","payloadType":"bool","topic":"","topicType":"str","x":100,"y":800,"wires":[["84b6c29d.4f7d1"]]},{"id":"84b6c29d.4f7d1","type":"function","z":"e193914.078e67","name":"","func":"var state = context.get('state_buffer')||'off';\n//node.warn(state);\n\nswitch (state) {\n    case 'off':\n        msg.payload = {\"subject\":\"write\",\"command\":\"start\",\"timeLimit\":-1};\n        context.set('state_buffer', 'on');\n        break;\n    case 'on':\n        msg.payload = {\"subject\":\"write\",\"command\":\"stop\"};\n        context.set('state_buffer', 'off');\n        break;\n    default:\n        msg.payload = {\"subject\":\"write\",\"command\":\"start\",\"timeLimit\":-1};\n        context.set('state_buffer', 'on');\n        break;\n}\n\nnode.send(msg);","outputs":"1","noerr":0,"initialize":"","finalize":"","libs":[],"x":270,"y":800,"wires":[["c83a79e8.50b388","ccb74ab3.5b1278"]]},{"id":"12ae2d42.f85043","type":"change","z":"e193914.078e67","name":"","rules":[{"t":"set","p":"background","pt":"msg","to":"orange","tot":"str"},{"t":"set","p":"txt","pt":"msg","to":"Please wait...","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":950,"wires":[["50bf018d.2be41","371dc912.1723b6"]]},{"id":"c83a79e8.50b388","type":"switch","z":"e193914.078e67","name":"","property":"payload.command","propertyType":"msg","rules":[{"t":"cont","v":"start","vt":"str"},{"t":"cont","v":"stop","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":270,"y":850,"wires":[["12ae2d42.f85043"],["ea0f87a0.a9a9c8"]]},{"id":"ea0f87a0.a9a9c8","type":"change","z":"e193914.078e67","name":"","rules":[{"t":"set","p":"background","pt":"msg","to":"red","tot":"str"},{"t":"set","p":"txt","pt":"msg","to":"Streaming OFF","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":900,"wires":[["371dc912.1723b6"]]},{"id":"9ca7c9c3.171a78","type":"change","z":"e193914.078e67","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"action","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":180,"y":400,"wires":[["9cc6812c.92bde"]]},{"id":"c0028b83.5ba2a8","type":"trigger","z":"e193914.078e67","name":"","op1":"","op2":"{\"command\":\"start\",\"args\":[\"-loglevel\",\"error\",\"-nostats\",\"-f\",\"hls\",\"-http_multiple\",\"1\",\"-re\",\"-i\",\"https://weather-lh.akamaihd.net/i/twc_1@92006/index_1200_av-p.m3u8?sd=10&rebase=on\",\"-c:v\",\"copy\",\"-c:a\",\"aac\",\"-f\",\"mp4\",\"-movflags\",\"+frag_keyframe+empty_moov+default_base_moof\",\"pipe:1\",\"-progress\",\"pipe:3\",\"-f\",\"image2pipe\",\"-vf\",\"select='eq(pict_type,PICT_TYPE_I)',scale=trunc(iw/4):-2\",\"-vsync\",\"vfr\",\"pipe:4\"]}","op1type":"nul","op2type":"json","duration":"5","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":340,"y":270,"wires":[["b2276854.a04758"]]},{"id":"9cc6812c.92bde","type":"switch","z":"e193914.078e67","name":"","property":"action.command","propertyType":"msg","rules":[{"t":"cont","v":"start","vt":"str"},{"t":"cont","v":"stop","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":180,"y":310,"wires":[["c0028b83.5ba2a8"],["b14c1a0f.5530d8"]]},{"id":"b14c1a0f.5530d8","type":"trigger","z":"e193914.078e67","name":"","op1":"","op2":"{\"command\":\"stop\"}","op1type":"nul","op2type":"json","duration":"5","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":340,"y":340,"wires":[["b2276854.a04758"]]},{"id":"b2276854.a04758","type":"ffmpeg-spawn","z":"e193914.078e67","name":"","outputs":5,"migrate":1e-9,"cmdPath":"ffmpeg","cmdArgs":"[\"-loglevel\",\"error\",\"-nostats\",\"-f\",\"hls\",\"-http_multiple\",\"1\",\"-re\",\"-i\",\"https://weather-lh.akamaihd.net/i/twc_1@92006/index_1200_av-p.m3u8?sd=10&rebase=on\",\"-c:v\",\"copy\",\"-c:a\",\"aac\",\"-f\",\"mp4\",\"-movflags\",\"+frag_keyframe+empty_moov+default_base_moof\",\"pipe:1\",\"-progress\",\"pipe:3\"]","cmdOutputs":4,"killSignal":"SIGTERM","x":340,"y":180,"wires":[["dd07d8e7.8e4b48"],["dd07d8e7.8e4b48"],[],[],[]]},{"id":"c4ffcbe0.7ac2f8","type":"inject","z":"e193914.078e67","name":"start default","props":[{"p":"action","v":"{\"command\":\"start\"}","vt":"json"}],"repeat":"","crontab":"","once":false,"onceDelay":"1","topic":"","payloadType":"str","x":120,"y":140,"wires":[["b2276854.a04758"]]},{"id":"9e310dd2.34f96","type":"inject","z":"e193914.078e67","name":"stop default","props":[{"p":"action","v":"{\"command\":\"stop\"}","vt":"json"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"str","x":120,"y":220,"wires":[["b2276854.a04758"]]},{"id":"302ee2d6.8fe45e","type":"comment","z":"e193914.078e67","name":"start ffmpeg","info":"","x":120,"y":104,"wires":[]},{"id":"363db931.0dc4a6","type":"comment","z":"e193914.078e67","name":"stop ffmpeg","info":"","x":120,"y":180,"wires":[]},{"id":"dd07d8e7.8e4b48","type":"mqtt out","z":"e193914.078e67","name":"","topic":"mp4_123_test","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"ed237c6b.40d1b","x":570,"y":180,"wires":[]},{"id":"17d3345a.8e43fc","type":"comment","z":"e193914.078e67","name":"Server side (machine one)","info":"","x":160,"y":50,"wires":[]},{"id":"4617d743.771aa8","type":"comment","z":"e193914.078e67","name":"Client side (machine xy)","info":"","x":150,"y":620,"wires":[]},{"id":"50bf018d.2be41","type":"trigger","z":"e193914.078e67","name":"","op1":"","op2":"true","op1type":"nul","op2type":"bool","duration":"5","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":270,"y":1000,"wires":[["5d4a1672.e90538"]]},{"id":"5d4a1672.e90538","type":"change","z":"e193914.078e67","name":"","rules":[{"t":"set","p":"background","pt":"msg","to":"green","tot":"str"},{"t":"set","p":"txt","pt":"msg","to":"Streaming ON","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":1050,"wires":[["371dc912.1723b6"]]},{"id":"ed237c6b.40d1b","type":"mqtt-broker","name":"test.mosquitto.org","broker":"test.mosquitto.org","port":"1883","tls":"ce0f0716.0b63b8","clientid":"","usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""},{"id":"9c7f211e.e2d06","type":"ui_group","name":"Video over MQTT","tab":"4ea63eac.dccaf","order":1,"disp":false,"width":"6","collapse":false},{"id":"ce0f0716.0b63b8","type":"tls-config","name":"","cert":"","key":"","ca":"","certname":"","keyname":"","caname":"","servername":"","verifyservercert":true},{"id":"4ea63eac.dccaf","type":"ui_tab","name":"Video over MQTT","icon":"dashboard","disabled":false,"hidden":false}]
2 Likes

Thanks krambriw, I was thinking to something similar to that, with a counter increasing/decreasing by messages sent from client side via mqtt. So I could start sending the video flow when the first client is connected, and stop it when the last one is disconnected. I already implemented something similar but using ui_control (all in local environment or even remotely but directly reaching the dashboard via IP, without remote mqtt, ecc). In that case it was easy to overcome the problem when you have a line disconnection, thanks to ui_control. In this case, wia mqtt, I'm thinking how to face this without complicate it too much

[{"id":"8a857234.e024","type":"ui_ui_control","z":"f68e9dd6.332eb","name":"","events":"all","x":100,"y":120,"wires":[["8ec1bf4d.4f579"]]},{"id":"8ec1bf4d.4f579","type":"function","z":"f68e9dd6.332eb","name":"Connection","func":"var Connected = context.get(\"Connected\");\nvar Connection = context.get(\"Connection\");\nif (msg.payload == \"connect\"){\n    Connected = true;\n    Connection = Connection +1;\n}\nif (msg.payload == \"lost\"){\n    Connection = Connection -1;\n    if (Connection == 0){\n        Connected = false;\n    }\n}\n\nif (context.get(\"Connected\")==false && Connection==1){\n    msg.connected = true;\n} else if (context.get(\"Connected\")==true && Connection==0){\n    msg.connected = false;\n} else {\n    msg.connected = null;\n}\n\ncontext.set(\"Connection\", Connection);\ncontext.set(\"Connected\", Connected);\n\nreturn [msg];","outputs":1,"noerr":0,"initialize":"// Connected\nif (context.get(\"Connected\") == undefined) {\n    context.set(\"Connected\",false)\n} else {\n    context.set(\"Connected\",context.get(\"Connected\"));\n}\n// Connection\nif (context.get(\"Connection\") == undefined) {\n    context.set(\"Connection\",0)\n} else {\n    context.set(\"Connection\",context.get(\"Connection\"));\n}\n","finalize":"","x":290,"y":120,"wires":[["93ed8d47.82bc6"]]},{"id":"93ed8d47.82bc6","type":"switch","z":"f68e9dd6.332eb","name":"","property":"connected","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":490,"y":120,"wires":[["a10f874f.074bc8","e32c83cb.58612"],["2e184129.c194fe","d6769b7e.c043d8","74f23c32.730d04"]]},{"id":"a10f874f.074bc8","type":"link out","z":"f68e9dd6.332eb","name":"Start connection","links":["92d2f636.22b858","cb32c510.a6ffe8","4f5d2049.fe3ab","c5bb114.b19caf"],"x":655,"y":80,"wires":[]},{"id":"d6769b7e.c043d8","type":"link out","z":"f68e9dd6.332eb","name":"Stop conection - Video","links":["87da0239.7b80a"],"x":655,"y":140,"wires":[]}]

image

Mmm, thinking better, it's not exactly this way. At the end the "client" side is where the IP camera is placed, and that directly talk with the "server", reachable on a public IP. Now all users will connect with the server and not with the client, so at the and the counter could be easily implemented on the server side. At the end you could have more connections user-server, but there will always be just one connection server-client. Maybe that could be the trick

I've got a set of ESP32-CAM camera modules on order from China.
It would be great if I could talk to them and control them using the above flow.
Any comments on the feasibility of this idea??
Screen Shot 06-05-21 at 12.42 PM

Hi Dave,
Most likely they do not provide rtsp streams but instead image frames via http. I have a couple of cameras providing the same and in that case you could:

  • use one of the earlier flows above (jpeg_test) that grabs those frames and publishes them to mqtt and then on the client side simply subscribe to the same topic and present them on the dashboard using (as example) the media node as in the example flow
  • convert from http to mp4. That will however load the cpu rather heavily but if you run the server on a RPi3 or 4 you can utlize the GPU that lowers the CPU load significantly

Best image/video quality will with those cameras, I guess, be to avoid converting to mp4. If you are lucky that they do provide rtsp, well then just use one of the later flow samples and modify the settings to fit the url of your camera

1 Like

Hi Walter,
Thanks for your swift response - and useful information.
I suspected that would be the case.
I'll just have to be patient and wait until the cameras arrive.

At just GBP 4.25 each I just couldn't resist buying a couple.
Going to have a 'crack' at doing some time lapse photography.

How do you say to the pi to use GPU for this task?

There are descriptions around how to enable the GPU in general. In addition you will (eventually) have to build ffmpeg to support or be able to use it

When I just type "ffmpeg -encoders | grep 264" in a command prompt I get:

pi@nrpi:~ $ ffmpeg -encoders | grep 264
ffmpeg version git-2021-04-20-718e03e Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 8 (Raspbian 8.3.0-6+rpi1)
  configuration: --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib --extra-libs='-lpthread -lm -latomic' --arch=armel --enable-gmp --enable-gpl --enable-libaom --enable-libass --enable-libdav1d --enable-libdrm --enable-libfdk-aac --enable-libfreetype --enable-libkvazaar --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libssh --enable-libvorbis --enable-libvpx --enable-libzimg --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-mmal --enable-nonfree --enable-omx --enable-omx-rpi --enable-version3 --target-os=linux --enable-pthreads --enable-openssl --enable-hardcoded-tables
  libavutil      56. 73.100 / 56. 73.100
  libavcodec     58.136.101 / 58.136.101
  libavformat    58. 78.100 / 58. 78.100
  libavdevice    58. 14.100 / 58. 14.100
  libavfilter     7.111.100 /  7.111.100
  libswscale      5. 10.100 /  5. 10.100
  libswresample   3. 10.100 /  3. 10.100
  libpostproc    55. 10.100 / 55. 10.100
 V..... libx264              libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (codec h264)
 V..... libx264rgb           libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 RGB (codec h264)
 V..... h264_omx             OpenMAX IL H.264 video encoder (codec h264)
 V..... h264_v4l2m2m         V4L2 mem2mem H.264 encoder wrapper (codec h264)
 V....D h264_vaapi           H.264/AVC (VAAPI) (codec h264)

In my case I find that ffmpeg supports "h264-omx" and then I use this as a typical param to use the GPU:
-c:v h264_omx instead of -c:v copy

In my /boot/config.txt I have also increased the memory available for the GPU with gpu_mem=256

I'd like to give some observations of improvement for transmitting mp4 via mqtt so that I don't forget later on when trying to implement features. It's mostly a list of things I am brainstorming:

  • brokers have quota limitations such as size of message or number of transmits and receives
  • preferably send complete segments so that there is less individual transmits and receives (to help not exceed quotas)
  • an mp4 media segment may be larger in size due to more scene activity and exceed size limit of broker
  • complete segments will help the receiving side mp4frag parser from crashing due to missing pieces of buffer
  • if sending pieces, the internal error handling of mp4frag will need to be improved to account for occasional missing pieces
  • the duration data is lost when transmitting complete segments
  • only the payload gets sent, which would mean that an object containing the segment, duration, etc. would have to be sent as opposed to just the segment<Buffer>
  • mp4frag currently has topics attached to the segment buffer output, which are overridden if setting the topic in the mqtt node
  • receiving side must always receive the very first piece of mp4 buffer (ftyp atom) before segment data so that it can be playable
  • receiving side mp4frag should be able to receive an object containing a pre-parsed segment and its duration so that it does not unnecessarily try to parse it again

This list is not compete in anyway, as I am sure there are many more things to consider when using mqtt.

2 Likes

Nice brainstorming!

It would be possible to add a node (function) before the mqtt out node to "construct" a message holding an object with the missing parts. But also on receiving side we would have to "decode" it back so we can separate between messages holding image data and control commands

Haven't tried that but you could skip to configure topic in the mqtt out node but you have to be sure the topics provided are unique per mp4frag node. You also need to know those so you can configure the subscription in the mqtt in node on the client side correctly

Maybe setting the QoS to 2 would help here?

PS: Did you yet try to view the video I'm streaming out?

I did subscribe to it and pipe that to a debug node to see that it is live. But, since I will be unable to receive the first piece of mp4 (ftyp atom), I am sure it would not be viewable. I would have to be subscribing for when you first start to publish.

I did restart it now!

She is really good at holding her breath under water.