title: How to set up a continuous stream from Icecast to YouTube Live using FFmpeg?
body: <p>When Icecast servers turns off, FFmpeg trying to reconnect but with only one attempt. Here is error which i get and my script.</p>
  
  <pre><code>[http @ 0x556612e43f80] Stream ends prematurely at 4040716, should be 1844674407370955161597x
  [http @ 0x556612e43f80] Will reconnect at 4040716 error=Input/output error.
  [tcp @ 0x7fe10400b7a0] Connection to tcp://185.195.26.99:8000 failed: Connection refused
  [http @ 0x556612e43f80] Failed to reconnect at 0.
  185.195.26.99:8000/radio: Input/output error1:40.96 bitrate=2878.3kbits/s speed=0.997x
  </code></pre>
  
  <p>After that stream continuing, and YouTube does not break live translation, but it goes empty.</p>
  
  <pre><code>#!/bin/bash
  
  image=../pic/1.jpg #path to image
  source=http://***.**.**.**:8000/radio #radio stream as source
  youtube_url=rtmp://a.rtmp.youtube.com/live2 #rtmp://a.rtmp.youtube.com/live2
  youtube_key=****-****-*****-****
  resolution=1920x1080 #stream resolution
  
  ###########################################################
  
  stream=FFREPORT=file=../log/stream-%t.log:level=32 ffmpeg \
          -thread_queue_size 1024 \
          -reconnect 1 -reconnect_at_eof 1 -reconnect_streamed 1 -reconnect_delay_max 3600 -i $source \
          -re -loop 1 -i $image \
          -acodec aac -b:a 128k -ar 44100 -strict experimental \
          -vcodec libx264 -preset ultrafast -tune stillimage -r 30 -g 60 -b:v 4500k -minrate 4000k -maxrate 4500k -bufsize 6000k \
          -s $resolution \
          -f flv \
          $youtube_url/$youtube_key\
  
  until $stream ; do
          echo "Restarting stream ..."
          sleep 2
  done
  </code></pre>