呼叫流媒體伺服器統計功能,根據客戶關閉視訊流
阿新 • • 發佈:2018-12-21
在car-eye JT1078 平臺開發中可能遇到實時視訊忘記關閉的情況,裝置一直在推流在移動系統中是完全不可以接受的。 為止,我們需要自動監控裝置的推流和拉流情況,RTMP伺服器提供了基於json格式的輸出,用來表達有多少個客戶端連線。但客戶端觀看為0的時候,平臺自動關閉這個裝置流/
{"http-flv":{"nginx_version":"1.12.2","nginx_http_flv_version":"1.2.5","compiler":"gcc 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) ","built":"Nov 11 2018 23:58:51","pid":16265,"uptime":238184,"naccepted":27162,"bw_in":178848,"bytes_in":8709208744,"bw_out":259496,"bytes_out":6676436554,"servers":[[{"name":"live","live":{"streams":[{"name":"13826559865&channel=1","time":1847784,"bw_in":76648,"bytes_in":17433318,"bw_out":153296,"bytes_out":18198938,"bw_audio":24488,"bw_video":52152,"clients":[{"id":36315,"address":"119.123.132.126","time":21270,"dropped":0,"avsync":-67,"timestamp":1856075,"publishing":false,"active":true},{"id":36224,"address":"120.76.235.109","time":1846857,"dropped":0,"avsync":-67,"timestamp":1856075,"publishing":true,"active":true},{"id":36215,"address":"119.123.132.126","time":1921313,"flashver":"WIN 25,0,0,127","pageurl":"http://liveoss.com:8088/common/vedio_rtmp/index.jsp","swfurl":"http://vjs.zencdn.net/swf/5.4.0/video-js.swf","dropped":0,"avsync":-67,"timestamp":1856075,"publishing":false,"active":true}],"meta":{"video":{"width":352,"height":288,"frame_rate":15,"codec":"H264","profile":"Baseline","level":"2.0"}, "audio": {"codec":"AAC","profile":"LC","channels":"1","sample_rate":8000}},"nclients":3,"publishing":true,"active":true},{"name":"13826559865&channel=2","time":16521,"bw_in":71056,"bytes_in":136982,"bw_out":71024,"bytes_out":136949,"bw_audio":23640,"bw_video":47416,"clients":[{"id":36319,"address":"120.76.235.109","time":16361,"dropped":0,"avsync":-67,"timestamp":16478,"publishing":true,"active":true},{"id":36318,"address":"119.123.132.126","time":16766,"dropped":0,"avsync":-67,"timestamp":16478,"publishing":false,"active":true}],"meta":{"video":{"width":352,"height":288,"frame_rate":15,"codec":"H264","profile":"Baseline","level":"2.0"}, "audio": {"codec":"AAC","profile":"LC","channels":"1","sample_rate":8000}},"nclients":2,"publishing":true,"active":true},{"name":"13826559865&channel=3","time":8707,"bw_in":0,"bytes_in":3154217,"bw_out":0,"bytes_out":3154183,"bw_audio":0,"bw_video":0,"clients":[{"id":36326,"address":"120.76.235.109","time":7922,"dropped":0,"avsync":0,"timestamp":8088,"publishing":true,"active":true},{"id":36325,"address":"119.123.132.126","time":8976,"dropped":0,"avsync":0,"timestamp":8088,"publishing":false,"active":true}],"meta":{"video":{"width":1280,"height":720,"frame_rate":15,"codec":"H264","profile":"Main","level":"3.1"}, "audio": {"codec":"AAC","profile":"LC","channels":"1","sample_rate":8000}},"nclients":2,"publishing":true,"active":true},{"name":"13826559865&channel=4","time":11457,"bw_in":99712,"bytes_in":135168,"bw_out":99688,"bytes_out":135135,"bw_audio":23640,"bw_video":76072,"clients":[{"id":36324,"address":"120.76.235.109","time":11315,"dropped":0,"avsync":0,"timestamp":11535,"publishing":true,"active":true},{"id":36323,"address":"119.123.132.126","time":11715,"dropped":0,"avsync":0,"timestamp":11535,"publishing":false,"active":true}],"meta":{"video":{"width":352,"height":288,"frame_rate":15,"codec":"H264","profile":"Baseline","level":"2.0"}, "audio": {"codec":"AAC","profile":"LC","channels":"1","sample_rate":8000}},"nclients":2,"publishing":true,"active":true}],"nclients":9}},{"name":"hls","live":{"streams":[],"nclients":0}},{"name":"dash","live":{"streams":[],"nclients":0}}]]}}
當客戶端關閉後,輸出成了:
{"http-flv":{"nginx_version":"1.12.2","nginx_http_flv_version":"1.2.5","compiler":"gcc 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) ","built":"Nov 11 2018 23:58:51","pid":16265,"uptime":238245,"naccepted":27162,"bw_in":3651312,"bytes_in":8734380791,"bw_out":2241448,"bytes_out":6699562368,"servers":[[{"name":"live","live":{"streams":[{"name":"13826559865&channel=1","time":1908170,"bw_in":77784,"bytes_in":17968274,"bw_out":136824,"bytes_out":19208463,"bw_audio":24776,"bw_video":53008,"clients":[{"id":36224,"address":"120.76.235.109","time":1907243,"dropped":0,"avsync":-67,"timestamp":1916777,"publishing":true,"active":true},{"id":36215,"address":"119.123.132.126","time":1981699,"flashver":"WIN 25,0,0,127","pageurl":"http://liveoss.com:8088/common/vedio_rtmp/index.jsp","swfurl":"http://vjs.zencdn.net/swf/5.4.0/video-js.swf","dropped":0,"avsync":-67,"timestamp":1916777,"publishing":false,"active":true}],"meta":{"video":{"width":352,"height":288,"frame_rate":15,"codec":"H264","profile":"Baseline","level":"2.0"}, "audio": {"codec":"AAC","profile":"LC","channels":"1","sample_rate":8000}},"nclients":2,"publishing":true,"active":true},{"name":"13826559865&channel=2","time":76907,"bw_in":72064,"bytes_in":632811,"bw_out":27128,"bytes_out":576120,"bw_audio":24488,"bw_video":47568,"clients":[{"id":36319,"address":"120.76.235.109","time":76747,"dropped":0,"avsync":0,"timestamp":77113,"publishing":true,"active":true}],"meta":{"video":{"width":352,"height":288,"frame_rate":15,"codec":"H264","profile":"Baseline","level":"2.0"}, "audio": {"codec":"AAC","profile":"LC","channels":"1","sample_rate":8000}},"nclients":1,"publishing":true,"active":true},{"name":"13826559865&channel=3","time":69093,"bw_in":3388720,"bytes_in":26514758,"bw_out":2000688,"bytes_out":23988175,"bw_audio":24488,"bw_video":3364224,"clients":[{"id":36326,"address":"120.76.235.109","time":68308,"dropped":0,"avsync":0,"timestamp":68790,"publishing":true,"active":true}],"meta":{"video":{"width":1280,"height":720,"frame_rate":15,"codec":"H264","profile":"Main","level":"3.1"}, "audio": {"codec":"AAC","profile":"LC","channels":"1","sample_rate":8000}},"nclients":1,"publishing":true,"active":true},{"name":"13826559865&channel=4","time":71843,"bw_in":101608,"bytes_in":832485,"bw_out":93896,"bytes_out":752979,"bw_audio":24488,"bw_video":77112,"clients":[{"id":36324,"address":"120.76.235.109","time":71701,"dropped":0,"avsync":0,"timestamp":72237,"publishing":true,"active":true}],"meta":{"video":{"width":352,"height":288,"frame_rate":15,"codec":"H264","profile":"Baseline","level":"2.0"}, "audio": {"codec":"AAC","profile":"LC","channels":"1","sample_rate":8000}},"nclients":1,"publishing":true,"active":true}],"nclients":5}},{"name":"hls","live":{"streams":[],"nclients":0}},{"name":"dash","live":{"streams":[],"nclients":0}}]]}}
其中客戶端nclients變成1代表這個通道已經沒有客戶端進行連線。此時需要設定超時後進行自動關閉。
相關功能在car-eye 車輛管理平臺已經實現: