title: FFMPEG: Youtube streaming quality and speed issues
body: <p>I am trying to make a reliable stream from my Icecast/Shoutcast servers to Youtube live. The command that I use is:</p>
  
  <pre><code>ffmpeg -v verbose -framerate 30 -loop 1 -i /var/image.jpg -re -i http://127.0.0.1:4700/radio -c:v libx264 -preset ultrafast -b:v 2250k -maxrate 6000k -bufsize 6000k -c:a copy -ab 128k -s 1920x1080 -framerate 30 -g 60 -keyint_min 60 -f flv  rtmp://a.rtmp.youtube.com/live2/xxx
  </code></pre>
  
  <p>As you can see I am using recommended bitrate for Youtube, insert keyframes every 2 seconds and streaming at 30 frames per second.
  The stream is working but after running for some time two thing are happening:</p>
  
  <ol>
  <li>FFMPEG <code>speed</code> falls from 1x to something like <code>0.998x</code></li>
  <li>Youtube starts complaining that video stream speed is slow, markes the quality as bad and sometimes video starts buffering.</li>
  </ol>
  
  <p>Why is this happening? CPU load is normal, connectivity is ok (the stream is running on a 1Gg/s dedicated server).</p>
  
  <p>Since in my example above I am streaming a single image as a logo of the stream I also tried to generate a short 30 seconds video with that image and broadcast that video instead of an image, but that did not help as well.</p>
  
  <p>The command I used for conversion:</p>
  
  <pre><code>ffmpeg -framerate 30 -loop 1 -i /var/image.jpg -c:v libx264 -preset ultrafast -tune stillimage  -b:v 2250k -minrate 2250k -maxrate 6000k -bufsize 6000k -framerate 30 -g 60 -keyint_min 60 -t 30 out4.mp4
  </code></pre>
  
  <p>And broadcast with</p>
  
  <pre><code>ffmpeg -stream_loop -1 -i out4.mp4  -re -i http://127.0.0.1:4700/radio -c:v copy -c:a copy  -framerate 30 -g 60 -keyint_min 60 -f flv  rtmp://a.rtmp.youtube.com/live2/xxx
  </code></pre>
  
  <p>ffmpeg version is <code>4.1.1</code></p>