ossrs / srs

SRS is a simple, high-efficiency, real-time media server supporting RTMP, WebRTC, HLS, HTTP-FLV, HTTP-TS, SRT, MPEG-DASH, and GB28181.
https://ossrs.io
MIT License
25.69k stars 5.38k forks source link

RTMP: time_jitter: DTS out of order #2776

Closed thegobot closed 1 year ago

thegobot commented 2 years ago

if there is a big difference between the previous timestamp and the current timestamp - playback error

https://github.com/ossrs/srs/blob/b06661539c2d02b35b45e89df1bc23a43cabd0a3/trunk/src/app/srs_app_source.cpp#L73

ffplay [flv @ 0000000000555700] DTS 16925 < 16983 out of order

srs_trace("%d ==> %d, last_pkt_time:%d, delta: %d, %s", msg->timestamp, last_pkt_correct_time, last_pkt_time, delta, msg->is_audio() ? "audio" : "video");

Format: msg->timestam ==> last_pkt_correct_time, last_pkt_time, delta

38012 ==> 16764, last_pkt_time:37989, delta: 23, audio
38035 ==> 16787, last_pkt_time:38012, delta: 23, audio
38058 ==> 16810, last_pkt_time:38035, delta: 23, audio
38082 ==> 16834, last_pkt_time:38058, delta: 24, audio
38105 ==> 16857, last_pkt_time:38082, delta: 23, audio
38128 ==> 16880, last_pkt_time:38105, delta: 23, audio
38151 ==> 16903, last_pkt_time:38128, delta: 23, audio
38174 ==> 16926, last_pkt_time:38151, delta: 23, audio
38198 ==> 16950, last_pkt_time:38174, delta: 24, audio
38221 ==> 16973, last_pkt_time:38198, delta: 23, audio
correct jitter: dts: 37730, last_pkt_time: 38221, delta: 10, video //use default 10ms to notice the problem of stream
37730 ==> 16983, last_pkt_time:38221, delta: 10, video //LAST VIDEO FTS
correct jitter: dts: 38244, last_pkt_time: 37730, delta: 10, audio //use default 10ms to notice the problem of stream
38244 ==> 16993, last_pkt_time:37730, delta: 10, audio
38267 ==> 17016, last_pkt_time:38244, delta: 23, audio
38291 ==> 17040, last_pkt_time:38267, delta: 24, audio
38314 ==> 17063, last_pkt_time:38291, delta: 23, audio
38337 ==> 17086, last_pkt_time:38314, delta: 23, audio
38360 ==> 17109, last_pkt_time:38337, delta: 23, audio
38176 ==> 16925, last_pkt_time:38360, delta: -184, video // BAD timestamp (last video DTS = 16983) Video freezes in Chrome, but continue in ffplay

SRS: 4.0.178

winlinvip commented 2 years ago

Well it seems a discussion, and it not likely to happen so that we don't need to fix it?

thegobot commented 2 years ago

I suggest disabling the default option

time_jitter off #OR zero
winlinvip commented 2 years ago

I didn't get you, what's the issue? To play RTMP stream? How to replay this issue?

thegobot commented 2 years ago

I didn't get you, what's the issue? To play RTMP stream? How to replay this issue?

this is a borderline case. When changing the video resolution, my encoder(android yasea) sends the timestamps that I described at the beginning. Only disabling the jitter helped me

Yes, issue with playing (flv)

winlinvip commented 2 years ago

Rather than changing the default config value, it's much better to fix the jitter algorithm to fix this borderline case.

Patch welcome. 😄

thegobot commented 2 years ago

Alas, I can't make a patch. although with jitter disabled there are audio problems (flvjs) ... ohhh, I dream of switching completely to webrtc, I'm still testing, but it works great. flvjs is still a crutch...

winlinvip commented 2 years ago

WebRTC is not designed for live streaming, so there's a lot of problems.Parts of them have been solved by SRS, but some still exists. Be careful, it's really really complex.

Welcome for more discuss in discord.