天天看點

srs錄像丢失調查,50s video lost when recording 6hrs.

SRS錄像,發現統計直播時長和錄像時長不一緻。錄像6hour,差了50s。

調查發現,on_publish事件和on_unpublish事件之間,差距就有4s。這4s是合理的,并不是錄像視訊丢失。

錄像時長實際上是正确的,隻是兩個ts切片之間有視訊計算上的丢失。平均兩個ts之間就有15ms的時間被

gap。這個問題其實很好解決,上一個ts的end_time作為下一個ts的start_time就行了。

[16446][59hd9wz8] hls#1:start_dts=0,dts=8949,duration=8949000

[16446][59hd9wz8] hls#1:start_dts=8966,dts=8966,duration=0

On average, 15ms is lost for two ts. 1h lost 600*15=9s, 6 hours lost 54s.

[2021-03-31 07:58:27.215][Trace][19130][8571p0e1] publisher-stat: add publisher:127.0.0.1-live/ap01-1000

[2021-03-31 07:58:27.716][Trace][19130][8571p0e1] hls#1:start_dts=0,dts=0,duration=0

Start slicing, 0.5s later than the on_publish event. 3.5s after the end of slicing, the on_unpublish event is issued. The total difference is 4s.

[2021-03-31 07:58:45.257][Trace][19130][8571p0e1] hls#1:start_dts=8949000,dts=17912000,duration=8963000

[2021-03-31 07:58:48.711][Trace][19130][8571p0e1] publisher-stat: del publisher:127.0.0.1-live/ap01-1000

fixed and verified 3 times. difference is only 4s. that's normal.

[2021-03-31 08:39:44.387][Trace][20553][y86e90f6] publisher-stat-history: add {"uri":"live/ap01-1000","type":"rtmp","publisher_ip":"127.0.0.1","online":0,"start_ts":1617204747,"end_ts":1617205184,"duration":437}

hls-player shows video length is: 7:13