Search code examples
opencvgstreamervlcrtsprtp

OpenCv + Gstreamer from an app, getting initial 30s delay


So my application is exposing an RTP stream using new VideoWriter(pipeline-definition);

The pipeline definition is:

appsrc is-live=1 do-timestamp=1 format=3 stream-type=0 min-latency=0 max-latency=500000000 ! queue leaky=2 max-size-time=500000000 ! videoconvert ! video/x-raw ! x264enc ! h264parse ! rtph264pay config-interval=10 pt=96 ! udpsink host=127.0.0.1 port=9000

The problem I'm faced with is 30s delay in the stream when viewing it in VLC. No matter what I do, VLC is always 29-30s behind. It seems that appsrc is causing this as the same pipeline with videotestsrc has no delay at all.

Any ideas what should I do to make the appsrc release the frames to the stream right away?


Solution

  • Seems like the VideoWriter has an internal buffer that caches 30s of footage. In my case I was keeping a singleton in memory and relied on it flushing to the pipeline fast enough. In reality I ended up having to force the VideoWriter to flush the data by releasing it.

    I don't recommend this as a solution to the problem but in my case it worked as I need this pipeline only when DEBUG is defined.