falcon 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,96 +0,0 @@
1
- module Falcon
2
- class Profile
3
- cattr_accessor :all
4
- @@all = []
5
-
6
- attr_accessor :name, :player, :container, :extname, :width, :height, :fps, :command
7
- attr_accessor :video_bitrate, :video_codec
8
- attr_accessor :audio_codec, :audio_bitrate, :audio_sample_rate
9
-
10
- DEFAULTS = {
11
- :player => 'flash',
12
- :container => "mp4",
13
- :extname => 'mp4',
14
- :width => 480,
15
- :height => 320,
16
- :fps => 29.97,
17
- :video_codec => "libx264",
18
- :video_bitrate => 500,
19
- :command => nil,
20
- :audio_codec => "libfaac",
21
- :audio_bitrate => 128,
22
- :audio_sample_rate => 48000
23
- }
24
-
25
- def initialize(name, options = {})
26
- options.assert_valid_keys(DEFAULTS.keys)
27
- options = DEFAULTS.merge(options)
28
-
29
- @name = name.to_s
30
-
31
- if self.class.exists?(@name)
32
- raise "Profile name: #{@name} already registered."
33
- end
34
-
35
- options.each do |key, value|
36
- send("#{key}=", value)
37
- end
38
-
39
- @@all << self
40
- end
41
-
42
- def audio_bitrate_in_bits
43
- self.audio_bitrate.to_i * 1024
44
- end
45
-
46
- def video_bitrate_in_bits
47
- self.video_bitrate.to_i * 1024
48
- end
49
-
50
- def path(source, prefix = nil)
51
- dirname = File.dirname(source)
52
- filename = File.basename(source, File.extname(source))
53
- filename = [prefix, filename].compact.join('_') + '.' + extname
54
-
55
- Pathname.new(File.join(dirname, filename))
56
- end
57
-
58
- def encode_options
59
- {
60
- :container => self.container,
61
- :video_codec => self.video_codec,
62
- :video_bitrate_in_bits => self.video_bitrate_in_bits.to_s,
63
- :fps => self.fps,
64
- :audio_codec => self.audio_codec.to_s,
65
- :audio_bitrate => self.audio_bitrate.to_s,
66
- :audio_bitrate_in_bits => self.audio_bitrate_in_bits.to_s,
67
- :audio_sample_rate => self.audio_sample_rate.to_s
68
- }
69
- end
70
-
71
- def update(options)
72
- options.each do |key, value|
73
- send("#{key}=", value)
74
- end
75
- end
76
-
77
- class << self
78
- def find(name)
79
- @@all.detect { |p| p.name == name.to_s }
80
- end
81
- alias :get :find
82
-
83
- def [](name)
84
- find(name)
85
- end
86
-
87
- def exists?(name)
88
- !find(name).nil?
89
- end
90
-
91
- def detect(name)
92
- name.is_a?(Falcon::Profile) ? name : find(name.to_s)
93
- end
94
- end
95
- end
96
- end
@@ -1,9 +0,0 @@
1
- Falcon::Profile.new("web_mp4", {:player => 'flash', :container => "mp4", :extname => 'mp4',
2
- :width => 480, :height => 320, :video_codec => "libx264",
3
- :command => "-vpre slow -crf 22", :video_bitrate => 500, :fps => 29.97,
4
- :audio_codec => "libfaac", :audio_bitrate => 128, :audio_sample_rate => 48000})
5
-
6
- Falcon::Profile.new("web_ogg", {:player => 'html5', :container => "ogg", :extname => 'ogv',
7
- :width => 480, :height => 320, :video_codec => "libtheora", :command => '-g 300',
8
- :video_bitrate => 1000, :fps => 29.97, :audio_codec => "libvorbis",
9
- :audio_bitrate => 128, :audio_sample_rate => 48000})
@@ -1,7 +0,0 @@
1
- Usage:
2
- rails generate falcon:install
3
-
4
- Options:
5
-
6
- Example:
7
- rails g falcon:install
@@ -1,31 +0,0 @@
1
- require 'rails/generators'
2
- require 'rails/generators/migration'
3
-
4
- module Falcon
5
- module Generators
6
- class InstallGenerator < Rails::Generators::Base
7
- include Rails::Generators::Migration
8
-
9
- desc "Create falcon migration"
10
- source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
11
-
12
- # copy migration files
13
- def create_migrations
14
- migration_template "migrate/create_encodings.rb", File.join('db/migrate', "falcon_create_encodings.rb")
15
- end
16
-
17
- def self.next_migration_number(dirname)
18
- if ActiveRecord::Base.timestamped_migrations
19
- current_time.utc.strftime("%Y%m%d%H%M%S")
20
- else
21
- "%.3d" % (current_migration_number(dirname) + 1)
22
- end
23
- end
24
-
25
- def self.current_time
26
- @current_time ||= Time.now
27
- @current_time += 1.minute
28
- end
29
- end
30
- end
31
- end
@@ -1,29 +0,0 @@
1
- class FalconCreateEncodings < ActiveRecord::Migration
2
- def self.up
3
- create_table :falcon_encodings do |t|
4
- t.string :name, :limit => 50, :null => false
5
- t.string :profile_name, :limit => 50, :null => false
6
- t.string :source_path, :null => false
7
-
8
- t.string :videoable_type, :limit => 50
9
- t.integer :videoable_id
10
-
11
- t.integer :status, :default => 0
12
- t.integer :progress
13
- t.integer :width
14
- t.integer :height
15
-
16
- t.integer :encoding_time
17
- t.datetime :encoded_at
18
-
19
- t.timestamps
20
- end
21
-
22
- add_index :falcon_encodings, [:videoable_type, :videoable_id]
23
- add_index :falcon_encodings, :status
24
- end
25
-
26
- def self.down
27
- drop_table :falcon_encodings
28
- end
29
- end