bluenviron / mediamtx

Ready-to-use SRT / WebRTC / RTSP / RTMP / LL-HLS media server and media proxy that allows to read, publish, proxy, record and playback video and audio streams.
MIT License
11.41k stars 1.45k forks source link

H.265 HLS Error: DTS is not monotonically increasing #1431

Closed Patton-L closed 1 year ago

Patton-L commented 1 year ago

Which version are you using?

v0.21.6

Which operating system are you using?

Describe the issue

When using NVENC HEVC in OBS, both LL-HLS and fmp4 variant of hls streams stop after about 10 seconds of successful playing. Log showing destroyed (muxer error: unable to extract DTS: DTS is not monotonically increasing, was 13.934s, now is 13.933666667s)

Tested opening the H.265 stream using RTSP with VLC and it works well. NVENC H.264 stream works well under both LL-HLS and fmp4 variant of hls streams.

Describe how to replicate the issue

  1. Use either fmp4 or lowLatency as hlsVariant.
  2. Use OBS to start the stream with NVENC HEVC.
  3. use browser to open the HLS stream
  4. the stream will stop after a few seconds and error will be in the log

Did you attach the server logs?

yes

Jan 29 05:36:19 rtsp-simple-server[4345]: 2023/01/29 05:36:19 INF [RTMPS] listener opened on 0.0.0.0:x
Jan 29 05:36:19 rtsp-simple-server[4345]: 2023/01/29 05:36:19 INF [HLS] listener opened on :x
Jan 29 05:36:19 rtsp-simple-server[4345]: 2023/01/29 05:36:19 INF [WebRTC] listener opened on :x(HTTP), :x(ICE/UDP)
Jan 29 05:37:17 rtsp-simple-server[4345]: 2023/01/29 05:37:17 INF [RTMP] [conn x.x.x.x:x] opened
Jan 29 05:37:18 rtsp-simple-server[4345]: 2023/01/29 05:37:18 INF [RTMP] [conn x.x.x.x:x] is publishing to path '_path_', 2 tracks (H265, MPEG4-audio)
Jan 29 05:37:29 rtsp-simple-server[4345]: 2023/01/29 05:37:29 INF [HLS] [muxer _path_] created (requested by x.x.x.x)
Jan 29 05:37:29 rtsp-simple-server[4345]: 2023/01/29 05:37:29 INF [HLS] [muxer _path_] is converting into HLS, 2 tracks (H265, MPEG4-audio)
Jan 29 05:37:43 rtsp-simple-server[4345]: 2023/01/29 05:37:43 INF [HLS] [muxer _path_] destroyed (muxer error: unable to extract DTS: DTS is not monotonically increasing, was 13.934s, now is 13.933666667s)
Jan 29 05:37:45 rtsp-simple-server[4345]: 2023/01/29 05:37:45 INF [HLS] [muxer _path_] created (requested by x.x.x.x)
Jan 29 05:37:45 rtsp-simple-server[4345]: 2023/01/29 05:37:45 INF [HLS] [muxer _path_] is converting into HLS, 2 tracks (H265, MPEG4-audio)

Did you attach a network dump?

no

aler9 commented 1 year ago

Hello, i tried to replicate the issue but i was not able to. In my case, the HLS muxer worked flawlessly. These are my OBS Studio settings:

Capture

GPU is Nvidia Quadro P620.

Patton-L commented 1 year ago

Hi, Thanks for testing on this issue!

I tried to put my OBS config exactly the same as in your screenshot, and still getting the same error; This might be a issue only happening to my pc then. I can still try to provide you with some more information if that helps.

My OBS (29.0.2) is on windows with latest Nvidia studio driver 528.49

Log, under 30fps, 1080p:

INF [HLS] [muxer _path_] destroyed (muxer error: unable to extract DTS: DTS is not monotonically increasing, was 16.867s, now is 16.866333334s)
INF [HLS] [muxer _path_] created (requested by x.x.x.x)
INF [HLS] [muxer _path_] is converting into HLS, 2 tracks (H265, MPEG4-audio)
INF [HLS] [muxer _path_] destroyed (muxer error: unable to extract DTS: DTS is not monotonically increasing, was 15.834s, now is 15.833333334s)
INF [HLS] [muxer _path_] created (requested by x.x.x.x)
INF [HLS] [muxer _path_] is converting into HLS, 2 tracks (H265, MPEG4-audio)
INF [HLS] [muxer _path_] destroyed (muxer error: unable to extract DTS: DTS is not monotonically increasing, was 22.867s, now is 22.866333334s)
INF [HLS] [muxer _path_] created (requested by x.x.x.x)
INF [HLS] [muxer _path_] is converting into HLS, 2 tracks (H265, MPEG4-audio)
INF [HLS] [muxer _path_] destroyed (muxer error: unable to extract DTS: DTS is not monotonically increasing, was 16.867s, now is 16.866333334s)

One thing I do notice is that if I change the framerate in OBS from 30 to 24 NTSC, it will fail for a minute and start to work for more than a minute instead of ~10 seconds. This different behavior is replicable for me.

Log for 24 fps:

INF [HLS] [muxer _path_] created (requested by x.x.x.x)
INF [HLS] [muxer _path_] is converting into HLS, 2 tracks (H265, MPEG4-audio)
INF [HLS] [muxer _path_] destroyed (muxer error: unable to extract DTS: DTS is not monotonically increasing, was 19.854s, now is 19.853583334s)
INF [HLS] [muxer _path_] created (requested by x.x.x.x)
INF [HLS] [muxer _path_] is converting into HLS, 2 tracks (H265, MPEG4-audio)
INF [HLS] [muxer _path_] destroyed (muxer error: unable to extract DTS: DTS is not monotonically increasing, was 16.725s, now is 16.724583334s)
INF [HLS] [muxer _path_] created (requested by x.x.x.x)
INF [HLS] [muxer _path_] is converting into HLS, 2 tracks (H265, MPEG4-audio)
-- start to play for a minute--
INF [HLS] [muxer _path_] destroyed (muxer error: unable to extract DTS: DTS is not monotonically increasing, was 1m42.812s, now is 1m42.811583334s)

another try for 24 fps:

INF [HLS] [muxer _path_] destroyed (muxer error: unable to extract DTS: DTS is not monotonically increasing, was 1m42.978s, now is 1m42.977583334s)
Patton-L commented 1 year ago

Hi, Just notice if I set max b frames to 0 the issue will be gone; Seems to be a bug from ffmpeg itself. https://github.com/obsproject/obs-studio/pull/8582

github-actions[bot] commented 9 months ago

This issue is being locked automatically because it has been closed for more than 6 months. Please open a new issue in case you encounter a similar problem.