title: ffmpeg - switch rtmp streams into a single encoded output?
body: <p>I have <code>1-5</code> input streams, each uploading on a slightly different time offset. </p>
  
  <p>With rtmp and ffmpeg, I can reliably encode a single stream into an HLS playlist that plays seamlessly on iOS, my target delivery platform.</p>
  
  <p>I know that you can accept multiple input streams into ffmpeg, and I want to switch between the input streams to create a consistent, single, seamless output. </p>
  
  <p>So I want to switch between 
  <code>rtmp://localhost/live/stream1</code> .. <code>rtmp://localhost/live/stream5</code> on a regular interval. Sometimes there will be multiple streams, and sometimes there won't.</p>
  
  <p>Is there any way for ffmpeg to rotate between input streams while generating an HLS playlist? My goal is to avoid running duplicate instances of ffmpeg for server cost reasons, and I think connecting disparately encoded input streams for playback would be difficult if not impossible.</p>
  
  <p>Switching on each segment is the ideal behavior, but I also need to keep the streams in time sync. Is this possible?</p>