ossrs / srs-unity

WebRTC Samples with SRS SFU server for Unity.
https://ossrs.io
MIT License
64 stars 9 forks source link

Can't play video when player starts after publisher #5

Closed SpecterFire closed 1 year ago

SpecterFire commented 1 year ago

Hello, I encountered a problem. I use SrsStreamer in the project for streaming. If I start the streaming end first and then start the RTC player, I cannot get the video stream. When I check in chrome://webrtc-internals/, there is indeed no video data. However, if I start the RTC player and click the play button first, and then start Unity SrsStreamer for streaming, the streaming is successful at this time. What could be the cause of this?

TRANS_BY_GPT4

SpecterFire commented 1 year ago

Supplement: In both cases, audio can stream normally, but video cannot. The log contains the following warning: [2023-01-31 17:59:55.511][WARN][1772][pe60127j][11] avc ignore type=1 for no sequence header [2023-01-31 17:59:55.528][WARN][1772][pe60127j][11] avc ignore type=1 for no sequence header [2023-01-31 17:59:55.552][WARN][1772][pe60127j][11] avc ignore type=1 for no sequence header [2023-01-31 17:59:55.570][WARN][1772][pe60127j][11] avc ignore type=1 for no sequence header [2023-01-31 17:59:55.586][WARN][1772][pe60127j][11] avc ignore type=1 for no sequence header [2023-01-31 17:59:55.601][WARN][1772][pe60127j][11] avc ignore type=1 for no sequence header [2023-01-31 17:59:55.617][WARN][1772][pe60127j][11] avc ignore type=1 for no sequence header [2023-01-31 17:59:55.634][WARN][1772][pe60127j][11] avc ignore type=1 for no sequence header [2023-01-31 17:59:55.651][WARN][1772][pe60127j][11] avc ignore type=1 for no sequence header [2023-01-31 17:59:55.668][WARN][1772][pe60127j][11] avc ignore type=1 for no sequence header [2023-01-31 17:59:55.687][WARN][1772][pe60127j][11] avc ignore type=1 for no sequence header [2023-01-31 17:59:55.702][WARN][1772][pe60127j][11] avc ignore type=1 for no sequence header [2023-01-31 17:59:55.719][WARN][1772][pe60127j][11] avc ignore type=1 for no sequence header [2023-01-31 17:59:55.735][WARN][1772][pe60127j][11] avc ignore type=1 for no sequence header [2023-01-31 17:59:55.752][WARN][1772][pe60127j][11] avc ignore type=1 for no sequence header [2023-01-31 17:59:55.767][WARN][1772][pe60127j][11] avc ignore type=1 for no sequence header [2023-01-31 17:59:55.787][WARN][1772][pe60127j][11] avc ignore type=1 for no sequence header [2023-01-31 17:59:55.802][WARN][1772][pe60127j][11] avc ignore type=1 for no sequence header [2023-01-31 17:59:55.817][WARN][1772][pe60127j][11] avc ignore type=1 for no sequence header [2023-01-31 17:59:55.836][WARN][1772][pe60127j][11] avc ignore type=1 for no sequence header [2023-01-31 17:59:55.851][WARN][1772][pe60127j][11] avc ignore type=1 for no sequence header [2023-01-31 17:59:55.952][WARN][1772][pe60127j][11] avc ignore type=1 for no sequence header

TRANS_BY_GPT4

SpecterFire commented 1 year ago

After testing, avc ignore type=1 for no sequence header is caused by enabling rtc_to_rtmp, which may not be related to this issue.

TRANS_BY_GPT4

SpecterFire commented 1 year ago

Is it because Unity has set the AV_CODEC_FLAG_GLOBAL_HEADER, and SRS did not process the pps/sps obtained from stradata and put it before the keyframe?

TRANS_BY_GPT4

winlinvip commented 1 year ago

If player starts after publisher, it need to wait for next I frame from publisher, about 2~7s.

SRS wil send PLI to publisher to request I frame from publisher but it might not response.

It's not a bug and SRS can't fix it, I think Unity WebRTC sdk might couldn't fix it also. Just a different workflow of WebRTC.

cnjssj commented 1 year ago

Hello, I also encountered the same problem. There is sound when the stream is published first and then played, but the video cannot work normally. So that we cannot use the normal live broadcast function. Is there any solution to this problem? Thanks!

winlinvip commented 10 months ago

Fixed in 3.0.0-pre.5, see https://github.com/Unity-Technologies/com.unity.webrtc/issues/882