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.43k stars 5.35k forks source link

Quality of video over webRTC with SRS compared to OvenMediaEngine (GPU enabled) #4066

Closed antonymarion closed 4 months ago

antonymarion commented 4 months ago

Hi,

I tested the same stream sent to a rtmp server using ffmpeg.

And played it with SRS vs OvenMediaEngine (using GPU Harwdware Acceleration).

Depenging on the video (codec) I can notice some obvious difference regarding the quality of the stream once read in a Web Player (webRtc).

SRS: image OvenMediaEngine image

Could you confirm me that is due to enable GPU acceleration ?

If not what is the root cause please, and can we expect this to be fixed in the future?

Thks

suzp1984 commented 4 months ago

Could you gives the video source to test? and the steps to reproduce this issue?

antonymarion commented 4 months ago

sure

https://github.com/ossrs/srs/assets/8767496/57ac493e-eadf-4960-8f03-65642e3f2d96

then

fmpeg -d -stream_loop -1 -re -i ./forest.mp4 -c copy -f flv -y rtmp:/{your_ip}/live/test </dev/null

suzp1984 commented 4 months ago

ffprobe -show_frames forest.mp4 | grep -i 'pict_type'

There are B frames in this video, while webrtc don't support B frame, which will be drop by default at SRS. That's the reason of bad quality.

How to workaround

ffmpeg -d -stream_loop -1 -re -i ./forest.mp4 -vcodec h264 -profile:v baseline -f flv -y rtmp:/{your_ip}/live/test </dev/null or ffmpeg -d -stream_loop -1 -re -i ./forest.mp4 -vcodec h264 -profile:v high -bf 0 -f flv -y rtmp:/{your_ip}/live/test </dev/null

Both of above publish cmd will resolve your problem.

About the GPU Acceleration question

No, SRS will not do any decode or encode, but just demux the video format, get the nalu elements inside the video frames, for the RTMP which is flv tags, then remux the nalu to the RTP packet. In short, the most common job of a live stream server is just do video format demux -> remux, or just re-streaming.

For the OvenMediaEngine, I didn't read it's source code yet, but he process video stream in this way: demux -> decode -> encode -> remux. Which means he did video decode->encode which is cpu | gpu intense job, and this kinds of server will be quite different than general live media server.

antonymarion commented 4 months ago

Well thks for the clarification.

That was not really intensive on a RTX Titan GPU though (around 1% usage if I remember well..)

I will go back to SRS if I see that OvenMediaEngine is consuming too much resources (not the case right now 😉)