-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG]: H264 encoding problem with NvCodec. #882
Comments
I think the root cause is the NVCodec does not support PLI, which is essential for WebRTC. SRS is a WebRTC SFU, it works like this:
If start publisher before player, the player will request PLI to publisher, because in WebRTC the keyframe might lost or new participants will join the video room which need a new keyframe for decoding. If publisher does not response for the PLI request, the player never get a keyframe and can't decode the video stream. |
@winlinvip Hi, what's the following lines meaning? Does it matter? The following lines are printed all along with the stream pushing.
|
@winlinvip @karasusan I found out the problem. com.unity.webrtc/Plugin~/WebRTCPlugin/Codec/NvCodec/NvEncoderImpl.cpp Lines 445 to 450 in 0bfa9ff
Change it to the lines below. Add output spspps solve the problem. picParams.encodePicFlags = 0;
if (send_key_frame)
{
picParams.encodePicFlags = NV_ENC_PIC_FLAG_FORCEINTRA | NV_ENC_PIC_FLAG_FORCEIDR | NV_ENC_PIC_FLAG_OUTPUT_SPSPPS;
m_configurations[0].key_frame_request = false;
} UPDATE: reminded by @johzzy. The SPSPPS is only needed for keyframe. It solves the problem with verification. |
@SetoKaiba @winlinvip We will make the PR for solving this issue, do you have any concerns? |
The sequence header is SPS/PPS for H.264, or SPS/PPS/VPS for H.265, it's just a short name. No sequence header means no SPS/PPS, so it's not able to decode the video stream. The I confirmed with @johzzy, it works for me, thanks a lot @SetoKaiba @karasusan |
We are also working on adding WHIP support to FFmpeg. Please see ossrs/ffmpeg-webrtc#1. After this feature is merged, Unity will be able to communicate with FFmpeg applications. |
Package version
3.0.0-pre.4
Environment
Steps To Reproduce
https://github.com/SetoKaiba/srs-unity
Use this project to produce the bug.
Current Behavior
No response
Expected Behavior
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: