falcon 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.travis.yml +18 -0
- data/Gemfile +9 -0
- data/README.md +100 -0
- data/Rakefile +64 -36
- data/bin/falcon +28 -0
- data/falcon.gemspec +31 -0
- data/lib/falcon.rb +20 -57
- data/lib/falcon/command.rb +86 -0
- data/lib/falcon/server.rb +73 -0
- data/lib/falcon/version.rb +21 -1
- data/lib/rack/handler/falcon.rb +40 -0
- metadata +148 -77
- data/LICENSE +0 -19
- data/README.rdoc +0 -159
- data/app/models/falcon/encoding.rb +0 -5
- data/lib/falcon/base.rb +0 -98
- data/lib/falcon/encoder.rb +0 -235
- data/lib/falcon/engine.rb +0 -12
- data/lib/falcon/media.rb +0 -154
- data/lib/falcon/profile.rb +0 -96
- data/lib/falcon/profiles.rb +0 -9
- data/lib/generators/falcon/USAGE +0 -7
- data/lib/generators/falcon/install_generator.rb +0 -31
- data/lib/generators/falcon/templates/migrate/create_encodings.rb +0 -29
data/lib/falcon/profile.rb
DELETED
@@ -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
|
data/lib/falcon/profiles.rb
DELETED
@@ -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})
|
data/lib/generators/falcon/USAGE
DELETED
@@ -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
|