After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 796334 - avdec_h264 looses reference frames after lost packages
avdec_h264 looses reference frames after lost packages
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-libav
1.14.1
Other Linux
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2018-05-22 13:52 UTC by Michael Olbrich
Modified: 2018-08-29 07:23 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Michael Olbrich 2018-05-22 13:52:21 UTC
Since the update to ffmpeg n3.4.1 (1.12.0-39-g829b269e1ef3) avdec_h264 handles packet loss badly.

This pipeline shows this nicely:
gst-launch-1.0 videotestsrc pattern=ball ! x264enc key-int-max=60 ! \
  rtph264pay ! identity drop-probability=0.01 ! queue ! rtph264depay ! \
  avdec_h264 ! autovideosink

With gst-libav before the mentioned commit, it looks like the last decoded frame is uses as a reference frame. This results in minor artifacts but the video is still recognizable. 
After this commit an empty frame is a reference frame. As a result the video is a grey mess until the next I-Frame.

I tracked this down to two relevant commits in ffmpeg:
061a0c14bb57 decode: restructure the core decoding code
d8d1689f929c avcodec/decode: reset codec on receiving packet after EOF in compat_decode

With the first one and without the second one playback is completely broken. If I back-port the second commit onto the first one, then I get the error described above. All commits before the first one are good.

The commit message of the second commit looks suspicious:
[...]
To restore some compatibility, reset the codec if we receive a new non-drain
packet using the old API after draining has completed. While this does
not give the same behaviour as the old API did, in the majority of cases
it works and it does not require changes to any other part of the decoding
code.
[...]
Maybe we need to switch to the new API?
Comment 1 Sebastian Dröge (slomo) 2018-08-28 15:49:40 UTC
(In reply to Michael Olbrich from comment #0)

> Maybe we need to switch to the new API?

Which new API? avcodec_send_packet(), avcodec_receive_frame(), etc? Those are used in GIT master now, together with ffmpeg 4.0
Comment 2 Michael Olbrich 2018-08-29 07:23:02 UTC
The old API was used when I opened this bug. I expect that this problem is solved with the latest changes in git master (from Bug 792900).

I cannot test this right now, but if there are still problems, then it's a different issue.