strukturag / libde265

Open h.265 video codec implementation.
Other
1.72k stars 459 forks source link

Total image distortion even on 1% packet loss #423

Open svpcom opened 1 year ago

svpcom commented 1 year ago

Hi, I use rtp as h265 transport and found that even with 1% of packets loss image became totally distorted (static background became gray and only moving parts are shown). It seems that libde265 has a bug because if I use NVidia HW decoder nvh265dec it decode that same stream without any visible artifacts. The same bug also have libav.

How to reproduce:

  1. Use gstreamer:
    gst-launch-1.0 videotestsrc is-live=true do-timestamp=true ! 'video/x-raw,width=640,height=480,framerate=30/1,format=I420' ! x265enc tune=zerolatency bitrate=2000 ! rtph265pay mtu=1400 aggregate-mode=zero-latency  ! identity drop-probability=0.01 ! queue ! rtph265depay ! h265parse ! libde265dec ! videoconvert ! xvimagesink sync=false
  2. Use libde265-dec265
    /usr/bin/libde265-dec265 -d /tmp/test.h265

If I replace in gstreamer pipeline above libde265dec with nvh265dec all will work without problems

Test data: h265_0.01_loss.mkv.gz test.h265.gz

SW versions: GStreamer: 1.22.0 libde265: 1.0.11-1 OS: Debian 12, amd64

farindk commented 1 year ago

That is not a bug. Even a small packet loss can corrupt many frames because they depend on each other. It is not specified what to do in the case of missing input data. As far as I remember, libde265 simply uses empty content (grey) for the missing image parts. Alternatively, one can use some error concealment algorithms to hide the errors. Apparently, the NVidia HW decoder uses one of them.

We can leave this open as a feature request for implementing an error concealment algorithm.

svpcom commented 1 year ago

@farindk Is it possible to use previous base frame instead of grey color filling?

farindk commented 1 year ago

Something like this. But frames are not always coded in temporal order and several frames could be decoded in parallel threads, what makes this more difficult. But yes, that would be a rather simple algorithm that should improve this.

farindk commented 1 year ago

BTW: I looked at your test stream. How does the input look like? I guess that it is a static test image with noise in the bottom right rectangle. Right?

svpcom commented 1 year ago

@farindk Yes. It is output of gstreamer videotestsrc. Also interesting that libav h264 decoder doesn't have such bug (see attached file) h264_0.01_loss.mkv.gz

svpcom commented 1 year ago

@farindk Is it possible to add quick fix for this problem or it requires a deep investigation?

CarlAreDHopen-eaton commented 7 months ago

Are there any progress on this issue? We are facing the exact same issue with intermittent packet loss in keyframes causing gray screen until the next key frame.