-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"DTS is not monotonically increasing" error with SRT playback and Intel QSV HEVC encoder #3285
Comments
After some more digging, it seems that the problem is with SPS data reading instead of DTS extraction. When publishing a stream encoded using QSV HEVC encoder, VUI is somehow not correctly read ( I can confirm that VUI data is present on both x265 and QSV HEVC streams, with the only difference being GPB is probably related to the problem, but I'm not sure why it could lead to SPS not being correctly read. |
Hello, thanks for the detailed analysis, i can confirm that the SPS parser has some troubles reading the SPS of QSV, in particular there's a missing algorithm, that is documented in ITU-T H265:
i'm working to implement it. |
The fix is ready (bluenviron/mediacommon#128), please test this nightly release and let me know if the error is gone (click on "Artifacts", "Binaries"): https://github.com/bluenviron/mediamtx/actions/runs/9132458367 |
The error is gone using the nightly release. Thanks very much for the fix. |
* replace DeltaPocS0Minus1 with DeltaPocS0 * make DeltaPocS0 a int32 * fix computation of DeltaPocS0 when InterRefPicSetPredictionFlag is false * fix SPS parsing of QSV HEVC * fix DTS extraction of QSV HEVC streams * add additional fuzzing
This issue is being locked automatically because it has been closed for more than 6 months. |
Which version are you using?
v1.4.2
The replication steps can also replicate the issue on v1.8.0, but I haven't done more tests on v1.8.0 yet.
Which operating system are you using?
Describe the issue
(I first thought the problem has something to do with #1002 but now find that the two issues are likely irrelevant.)
When streaming an Intel QSV HEVC encoded video to MediaMTX, SRT playback won't work at all, playback fails without any frame being displayed, with MediaMTX complaining "DTS is not monotonically increasing, was (some number)s, now is (some number)s" and the first number being 0.05 to 0.5 larger than the second one.
It only happens with QSV HEVC. libx265, QSV AVC(H.264) and AMD's AMF HEVC all work properly without issues.
I can confirm that packet DTS is indeed monotonically increasing in the video clip using ffprobe, and the same video clip plays fine locally as well as when streamed over some other SRT streaming servers. So it's unlikely a problem with the encoder itself.
Only SRT playback is affected:
RTSP publish, SRT read -> error
RTSP publish, RTSP read -> OK
SRT publish, SRT read -> error
SRT publish, RTSP read -> OK
I suspect it's something with B frames, but I have no idea how this could lead to a DTS-related error.
Intel's QSV HEVC encoder on DG2 (Arc A380 in my case) has GPB (Generalized P and B pictures) enabled by default, so every non-intra frame looks like a B frame, at least in FFmpeg. And with FFmpeg setting the default GOP size to 248, video streams look like long series of B frames (a few hundreds of them) with single I frames in between.
A workaround is to disable GPB (
-gpb 0
) and set GOP size to extremely small values(e.g.-g 5
, 10 or more won't solve the problem) when encoding using FFmpeg, which introduces P frames back and cuts down the length of concurrent B frames to single digits, at the cost of making the quality terrible (almost 4x bitrate for the same quality).Describe how to replicate the issue
ffmpeg -re -i /path/to/video.mkv -an -c:v hevc_qsv -f mpegts "srt://example.com:8890/?streamid=publish:stream"
).Media
->Open Network Stream
-> entersrt://example.com:8890/?streamid=read:stream
->Play
).An example of not working sample (encoded using QSV) and a working sample (encoded using x265) could be found here, if these samples are used,
-c:v hevc_qsv
can be replaced with-c:v copy
in the above command line example so that there's no need for an Intel GPU.Did you attach the server logs?
Yes, but there's probably not much information.
logLevel
is set todebug
Did you attach a network dump?
No, it's unlikely to be a network-related problem, and happens on localhost as well.
The text was updated successfully, but these errors were encountered: