Hi all,
I'm trying to add realtime statistics to the flow like: current bitrate (Mbps), Resolution, FPS & Bandwidth estimate (Mbps). The "current bitrate" is the most important one I guess.
I've used the excellent node-red-contrib-msg-size
and node-red-contrib-msg-speed
nodes for that, but I'm getting different results comparing to FFMPEG, as shown below:
[{"id":"ecc625cc.78b4b8","type":"exec","z":"ef7323f9.ad195","command":"","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"BITRATE","x":360,"y":200,"wires":[["66230546.d4bb2c"],[],["21767a4.918bd86"]]},{"id":"e9ffed02.839e2","type":"inject","z":"ef7323f9.ad195","name":"Stop stream","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":115,"y":200,"wires":[["cc54df93.0dd71"]],"l":false},{"id":"cc54df93.0dd71","type":"function","z":"ef7323f9.ad195","name":"stop","func":"msg = {\n kill:'SIGHUP',\n payload : 'SIGHUP' \n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":210,"y":200,"wires":[["ecc625cc.78b4b8"]]},{"id":"59b33cf8.d685d4","type":"inject","z":"ef7323f9.ad195","name":"Stream1","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"1","topic":"2>&1 | grep bitrate | sed 's/bitrate: \\(.*\\), kb/\\1/g'","payload":"https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_480_1_5MG.mp4","payloadType":"str","x":80,"y":80,"wires":[["cdaba4b0.ca6ec8"]]},{"id":"cdaba4b0.ca6ec8","type":"change","z":"ef7323f9.ad195","name":"set ffmpeg","rules":[{"t":"set","p":"payload","pt":"msg","to":"\"ffmpeg -i \" & msg.payload & \" \" &msg.topic","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":230,"y":160,"wires":[["ecc625cc.78b4b8"]]},{"id":"c95eeaba.c312a8","type":"inject","z":"ef7323f9.ad195","name":"Stream2","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"2>&1 | grep bitrate | sed 's/bitrate: \\(.*\\), kb/\\1/g'","payload":"https://multiplatform-f.akamaihd.net/i/multi/april11/sintel/sintel-hd_,512x288_450_b,640x360_700_b,768x432_1000_b,1024x576_1400_m,.mp4.csmil/master.m3u8","payloadType":"str","x":80,"y":120,"wires":[["cdaba4b0.ca6ec8"]]},{"id":"2be7b45e.fa087c","type":"split","z":"ef7323f9.ad195","name":"","splt":", ","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":210,"y":260,"wires":[["4e3df559.bb77dc"]]},{"id":"4e3df559.bb77dc","type":"join","z":"ef7323f9.ad195","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":350,"y":260,"wires":[["41661916.c5cb18"]]},{"id":"845811c3.806c6","type":"debug","z":"ef7323f9.ad195","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":575,"y":260,"wires":[],"l":false},{"id":"41661916.c5cb18","type":"change","z":"ef7323f9.ad195","name":"parse","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload[2]","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"$number( $replace(msg.payload, /([^\\d])+/, \"\") )","tot":"jsonata"},{"t":"set","p":"topic","pt":"msg","to":"single_bitrate","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":260,"wires":[["845811c3.806c6"]]},{"id":"66230546.d4bb2c","type":"switch","z":"ef7323f9.ad195","name":"multi-bitrate?","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"variant_bitrate","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":520,"y":180,"wires":[["1cd9f2b8.9912ed"],["2be7b45e.fa087c"]]},{"id":"2120220d.a93b9e","type":"inject","z":"ef7323f9.ad195","name":"Stream3","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"2>&1 | grep bitrate | sed 's/bitrate: \\(.*\\), kb/\\1/g'","payload":"https://multiplatform-f.akamaihd.net/i/multi/april11/hdworld/hdworld_,512x288_450_b,640x360_700_b,768x432_1000_b,1024x576_1400_m,.mp4.csmil/master.m3u8","payloadType":"str","x":80,"y":160,"wires":[["cdaba4b0.ca6ec8"]]},{"id":"1cd9f2b8.9912ed","type":"split","z":"ef7323f9.ad195","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":670,"y":180,"wires":[["1fee7710.8f2289"]]},{"id":"eab37bae.aab858","type":"join","z":"ef7323f9.ad195","name":"","mode":"reduce","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":",","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"$append($A,[payload])","reduceInit":"[]","reduceInitType":"json","reduceFixup":"","x":910,"y":180,"wires":[["54091b45.73c984"]]},{"id":"54091b45.73c984","type":"change","z":"ef7323f9.ad195","name":"distinct","rules":[{"t":"set","p":"payload","pt":"msg","to":"$distinct(msg.payload)","tot":"jsonata"},{"t":"set","p":"topic","pt":"msg","to":"multi_bitrate","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":920,"y":220,"wires":[["cc30a8e5.48fdd8"]]},{"id":"cc30a8e5.48fdd8","type":"debug","z":"ef7323f9.ad195","name":"multi_bitrate","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1015,"y":220,"wires":[],"l":false},{"id":"1fee7710.8f2289","type":"change","z":"ef7323f9.ad195","name":"trim","rules":[{"t":"set","p":"payload","pt":"msg","to":"$trim(msg.payload)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":790,"y":180,"wires":[["eab37bae.aab858"]]},{"id":"21767a4.918bd86","type":"debug","z":"ef7323f9.ad195","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":655,"y":220,"wires":[],"l":false}]
Any idea how to output the current bitrate from the exec-node
or from the amazing mp4frag
node? Or maybe change the FFMPEG command to make it show the current bitrate in spawn mode? Thanks!