nvcodec: Segment seeking without FLUSH flag leads to immediate SEGMENT_DONE and memory leak
I have a script that streams video from a file and decodes it, dumping the resulting frames into a fakesink
.
I want the video to seamlessly loop, so I send a segment seek event to the pipeline once it hits the PLAYING
state and send another segment seek event whenever the SEGMENT_DONE
message received by my bus watch. This script works fine using avdec_h264
and vaapih264dec
.
When running the script with nvh264dec
, I see different behavior. When I send a seek event after the SEGMENT_DONE
message, the pipeline immediately responds with another SEGMENT_DONE
message. If I keep sending seek events in response, this causes a memory leak.
I found that adding the FLUSH
seek flag to my seek event solves this problem, but this isn't necessary with other decoders. Especially considering the memory leak, this feels like a bug.
I've been able to reproduce this on multiple MP4/H.264 video files, but have not tested it on other container or encoding formats. I'd be happy to send an example video if it helps.
I have a reproducible example in Python available as a Gist here, alongside the Dockerfile I reproduced this problem with in case that's helpful.
CC @seungha.yang who appears to be the resident expert. Thank you for taking a look!
Versions I've tested:
- GStreamer: 1.18.4 and 1.19.1
- Python: 3.6
- PyGObject: 3.40.1
- Cuda: 10.0 and 11.2
- OS: Ubuntu 18.04 via Docker