title: Keep FFMPEG encoding session running
body: <p>I am trying to encode an external HLS (m3u8) link into MPEG-TS over UDP via ffmpeg with this command:</p>
  
  <pre><code>ffmpeg -re -i http://example.com/index400.m3u8 -vcodec copy -acodec copy -f mpegts udp://127.0.0.1:10000?pkt_size=1316
  </code></pre>
  
  <p>Currently I am executing the command directly inside a terminal which I keep open on my Centos server. However, and after some time (volatile), I get the following error : </p>
  
  <blockquote>
    <p>Failed to resolve hostname example.com: Temporary failure in name resolution<br>
    [hls,applehttp @ 0x349b420] Failed to reload playlist 0</p>
  </blockquote>
  
  <p>My question is, how can I run this command in a bash script or upstart or … so that whenever it unexpectedly stops, it automatically restarts.
  I prefer not to use third parties like monit, and please be explicit in writing the script with annotation for newbies, I am not well experienced on this.</p>