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

SRT ingest fails when using OBS Studio with encoder (NVDIA NVENC H.264) #3172

Closed GeekenDev closed 2 years ago

GeekenDev commented 2 years ago

Description

SRS fails to handle SRT connection when stream originates from OBS Studio and the encoder is set to NVDIA NVENC H.264. Regular x264 encoder in OBS works fine. This did not become an issue until ~ OBS Studio 27.2.1

  1. SRS Version: 4.0.261(Leo)

  2. SRS Log:

[2022-09-06 16:33:28.797][Error][23765][d1u11054][11] send media data error:code=3043 : write frame : drop sps/pps
thread [23765][d1u11054]: on_ts_video() [./src/srt/srt_to_rtmp.cpp:581][errno=11]
thread [23765][d1u11054]: write_h264_ipb_frame() [./src/srt/srt_to_rtmp.cpp:403][errno=11](Resource temporarily unavailable)
[2022-09-06 16:33:28.797][Error][23765][d1u11054][11] send media data error:code=3041 : demux annexb : annexb start code
thread [23765][d1u11054]: on_ts_video() [./src/srt/srt_to_rtmp.cpp:517][errno=11]
thread [23765][d1u11054]: annexb_demux() [src/protocol/srs_raw_avc.cpp:39][errno=11](Resource temporarily unavailable)
  1. SRS Config:
Default SRT config

TRANS_BY_GPT3

pkviet commented 2 years ago

obs-studio dev here; i wrote the srt support. i can confirm the issue which occurs with your transmuxer to rtmp. We don't observe such an issue with competing servers like Wowza or Nimble Server.

pkviet commented 2 years ago

Pinpointed the issue: in obs-studio, the nvenc encoder is set to have AUD (access unit delimiter), see : here It seems the srt_to_rtmp.cpp transmuxer doesn't know how to deal with them. It is true that per spec it is not mandatory to have NALU AUDs in h264. But in mpegts container it is mandatory. So your transmuxer must be able to parse them correctly. Currently your code for dealing with AUD is: https://github.com/ossrs/srs/blob/4.0release/trunk/src/srt/srt_to_rtmp.cpp#L525-L529 I'm not sure why these lines of code to ignore the AUD don't work though. Why not write them into the video instead of ignoring them ? What's very odd though is that x264 also is set to have AUD but the srt mpegts is transmuxed fine.

xiaozhihong commented 2 years ago

https://github.com/ossrs/srs/blob/4.0release/trunk/src/srt/srt_to_rtmp.cpp#L525-L529

Yes, you are right, we must not ignore AUD in the h264 stream. We will fix it later. Had you test remove the code https://github.com/ossrs/srs/blob/4.0release/trunk/src/srt/srt_to_rtmp.cpp#L525-L529, and can ingest SRT success?