Pages

Friday, 17 October 2014

Wowza Server Setup with Ubuntu and Also Integration In Rails

Wowza + Flowplayer + Video Upload + Rails + Video Streaming + Stop video after some time + java setup on ubuntu

1. First set up java on ubuntu (should be 64 bit system) :- in browser

$ sudo sh -c 'echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" >> /etc/apt/sources.list'
$ sudo sh -c 'echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" >> /etc/apt/sources.list'
$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886
$ sudo apt-get update
$ sudo apt-get install oracle-java8-installer


2. Install wowza using (should have account on wowza) :- in browser
http://www.wowza.com/pricing/installer

Copy the secret key of wowza

3. Let it download in directory /home/garg/Downloads/ :- in terminal
cd /home/garg/Downloads/

4. Install wowza
sudo chmod +x WowzaStreamingEngine-4.0.4.deb.bin
sudo ./WowzaStreamingEngine-4.0.4.deb.bin

5. start wowza service :- in terminal
sudo service WowzaStreamingEngine start
// sudo service WowzaStreamingEngine stop

6. On you machine, check wowza is running :- in browser
http://127.0.0.1:1935/
// http://[wowza-ip-address]:1935

7. Start engine manager :- in terminal
sudo service WowzaStreamingEngineManager start

8. In browser
http://127.0.0.1:8088/enginemanager

Read and continue steps and run wowza
Login with user name and password you put in console on wowza installation

Keep flowplayer.content-3.2.9.swf' in assets

--------------------------------------------------------------------------------------------------------------------------
9. Set up amazon  S3 on wowza media server

- Click the "Server" tab at the top of the manager, and then select "Media Cache" in the left bar pane.

- Select "Sources" and "Add Media Cache Source"

- Selcect
Source Name = S3 Stream
Source Type = AmazonS3
Aws Key id = "amazon key"
AWS secret = "amazon secret"

Minimum Time To Live:
- select days to keep cache.

- Select "Applications" on top bar of the wowza server.

- Select "VOD Edge" named as "mediacache".

- select "Media Cache Sources", to your amazon "S3 Stream" => created media cache source name of amazon s3.

Add the following settings in code

<script type="text/javascript" src="http://releases.flowplayer.org/js/flowplayer-3.2.13.js"></script>

<%= form_for @taped, :url => upload_taped_video_videos_path, :html => { :multipart => true } do |form| %>
  <%= form.file_field :taped_video %>
  <%= form.submit "Upload" %>
<% end %><br/>

<%@taped_videos.each_with_index do |tape, i|%>
  <div id="videoSection_<%= i %>" style="width:300px;height:300px;"></div>
  <div class="cost"><%=tape.cost.to_f%></div>
  <div id="replaceLink_<%= i %>" style="display:none">
    <% if current_user %>
      <%= link_to "Purchase to watch", purchase_taped_video_video_path(tape.id)%>
    <% else %>
      <!-- <%#= link_to "Already Member?", new_user_session_path%> | <%#= link_to "Register", new_registration_path(resource_name) %> -->
      <%= link_to "Already Member?", purchase_taped_video_video_path(tape.id)%> | <%= link_to "Register", "/users/sign_up" %>
    <% end %>
  </div>
  <script type="text/javascript">
    $(document).ready(function(){
      $("#show-text").hide()
    });

    flowplayer("videoSection_<%= i %>", "http://releases.flowplayer.org/swf/flowplayer-3.2.18.swf",
      {
        clip: {
          url: "mp4:amazons3/vmh(bucket name on amazon)/file_path/file.mp4",
          #url: "<%=File.extname(tape.taped_video_file_name).split('.')[1]%>:amazons3/vmh<%=tape.taped_video.path%>",
          autoPlay: false,
          autoBuffering: true,
          provider: 'rtmp',
          onCuepoint: [6000, function(clip, point) {
            this.stop()
            var plugin = this.getPlugin("content");
            plugin.show(10000).setHtml($("#replaceLink_<%= i %>").html());
          }]
        },
        plugins: {
          content: {
            url: 'flowplayer.content-3.2.9.swf',
            display: 'none'
          },
          rtmp: {
          url: '<%= asset_path "flowplayer/flowplayer.rtmp-3.2.13.swf"%>',
          netConnectionUrl: 'rtmp://127.0.0.1/mediacache'
          }
        }
      }
    );

    var player = $f()

    player.onLoad(function()  {
        // this- variable points to the player's API
        // this.getScreen().animate({width:300, height:200});
    });
  </script>
  <br/><br/>
<%end%>