title: FFmpeg stream encryption
body: <p>I am doing a project where a stream has to be transmitted in real time and in a secure manner to a server.</p>
  <p>As it can be found in the documentation it is possible to ''encrypt'' a stream using:</p>
  <ol>
  <li><p>srtp <a href="https://www.ffmpeg.org/ffmpeg-protocols.html#srtp" rel="nofollow noreferrer">https://www.ffmpeg.org/ffmpeg-protocols.html#srtp</a></p>
  <p>This works fine but the speed and quality aren't that good. (delay of 3 seconds). I would be grateful for improvements (see below)</p>
  </li>
  <li><p>tls using certificates (<a href="https://www.ffmpeg.org/ffmpeg-protocols.html#tls" rel="nofollow noreferrer">https://www.ffmpeg.org/ffmpeg-protocols.html#tls</a>)</p>
  <p>What exactly does tls? Does it even encrypt or is it just to verify that the stream comes from the correct source?</p>
  </li>
  </ol>
  <p>What else can i use to achieve adequate quality and speed?</p>
  <hr />
  <p>PS: The command for SRTP with AES with 3 second delay:</p>
  <pre><code>ffmpeg -r 24 -f x11grab -s 1280x1024 -i :0.0 -c:v libx264 -crf 35 -pix_fmt yuv420p -threads 4 -preset fast -tune fastdecode -bsf:v h264_mp4toannexb -movflags +faststart -f rtp_mpegts -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz &quot;srtp://10.0.0.100:8888&quot;
  </code></pre>
  <p>I output it with ffplay:</p>
  <pre><code>ffplay -srtp_in_suite AES_CM_128_HMAC_SHA1_80 -srtp_in_params zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz srtp://client:8888 -fast -fs
  </code></pre>