title: ffmpeg - continuous file streaming over RTMP
body: <p>I've been looking around for a simple (or perhaps not-so-simple) walkaround for a problem I am having in my set up for a simple test case: video streaming over red5 media server.</p>
  
  <p>I have built a small-ish library of FLV files scraped from YouTube and managed to play them in succession with the following perl script:</p>
  
  <pre><code>use Cwd;
  use strict;
  use warnings;
  use DBI;
  use DBD::mysql;
  
  our $db = DBI-&gt;connect();
  my $dst = "/home/seb/youtube/";
  sub streamFile {
      my $r = $db-&gt;prepare("SELECT name FROM music_flvs ORDER BY RAND() LIMIT 1");
      $r-&gt;execute();
      my @data = $r-&gt;fetchrow_array();
      my $filename = $data[0]
      my $t = `ffmpeg -re -i '${dst}${filename}' -ab 48k -ac 1 -vcodec libx264 -crf 30 -s "640x480" -acodec libfaac -ar 44100 -threads 4 -f flv 'rtmp://server/oflaDemo/music'`;
      return 1;
  }
  while (&amp;streamFile()) {
  }
  </code></pre>
  
  <p>This script does its purpose extremely well: it plays files one by one through <code>ffmpeg</code>. However, it does so with a crucial problem: it causes an <strong>Unpublish</strong> event every time it swaps songs, which causes all the clients to disconnect. I would like to prevent this. The event manifests itself in ActionScript as this:</p>
  
  <pre><code> 16:33:54:209 - Playback - NetStream.Play.UnpublishNotify
   16:33:54:209 - Playback - NetStream.Play.PublishNotify
  </code></pre>
  
  <p>I have seen the <code>concat</code> demuxer and believe that it might somewhat help me. The question is pretty simple: what is the best way to make ffmpeg stream a playlist to a RTMP server without ever causing an Unpublish event?</p>