title: Stream video using cloudfront and ffmpeg only
body: <p>I'm new to web streaming and was doing some experiments. I was wondering if it is possible stream video using ffmpeg and AWS Cloudfront. I've following things in place:</p>
  
  <pre><code>1. Cloudfront http and rtmp instance
  2. Ubuntu as OS
  3. A foscam ip camera at http://xxx.xxxx.net:9002 which can be accessed using url http://xxx.xxxx.net:9002/videostream.cgi?user=xxxx&amp;password=xxxx
  4. jwplayer
  </code></pre>
  
  <p>I used following using ffmpeg to stream data using cloudfront:</p>
  
  <pre><code>ffmpeg -f mjpeg -i 'http://xxx.xxx.net:9002/videostream.cgi?user=xxx&amp;pwd=xxxx'  -vcodec libx264 -crf 20 -preset veryfast -minrate 150k -maxrate 500k -s 960x540 -acodec libfaac -ar 44100 -ab 96000 -threads 0 -f flv - | tee name.flv | ffmpeg -i - -codec copy -f flv -metadata streamName=livestream rtmp://xxxxx.cloudfront.net/
  </code></pre>
  
  <p>To test the ffmpeg command above, I setup a crtmpserver on local machine and replaced rtmp://xxxxx.cloudfront.net/ with tcp://0.0.0.0:6666. This worked fine and I could view the live stream on jwplayer once I specified the crtmpserver url for jwplayer.</p>
  
  <p>So, if it is possible, I need to do the following in descending order of preference:</p>
  
  <pre><code>1. Stream video directly to cloudfront and access it using jwplayer using ffmpeg.
  2. Save video to S3 bucket using ffmpeg.
  </code></pre>
  
  <p>From documentations, streaming can be done using Adobe media server, Wowza etc. I was just wondering if this can be achieved using ffmpeg and cloudfront only.</p>