ant-media / Ant-Media-Server

Ant Media Server is a live streaming engine software that provides adaptive, ultra low latency streaming by using WebRTC technology with ~0.5 seconds latency. Ant Media Server is auto-scalable and it can run on-premise or on-cloud.
https://antmedia.io
Other
4.2k stars 619 forks source link

Issue if using OBS with NVENC H.264 encoder #4643

Open Philosyang opened 1 year ago

Philosyang commented 1 year ago

Issue

Short description

Needs to "refresh" encoder settings after the viewer has joined the WebRTC stream if streaming using OBS with NVENC H.264 encoder in order for the viewer to be able to view the WebRTC stream.

Environment

Steps to reproduce

  1. Use OBS with "NVIDIA NVENC H.264" encoder for streaming settings.
  2. "Tune for ultra-low latency streaming" with the parameters mentioned in https://resources.antmedia.io/docs/open-broadcaster-software-publishing. For NVENC, rate control is set to CBR, keyframe interval is set to 1 second, tuning is set to Ultra Low Latency, max B-frames is set to 0.
  3. Assuming we have set up a stream named abcdef with stream id abcdef on Ant Media Server, and input correct server and key in OBS.
  4. Streamer starts their stream.
  5. Viewer opens the browser and navigate to the abcdef stream.
  6. Viewer fails to see the stream. The stream is loading forever.
  7. Streamer navigates to OBS > Settings > Output > Encoder Settings and change a random item such as +50 Kbps to Bitrate.
  8. Viewer fails to see the stream. The stream is loading forever.
  9. Streamer clicks the "Apply" button to apply the encoder settings.
  10. Viewer is now immediately able to see the stream.

Expected behavior

  1. Streamer starts their stream.
  2. Viewer opens the browser and navigate to the abcdef stream.
  3. Viewer is now immediately able to see the stream.

Actual behavior

  1. Streamer starts their stream.
  2. Viewer opens the browser and navigate to the abcdef stream.
  3. Viewer fails to see the stream. The stream is loading forever.
  4. Streamer navigates to OBS > Settings > Output > Encoder Settings and change a random item such as +50 Kbps to Bitrate.
  5. Viewer fails to see the stream. The stream is loading forever.
  6. Streamer clicks the "Apply" button to apply the encoder settings.
  7. Viewer is now immediately able to see the stream.

Note that this issue only happens with NVENC for me. I have tested CPU encoding and Intel's QuickSync encoding, both worked as expected.

Reproduction GIF: Maybe click on the GIF file for a better view. Animation

Logs

https://gist.github.com/Philosyang/7315e31f565cb0afe30bd18d7700aca9

racile commented 1 year ago

I have had the same issue for a week now every time I change the encoder to NVENC it keeps loading, using the same setting without NVENC it works, I even tried the same settings with NVENC but streamed it to Facebook live or Youtube live and it worked. it seems like NVENC doesn't work with ant media server, or am I missing something, please advise, thank you.

yashtandon113 commented 1 year ago

Hi @Philosyang @racile Thank you for raising the issue and providing such a detailed explanation.

We were also able to reproduce the problem on our end. According to the release logs for OBS v28.1, they made some changes to the NVENC H264 encoder. It is available at https://github.com/obsproject/obs-studio/releases/tag/28.1.0.

This may cause some issues with WebRTC playback. We will investigate this matter and provide an update here.

Meanwhile, as a workaround, you can downgrade your OBS version to v28.0.3, which works fine.

shhhhhh16 commented 1 year ago

Hello, this problem still persist - any update on it?

mekya commented 1 year ago

Thank you for follow up

Unfortunately, there is no update. We could not schedule it due to commitments on our end.

TheLion092 commented 1 year ago

Hello, i also encountered this behavior. Are there new informations about it?

mekya commented 1 year ago

Hi @TheLion092 ,

I've put this to the this week's sprint. I hope we'll have something in a couple of weeks.

TheLion092 commented 1 year ago

@mekya Thank you very much. Just for your information: I encountered the same issue with OBS 28.0.2 too, a few minutes ago. You can still hear the sound but the video stays black.

shhhhhh16 commented 1 year ago

Hello, is there any possibility to increase priority on this? We are still forced to use OBS 27.x.x in order to not have this problem. Any OBS above 27.x has this problem :(

mekya commented 1 year ago

Hi @shhhhhh16,

Thank you for follow up. I see.

The team is very loaded because there is a good demand to the Ant Media Server Enterprise edition. Our priority is focusing on the issues that has no workaround solutions and/or blocking issues coming from enterprise users. Again priority changes according to the number of licenses user is having or similar business metrics.

On the other hand, we're doing our best to schedule the issues as much as possible coming from users here. We scheduled this issue to one of the developer several months ago and he could not fix it. Then senior developer needs to take a look at this issue. This is why it takes time.

If you have any recommendation to us or provide a solution for this issue, please let us know

Cheers Oz

shhhhhh16 commented 9 months ago

In my opinion the issue itself is with the player itself. Recorded videos works properly. Maybe something in between getting the rtmp stream <> web player? OBS 30.x beta has the same issue

TheLion092 commented 9 months ago

I just noticed that the problem only occurs in the enterprise edition.

Enterprise Edition 2.7.0 20231031_0626 -> Problem exists Community Edition 2.7.0 20231031_0625 -> Everything is working as intended

@mekya maybe that can help you fix the problem?

mekya commented 9 months ago

I have not had a chance to test it. I'm just moving it to the next sprint to check if anyone is available to fix the problem

TheLion092 commented 9 months ago

Thank you @mekya. Can we assist you with informations or something else @lastpeony ?

lastpeony commented 9 months ago

I reproduced this issue on my end using AMS 2.7.x. EE Additionally, I found another workaround: selecting the h264 encoder and adding one ABR resolves the problem, allowing the stream to function correctly. However, when the ABR is removed, the issue reappears, and the stream fails to work.

shhhhhh16 commented 9 months ago

@lastpeony thank you, i can confirm that adding ABR workarounds the issue

shhhhhh16 commented 8 months ago

Sadly ABR is increasing CPU usage by a lot so its not very reliable on a bigger scale. Is there any chance increase priority on this issue?

TheLion092 commented 8 months ago

Yes, i have the same opinion and thoughts too. As a workaround, for multiple streams, adding ABR is not feasible due to the high CPU load.

TheLion092 commented 7 months ago

It has now been a year since this issue was first reported, and there is still no fix for it. This is particularly frustrating given the importance of this function. Using OBS with AntMediaServer has become nearly impossible, or at least requires workarounds that come with their own set of drawbacks.

What makes this situation even more sad is that the issue doesn't pertain to the free "Community Edition" but rather to the paid and far from inexpensive "Enterprise Edition."

I have given up on waiting for a fix from the developers. Perhaps the issue is not important enough; who knows?

In the meantime i have discovered another product that allows me to initiate a WebRTC stream with OBS without any problems, and it happens to be open source and free!

I recommend everyone who uses OBS to give the MediaMTX Project a try.

shhhhhh16 commented 7 months ago

@mekya are there any news about this issue? its been over a year already...

mekya commented 6 months ago

Hi @shhhhhh16, You're right. Unfortunately, it seems that I need to fix this issue because it cannot be delegated and I could not have availability to prioritise and fix it.

Btw, We try to find a balance in giving priority of the issues according to enterprise users, community users, support packages, our commitments etc. If you are an enterprise user and want us to give increase priority, please reach out to contact@antmedia.io and let us know.

Thank you for your patience.

Regards Oguz