title: FFmpeg: Live streaming using RSTP C++
body: <p>I want to receive video stream from camera, process it using openCV (for tests - draw red rectangle) and live stream result.</p>
  
  <p>I already can read camera frames, convert to openCV Mat and change them back to AVFrame.</p>
  
  <p>From console im starting rtsp server using: ffplay -rtsp_flags listen -i rtsp://127.0.0.1:8765/live.sdp
  Problem shows when im trying call avio_open();</p>
  
  <pre><code>av_register_all();
  avformat_network_init();
  avcodec_register_all();
  (...)
  avformat_alloc_output_context2(&amp;outputContext, NULL, "rtsp", outputPath.c_str());
  outputFormat = outputContext-&gt;oformat;
  
  cout &lt;&lt; "Codec = " &lt;&lt; avcodec_get_name(outputFormat-&gt;video_codec) &lt;&lt; endl;
  
  if (outputFormat-&gt;video_codec != AV_CODEC_ID_NONE) {
      videoStream = add_stream(outputContext, &amp;outputVideoCodec, outputFormat-&gt;video_codec);
  }
  char errorBuff[80];
  int k = avio_open(&amp;outputContext-&gt;pb, outputPath.c_str(), AVIO_FLAG_WRITE);
  if (k &lt; 0) {
      cout &lt;&lt; "code: " &lt;&lt; k &lt;&lt; endl;
      fprintf(stderr, "%s \n", av_make_error_string(errorBuff, 80, k));
  }
  
  if (avformat_write_header(outputContext, NULL) &lt; 0) {
      fprintf(stderr, "Error occurred when writing header");
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Where outputPath = "rtsp://127.0.0.1:8765/live.sdp"
  avformat_alloc_output_context2 returns 0, but avio_open &lt; 0 so app prints:</p>
  
  <p>code: -1330794744</p>
  
  <p>Protocol not found</p>
  
  <p>I have no idea what is wrong. I am using ffmpeg build from <a href="https://ffmpeg.zeranoe.com/builds/" rel="nofollow">https://ffmpeg.zeranoe.com/builds/</a> 64-bit Dev </p>