srs icon indicating copy to clipboard operation
srs copied to clipboard

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

Open GeekenDev opened this issue 3 years ago • 3 comments

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

GeekenDev avatar Sep 06 '22 21:09 GeekenDev

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 avatar Sep 07 '22 10:09 pkviet

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.

pkviet avatar Sep 09 '22 16:09 pkviet

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?

xiaozhihong avatar Sep 15 '22 13:09 xiaozhihong