OPENCV push stream into RTSP server

Not tried, but you may try:

  • replace nvv4l2h264enc by omxh264enc as it seems better. I had shortly experimented with UDP streaming and found that default profile used by nvv4l2h264enc was higher than omxh264enc in my case, and even setting the fastest preset, it was loosing sync through UDP while omxh264enc was keeping it (maybe I missed some options).
  • add h264parse after h264 encoder
  • add rtph264pay config-interval=1 between h264parse and rstpclientsink.
  • add queue after appsrc.

If it works, feel free to try removing any useless part.

Also note, if upgrading your opencv version/build that VideoWriter API in python may have changed (with second argument being now the used API, such as cv2.CAP_GSTREAMER or cv2.CAP_ANY), but it doesn’t seem to be your case since you have a working case.