puremotion 0.0.1 → 0.1.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.
- data/.yardopts +1 -0
- data/README.md +69 -0
- data/Rakefile +23 -11
- data/examples/progress_reporting.rb +26 -0
- data/examples/simple.rb +22 -0
- data/ext/puremotion/audio.c +38 -0
- data/ext/puremotion/extconf.rb +34 -0
- data/ext/puremotion/frame.c +176 -0
- data/ext/puremotion/media.c +175 -0
- data/ext/puremotion/puremotion.c +26 -0
- data/ext/puremotion/puremotion.h +38 -0
- data/ext/puremotion/stream.c +128 -0
- data/ext/puremotion/stream_collection.c +44 -0
- data/ext/puremotion/utils.c +81 -0
- data/ext/puremotion/utils.h +6 -0
- data/ext/puremotion/video.c +141 -0
- data/lib/{puremotion/events → events}/event.rb +0 -0
- data/lib/{puremotion/events → events}/generator.rb +0 -0
- data/lib/media.rb +89 -0
- data/lib/preset/audio/audio.rb +42 -0
- data/lib/preset/file.rb +19 -0
- data/lib/preset/general.rb +28 -0
- data/lib/preset/metadata.rb +41 -0
- data/lib/preset/preset.rb +120 -0
- data/lib/preset/video/crop.rb +29 -0
- data/lib/preset/video/pad.rb +31 -0
- data/lib/preset/video/video.rb +130 -0
- data/lib/puremotion.rb +20 -12
- data/lib/puremotion_native.so +0 -0
- data/lib/threading.rb +54 -0
- data/lib/{puremotion/tools → tools}/ffmpeg.rb +12 -50
- data/lib/transcode/transcode.rb +142 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/units/media_spec.rb +13 -0
- data/spec/units/preset_spec.rb +91 -0
- metadata +52 -44
- data/.document +0 -5
- data/.gitignore +0 -21
- data/README.rdoc +0 -18
- data/VERSION +0 -1
- data/lib/puremotion/codecs.rb +0 -59
- data/lib/puremotion/media.rb +0 -490
- data/lib/puremotion/media/stream.rb +0 -4
- data/lib/puremotion/media/stream/audio.rb +0 -0
- data/lib/puremotion/media/stream/base.rb +0 -7
- data/lib/puremotion/media/stream/collection.rb +0 -5
- data/lib/puremotion/media/stream/video.rb +0 -61
- data/lib/puremotion/recipes/ipod.yml +0 -12
- data/lib/puremotion/thread.rb +0 -153
- data/lib/puremotion/transcode/recipe.rb +0 -250
- data/lib/puremotion/transcode/transcode.rb +0 -153
- data/puremotion.gemspec +0 -68
- data/test/helper.rb +0 -10
- data/test/test_puremotion.rb +0 -7
@@ -1,153 +0,0 @@
|
|
1
|
-
module PureMotion::Transcode
|
2
|
-
|
3
|
-
@@recipes = []
|
4
|
-
|
5
|
-
def self.do(media, params)
|
6
|
-
return Transcode.new(media, params)
|
7
|
-
end
|
8
|
-
|
9
|
-
class Transcode < Object
|
10
|
-
|
11
|
-
event :progress
|
12
|
-
event :complete
|
13
|
-
event :error
|
14
|
-
event :status_change
|
15
|
-
|
16
|
-
@status
|
17
|
-
@media = nil
|
18
|
-
|
19
|
-
@ffmpeg = nil
|
20
|
-
|
21
|
-
def initialize(media, params)
|
22
|
-
|
23
|
-
@status = Status::NOT_STARTED
|
24
|
-
|
25
|
-
@params = {
|
26
|
-
:output => nil,
|
27
|
-
:overwrite => false,
|
28
|
-
:recipe => nil
|
29
|
-
}
|
30
|
-
|
31
|
-
raise ArgumentError, "Invalid paramters given" unless params.is_a? Hash
|
32
|
-
|
33
|
-
@params.merge!(params)
|
34
|
-
|
35
|
-
raise ArgumentError, "No output file given" if @params[:output].nil?
|
36
|
-
|
37
|
-
case @params[:recipe]
|
38
|
-
when String
|
39
|
-
set_recipe Recipe.from_file(@params[:recipe])
|
40
|
-
when Hash
|
41
|
-
set_recipe Recipe.build(@params[:recipe])
|
42
|
-
when Recipe
|
43
|
-
set_recipe @params[:recipe]
|
44
|
-
when Symbol
|
45
|
-
set_recipe Recipe.from_name(@params[:recipe].to_s)
|
46
|
-
else
|
47
|
-
raise ArgumentError, "Invalid recipe"
|
48
|
-
end
|
49
|
-
|
50
|
-
@media = find_media(media)
|
51
|
-
|
52
|
-
if @media.analysed?
|
53
|
-
prepare
|
54
|
-
else
|
55
|
-
|
56
|
-
@media.analysed + lambda do |media, raw|
|
57
|
-
prepare
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
|
-
raise ArgumentError, "Output file #{@params[:output]} exists and overwrite disabled" if File.exists?(@params[:output]) and !@params[:overwrite]
|
63
|
-
|
64
|
-
@ffmpeg = PureMotion::Tools::FFmpeg.run :options => "-i #{@media.file} #{'-y' if @params[:overwrite]} " + @recipe.to_args + " \"#{@params[:output]}\""
|
65
|
-
|
66
|
-
@ffmpeg.line + lambda do |ffmpeg, line|
|
67
|
-
handle_output line
|
68
|
-
end
|
69
|
-
|
70
|
-
end
|
71
|
-
|
72
|
-
def run
|
73
|
-
|
74
|
-
end
|
75
|
-
|
76
|
-
def cancel
|
77
|
-
|
78
|
-
end
|
79
|
-
|
80
|
-
def cancel!
|
81
|
-
|
82
|
-
end
|
83
|
-
|
84
|
-
private
|
85
|
-
|
86
|
-
def set_recipe(recipe)
|
87
|
-
@params[:recipe] = recipe
|
88
|
-
@recipe = recipe
|
89
|
-
end
|
90
|
-
|
91
|
-
def set_status(status)
|
92
|
-
@status = status
|
93
|
-
status_change(@status)
|
94
|
-
end
|
95
|
-
|
96
|
-
def find_media(media)
|
97
|
-
|
98
|
-
case media
|
99
|
-
when String
|
100
|
-
return PureMotion::Media.new(media)
|
101
|
-
when PureMotion::Media
|
102
|
-
return media
|
103
|
-
else
|
104
|
-
raise Error, "Invalid media given"
|
105
|
-
end
|
106
|
-
|
107
|
-
end
|
108
|
-
|
109
|
-
def handle_output line
|
110
|
-
puts line
|
111
|
-
# /^frame=\s*(?<frame>\d*)\s*fps=\s*(?<fps>\d*)\s*q=(?<q>\S*)\s*size=\s*(?<size>[\d]*)(?<size_unit>[kmg]B)\s*time=\s*(?<time>[\d.]*)\s*bitrate=\s*(?<bitrate>[\d.]*)(?<bitrate_unit>[km]b).*$/
|
112
|
-
progress_line = /frame=\s*(\d*)\s*fps=\s*(\d*)\s*q=(\S*)\s*[L]?size=\s*([\d]*)([kmg]B)\s*time=\s*([\d.]*)\s*bitrate=\s*([\d.]*)([km]b)/
|
113
|
-
# 1 => frame
|
114
|
-
# 2 => fps
|
115
|
-
# 3 => q
|
116
|
-
# 4 => size
|
117
|
-
# 5 => size_unit
|
118
|
-
# 6 => time
|
119
|
-
# 7 => bitrate
|
120
|
-
# 8 => bitrate_unit
|
121
|
-
handle_progress(progress_line.match(line)) if progress_line.match(line)
|
122
|
-
end
|
123
|
-
|
124
|
-
def handle_progress line
|
125
|
-
p = {
|
126
|
-
:frame => line[1].to_i,
|
127
|
-
:fps => line[2].to_i,
|
128
|
-
:q => line[3].to_f,
|
129
|
-
:size => line[4].to_i,
|
130
|
-
:time => line[6].to_f,
|
131
|
-
:bitrate => line[7].to_f,
|
132
|
-
:precent => ((100.00 / @media.detail(:duration, :seconds)) * line[6].to_f).to_i
|
133
|
-
}
|
134
|
-
p[:percent] = 100 if p[:percent] > 100
|
135
|
-
progress(p)
|
136
|
-
end
|
137
|
-
|
138
|
-
# Fire progress event
|
139
|
-
# complete(p)
|
140
|
-
end
|
141
|
-
|
142
|
-
class Error < Exception
|
143
|
-
|
144
|
-
|
145
|
-
end
|
146
|
-
|
147
|
-
class Status
|
148
|
-
|
149
|
-
NOT_STARTED = -1
|
150
|
-
|
151
|
-
end
|
152
|
-
|
153
|
-
end
|
data/puremotion.gemspec
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{puremotion}
|
8
|
-
s.version = "0.0.1"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Ominiom"]
|
12
|
-
s.date = %q{2009-11-14}
|
13
|
-
s.description = %q{A Ruby wrapper for analysis and conversion of media using FFmpeg}
|
14
|
-
s.email = %q{iain.iw.wilson@googlemail.com}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE",
|
17
|
-
"README.rdoc"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".document",
|
21
|
-
".gitignore",
|
22
|
-
"LICENSE",
|
23
|
-
"README.rdoc",
|
24
|
-
"Rakefile",
|
25
|
-
"VERSION",
|
26
|
-
"lib/puremotion.rb",
|
27
|
-
"lib/puremotion/codecs.rb",
|
28
|
-
"lib/puremotion/events/event.rb",
|
29
|
-
"lib/puremotion/events/generator.rb",
|
30
|
-
"lib/puremotion/media.rb",
|
31
|
-
"lib/puremotion/media/stream.rb",
|
32
|
-
"lib/puremotion/media/stream/audio.rb",
|
33
|
-
"lib/puremotion/media/stream/base.rb",
|
34
|
-
"lib/puremotion/media/stream/collection.rb",
|
35
|
-
"lib/puremotion/media/stream/video.rb",
|
36
|
-
"lib/puremotion/recipes/ipod.yml",
|
37
|
-
"lib/puremotion/thread.rb",
|
38
|
-
"lib/puremotion/tools/ffmpeg.rb",
|
39
|
-
"lib/puremotion/transcode/recipe.rb",
|
40
|
-
"lib/puremotion/transcode/transcode.rb",
|
41
|
-
"puremotion.gemspec",
|
42
|
-
"test/helper.rb",
|
43
|
-
"test/test_puremotion.rb"
|
44
|
-
]
|
45
|
-
s.homepage = %q{http://github.com/ominiom/puremotion}
|
46
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
47
|
-
s.require_paths = ["lib"]
|
48
|
-
s.rubygems_version = %q{1.3.5}
|
49
|
-
s.summary = %q{PureMotion}
|
50
|
-
s.test_files = [
|
51
|
-
"test/helper.rb",
|
52
|
-
"test/test_puremotion.rb"
|
53
|
-
]
|
54
|
-
|
55
|
-
if s.respond_to? :specification_version then
|
56
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
57
|
-
s.specification_version = 3
|
58
|
-
|
59
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
60
|
-
s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
61
|
-
else
|
62
|
-
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
63
|
-
end
|
64
|
-
else
|
65
|
-
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
data/test/helper.rb
DELETED