title: Low-latency video streaming from c++ opencv application in WINDOWS
body: <p>There are quite a lot of questions on the topic, but most of them involve the use of undesired protocols - HTML5, WebRTC, etc.</p>
  
  <p>Basically, the problem can formulated as follows: how do I stream my own cv::Mat images over either RTSP or MJPEG [AFAIK it is better for realtime streaming] streams in <strong>Windows</strong>? Nearly everything I can find relies on the OS being Linux, and is just not applicable to the project.</p>
  
  <p>FFMPEG's pipelining sort of worked, but the delay was about 10 seconds. Could take it down to 3-4 seconds using some -incomprehensibly-long-parameter-list-that-ffmpeg-team-loves-so-much, but it is not enough, because the project under consideration is a surveillance app with active user controlling the camera, so I need to be as close to realtime as possible.</p>
  
  <p>Another issue is that the solution should not eat the whole amount of cores, because they are already overloaded with object tracking algorithms.</p>
  
  <p>Thanks for help in advance!</p>
  
  <p><strong>EDIT</strong>: 
  <code>ffmpeg -re -an -f mjpeg -i http://..addr.../video.mjpg -vcodec libx264 -tune zerolatency -f rtp rtp://127.0.0.1:1234 -sdp_file stream.sdp</code> - command I used to retranslate the stream directly without any preprocessing, and it yielded about 4 seconds of delay <strong>on a localhost</strong>.</p>