streamio-ffmpeg 0.7.2 → 0.7.3
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/CHANGELOG +6 -0
- data/LICENSE +1 -1
- data/README.rdoc +1 -1
- data/lib/ffmpeg/transcoder.rb +2 -3
- data/lib/ffmpeg/version.rb +3 -0
- data/lib/streamio-ffmpeg.rb +1 -2
- metadata +23 -40
- data/.document +0 -5
- data/.gitignore +0 -23
- data/Rakefile +0 -44
- data/VERSION +0 -1
- data/spec/ffmpeg/encoding_options_spec.rb +0 -128
- data/spec/ffmpeg/movie_spec.rb +0 -150
- data/spec/ffmpeg/transcoder_spec.rb +0 -161
- data/spec/fixtures/movies/awesome movie.mov +0 -0
- data/spec/fixtures/movies/awesome_widescreen.mov +0 -0
- data/spec/fixtures/movies/broken.mp4 +0 -0
- data/spec/fixtures/movies/weird_aspect.small.mpg +0 -0
- data/spec/fixtures/sounds/napoleon.mp3 +0 -0
- data/spec/spec.opts +0 -1
- data/spec/spec_helper.rb +0 -21
- data/spec/streamio-ffmpeg_spec.rb +0 -24
- data/streamio-ffmpeg.gemspec +0 -70
data/CHANGELOG
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
== 0.7.3 2010-08-26
|
2
|
+
|
3
|
+
* Replaced Jewler with simple dynamic gemspec file
|
4
|
+
* Spec files now not in published gem to make it a lot smaller in size
|
5
|
+
* Full output from ffmpeg command in error raised during transcoding
|
6
|
+
|
1
7
|
== 0.7.2 2010-08-11
|
2
8
|
|
3
9
|
* Added encoding option duration
|
data/LICENSE
CHANGED
data/README.rdoc
CHANGED
data/lib/ffmpeg/transcoder.rb
CHANGED
@@ -37,7 +37,6 @@ module FFMPEG
|
|
37
37
|
FFMPEG.logger.error "Failed encoding...\nCommand\n#{command}\nOutput\n#{output}\n"
|
38
38
|
raise "Failed encoding: #{line}"
|
39
39
|
end
|
40
|
-
last_output = line
|
41
40
|
end
|
42
41
|
end
|
43
42
|
|
@@ -45,9 +44,9 @@ module FFMPEG
|
|
45
44
|
FFMPEG.logger.info "Transcoding of #{@movie.path} to #{@output_file} succeeded\n"
|
46
45
|
yield(1.0) if block_given?
|
47
46
|
else
|
48
|
-
errors = @errors.empty? ? "" : "Errors: #{@errors.join(", ")}"
|
47
|
+
errors = @errors.empty? ? "" : " Errors: #{@errors.join(", ")}. "
|
49
48
|
FFMPEG.logger.error "Failed encoding...\n#{command}\n\n#{output}\n#{errors}\n"
|
50
|
-
raise "Failed encoding
|
49
|
+
raise "Failed encoding.#{errors}Full output: #{output}"
|
51
50
|
end
|
52
51
|
|
53
52
|
encoded
|
data/lib/streamio-ffmpeg.rb
CHANGED
@@ -2,13 +2,12 @@ $LOAD_PATH.unshift File.dirname(__FILE__)
|
|
2
2
|
|
3
3
|
require 'logger'
|
4
4
|
|
5
|
+
require 'ffmpeg/version'
|
5
6
|
require 'ffmpeg/movie'
|
6
7
|
require 'ffmpeg/transcoder'
|
7
8
|
require 'ffmpeg/encoding_options'
|
8
9
|
|
9
10
|
module FFMPEG
|
10
|
-
VERSION = '0.5.0'
|
11
|
-
|
12
11
|
# FFMPEG logs information about its progress when it's transcoding.
|
13
12
|
# Jack in your own logger through this method if you wish to.
|
14
13
|
#
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: streamio-ffmpeg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 5
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
version: 0.7.
|
9
|
+
- 3
|
10
|
+
version: 0.7.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- David Backeus
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-08-
|
18
|
+
date: 2010-08-26 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -34,46 +34,31 @@ dependencies:
|
|
34
34
|
version: 1.3.0
|
35
35
|
type: :development
|
36
36
|
version_requirements: *id001
|
37
|
-
description: Simple wrapper around ffmpeg to get metadata from movies and do transcoding
|
38
|
-
email:
|
37
|
+
description: Simple yet powerful wrapper around ffmpeg to get metadata from movies and do transcoding.
|
38
|
+
email:
|
39
|
+
- david@streamio.se
|
39
40
|
executables: []
|
40
41
|
|
41
42
|
extensions: []
|
42
43
|
|
43
|
-
extra_rdoc_files:
|
44
|
-
|
45
|
-
- README.rdoc
|
44
|
+
extra_rdoc_files: []
|
45
|
+
|
46
46
|
files:
|
47
|
-
- .document
|
48
|
-
- .gitignore
|
49
|
-
- CHANGELOG
|
50
|
-
- LICENSE
|
51
|
-
- README.rdoc
|
52
|
-
- Rakefile
|
53
|
-
- VERSION
|
54
47
|
- lib/ffmpeg/encoding_options.rb
|
55
48
|
- lib/ffmpeg/movie.rb
|
56
49
|
- lib/ffmpeg/transcoder.rb
|
50
|
+
- lib/ffmpeg/version.rb
|
57
51
|
- lib/streamio-ffmpeg.rb
|
58
|
-
-
|
59
|
-
-
|
60
|
-
-
|
61
|
-
- spec/fixtures/movies/awesome movie.mov
|
62
|
-
- spec/fixtures/movies/awesome_widescreen.mov
|
63
|
-
- spec/fixtures/movies/broken.mp4
|
64
|
-
- spec/fixtures/movies/weird_aspect.small.mpg
|
65
|
-
- spec/fixtures/sounds/napoleon.mp3
|
66
|
-
- spec/spec.opts
|
67
|
-
- spec/spec_helper.rb
|
68
|
-
- spec/streamio-ffmpeg_spec.rb
|
69
|
-
- streamio-ffmpeg.gemspec
|
52
|
+
- README.rdoc
|
53
|
+
- LICENSE
|
54
|
+
- CHANGELOG
|
70
55
|
has_rdoc: true
|
71
56
|
homepage: http://github.com/streamio/streamio-ffmpeg
|
72
57
|
licenses: []
|
73
58
|
|
74
59
|
post_install_message:
|
75
|
-
rdoc_options:
|
76
|
-
|
60
|
+
rdoc_options: []
|
61
|
+
|
77
62
|
require_paths:
|
78
63
|
- lib
|
79
64
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -90,20 +75,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
75
|
requirements:
|
91
76
|
- - ">="
|
92
77
|
- !ruby/object:Gem::Version
|
93
|
-
hash:
|
78
|
+
hash: 23
|
94
79
|
segments:
|
95
|
-
-
|
96
|
-
|
80
|
+
- 1
|
81
|
+
- 3
|
82
|
+
- 6
|
83
|
+
version: 1.3.6
|
97
84
|
requirements: []
|
98
85
|
|
99
86
|
rubyforge_project:
|
100
87
|
rubygems_version: 1.3.7
|
101
88
|
signing_key:
|
102
89
|
specification_version: 3
|
103
|
-
summary:
|
104
|
-
test_files:
|
105
|
-
|
106
|
-
- spec/ffmpeg/movie_spec.rb
|
107
|
-
- spec/ffmpeg/transcoder_spec.rb
|
108
|
-
- spec/spec_helper.rb
|
109
|
-
- spec/streamio-ffmpeg_spec.rb
|
90
|
+
summary: Reads metadata and transcodes movies.
|
91
|
+
test_files: []
|
92
|
+
|
data/.document
DELETED
data/.gitignore
DELETED
data/Rakefile
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rake'
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'jeweler'
|
6
|
-
Jeweler::Tasks.new do |gem|
|
7
|
-
gem.name = "streamio-ffmpeg"
|
8
|
-
gem.summary = %Q{Simple wrapper around ffmpeg to get metadata from movies and do transcoding}
|
9
|
-
gem.description = %Q{Simple wrapper around ffmpeg to get metadata from movies and do transcoding}
|
10
|
-
gem.email = "duztdruid@gmail.com"
|
11
|
-
gem.homepage = "http://github.com/streamio/streamio-ffmpeg"
|
12
|
-
gem.authors = ["David Backeus"]
|
13
|
-
gem.add_development_dependency "rspec", "1.3.0"
|
14
|
-
end
|
15
|
-
Jeweler::GemcutterTasks.new
|
16
|
-
rescue LoadError
|
17
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
18
|
-
end
|
19
|
-
|
20
|
-
require 'spec/rake/spectask'
|
21
|
-
Spec::Rake::SpecTask.new(:spec) do |spec|
|
22
|
-
spec.libs << 'lib' << 'spec'
|
23
|
-
spec.spec_files = FileList['spec/**/*_spec.rb']
|
24
|
-
end
|
25
|
-
|
26
|
-
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
27
|
-
spec.libs << 'lib' << 'spec'
|
28
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
29
|
-
spec.rcov = true
|
30
|
-
end
|
31
|
-
|
32
|
-
task :spec => :check_dependencies
|
33
|
-
|
34
|
-
task :default => :spec
|
35
|
-
|
36
|
-
require 'rake/rdoctask'
|
37
|
-
Rake::RDocTask.new do |rdoc|
|
38
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
39
|
-
|
40
|
-
rdoc.rdoc_dir = 'rdoc'
|
41
|
-
rdoc.title = "streamio-ffmpeg #{version}"
|
42
|
-
rdoc.rdoc_files.include('README*')
|
43
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
44
|
-
end
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.7.2
|
@@ -1,128 +0,0 @@
|
|
1
|
-
require 'spec_helper.rb'
|
2
|
-
|
3
|
-
module FFMPEG
|
4
|
-
describe EncodingOptions do
|
5
|
-
describe "ffmpeg arguments conversion" do
|
6
|
-
it "should convert video codec" do
|
7
|
-
EncodingOptions.new(:video_codec => "libx264").to_s.should == "-vcodec libx264"
|
8
|
-
end
|
9
|
-
|
10
|
-
it "should convert cropping options" do
|
11
|
-
EncodingOptions.new(:croptop => 20).to_s.should == "-croptop 20"
|
12
|
-
EncodingOptions.new(:cropbottom => 20).to_s.should == "-cropbottom 20"
|
13
|
-
EncodingOptions.new(:cropleft => 20).to_s.should == "-cropleft 20"
|
14
|
-
EncodingOptions.new(:cropright => 20).to_s.should == "-cropright 20"
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should know the width from the resolution or be nil" do
|
18
|
-
EncodingOptions.new(:resolution => "320x240").width.should == 320
|
19
|
-
EncodingOptions.new.width.should be_nil
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should know the height from the resolution or be nil" do
|
23
|
-
EncodingOptions.new(:resolution => "320x240").height.should == 240
|
24
|
-
EncodingOptions.new.height.should be_nil
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should convert frame rate" do
|
28
|
-
EncodingOptions.new(:frame_rate => 29.9).to_s.should == "-r 29.9"
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should convert the resolution" do
|
32
|
-
EncodingOptions.new(:resolution => "640x480").to_s.should include("-s 640x480")
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should add calculated aspect ratio" do
|
36
|
-
EncodingOptions.new(:resolution => "640x480").to_s.should include("-aspect 1.3333333")
|
37
|
-
EncodingOptions.new(:resolution => "640x360").to_s.should include("-aspect 1.7777777777777")
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should use specified aspect ratio if given" do
|
41
|
-
EncodingOptions.new(:resolution => "640x480",
|
42
|
-
:aspect => 1.77777777777778).to_s.should == "-s 640x480 -aspect 1.77777777777778"
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should convert video bitrate" do
|
46
|
-
EncodingOptions.new(:video_bitrate => "600k").to_s.should == "-b 600k"
|
47
|
-
end
|
48
|
-
|
49
|
-
it "should use k unit for video bitrate" do
|
50
|
-
EncodingOptions.new(:video_bitrate => 600).to_s.should == "-b 600k"
|
51
|
-
end
|
52
|
-
|
53
|
-
it "should convert audio codec" do
|
54
|
-
EncodingOptions.new(:audio_codec => "aac").to_s.should == "-acodec aac"
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should convert audio bitrate" do
|
58
|
-
EncodingOptions.new(:audio_bitrate => "128k").to_s.should == "-ab 128k"
|
59
|
-
end
|
60
|
-
|
61
|
-
it "should use k unit for audio bitrate" do
|
62
|
-
EncodingOptions.new(:audio_bitrate => 128).to_s.should == "-ab 128k"
|
63
|
-
end
|
64
|
-
|
65
|
-
it "should convert audio sample rate" do
|
66
|
-
EncodingOptions.new(:audio_sample_rate => 44100).to_s.should == "-ar 44100"
|
67
|
-
end
|
68
|
-
|
69
|
-
it "should convert audio channels" do
|
70
|
-
EncodingOptions.new(:audio_channels => 2).to_s.should == "-ac 2"
|
71
|
-
end
|
72
|
-
|
73
|
-
it "should convert maximum video bitrate" do
|
74
|
-
EncodingOptions.new(:video_max_bitrate => 600).to_s.should == "-maxrate 600k"
|
75
|
-
end
|
76
|
-
|
77
|
-
it "should convert mininimum video bitrate" do
|
78
|
-
EncodingOptions.new(:video_min_bitrate => 600).to_s.should == "-minrate 600k"
|
79
|
-
end
|
80
|
-
|
81
|
-
it "should convert video bitrate tolerance" do
|
82
|
-
EncodingOptions.new(:video_bitrate_tolerance => 100).to_s.should == "-bt 100k"
|
83
|
-
end
|
84
|
-
|
85
|
-
it "should convert buffer size" do
|
86
|
-
EncodingOptions.new(:buffer_size => 2000).to_s.should == "-bufsize 2000k"
|
87
|
-
end
|
88
|
-
|
89
|
-
it "should convert threads" do
|
90
|
-
EncodingOptions.new(:threads => 2).to_s.should == "-threads 2"
|
91
|
-
end
|
92
|
-
|
93
|
-
it "should convert duration" do
|
94
|
-
EncodingOptions.new(:duration => 30).to_s.should == "-t 30"
|
95
|
-
end
|
96
|
-
|
97
|
-
it "should convert video preset" do
|
98
|
-
EncodingOptions.new(:video_preset => "max").to_s.should == "-vpre max"
|
99
|
-
end
|
100
|
-
|
101
|
-
it "should convert audio preset" do
|
102
|
-
EncodingOptions.new(:audio_preset => "max").to_s.should == "-apre max"
|
103
|
-
end
|
104
|
-
|
105
|
-
it "should convert file preset" do
|
106
|
-
EncodingOptions.new(:file_preset => "max.ffpreset").to_s.should == "-fpre max.ffpreset"
|
107
|
-
end
|
108
|
-
|
109
|
-
it "should put the preset parameters last" do
|
110
|
-
opts = Hash.new
|
111
|
-
opts[:video_codec] = "libx264"
|
112
|
-
opts[:video_preset] = "normal"
|
113
|
-
|
114
|
-
converted = EncodingOptions.new(opts).to_s
|
115
|
-
converted.should == "-vcodec libx264 -vpre normal"
|
116
|
-
end
|
117
|
-
|
118
|
-
it "should convert a lot of them simultaneously" do
|
119
|
-
converted = EncodingOptions.new(:video_codec => "libx264", :audio_codec => "aac", :video_bitrate => "1000k").to_s
|
120
|
-
converted.should match(/-acodec aac/)
|
121
|
-
end
|
122
|
-
|
123
|
-
it "should ignore options with nil value" do
|
124
|
-
EncodingOptions.new(:video_codec => "libx264", :frame_rate => nil).to_s.should == "-vcodec libx264 "
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
data/spec/ffmpeg/movie_spec.rb
DELETED
@@ -1,150 +0,0 @@
|
|
1
|
-
require 'spec_helper.rb'
|
2
|
-
|
3
|
-
module FFMPEG
|
4
|
-
|
5
|
-
describe Movie do
|
6
|
-
describe "given a non existing file" do
|
7
|
-
it "should throw ArgumentError" do
|
8
|
-
lambda { Movie.new("i_dont_exist") }.should raise_error(Errno::ENOENT, /does not exist/)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "parsing" do
|
13
|
-
describe "given a non movie file" do
|
14
|
-
before(:all) do
|
15
|
-
@movie = Movie.new(__FILE__)
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should not be valid" do
|
19
|
-
@movie.should_not be_valid
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe "given a mp3 file" do
|
24
|
-
before(:all) do
|
25
|
-
@movie = Movie.new("#{fixture_path}/sounds/napoleon.mp3")
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should have uncertain duration" do
|
29
|
-
@movie.should be_uncertain_duration
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe "a broken mp4 file" do
|
34
|
-
before(:all) do
|
35
|
-
@movie = Movie.new("#{fixture_path}/movies/broken.mp4")
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should not be valid" do
|
39
|
-
@movie.should_not be_valid
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should have nil calculated_aspect_ratio" do
|
43
|
-
@movie.calculated_aspect_ratio.should be_nil
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe "given a weird aspect ratio file" do
|
48
|
-
before(:all) do
|
49
|
-
@movie = Movie.new("#{fixture_path}/movies/weird_aspect.small.mpg")
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should parse the DAR" do
|
53
|
-
@movie.dar.should == "704:405"
|
54
|
-
end
|
55
|
-
|
56
|
-
it "should have correct calculated_aspect_ratio" do
|
57
|
-
@movie.calculated_aspect_ratio.to_s[0..15].should == "1.73827160493827" # substringed to be 1.9 compatible
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
describe "given an awesome movie file" do
|
62
|
-
before(:all) do
|
63
|
-
@movie = Movie.new("#{fixture_path}/movies/awesome movie.mov")
|
64
|
-
end
|
65
|
-
|
66
|
-
it "should not have uncertain duration" do
|
67
|
-
@movie.should_not be_uncertain_duration
|
68
|
-
end
|
69
|
-
|
70
|
-
it "should remember the movie path" do
|
71
|
-
@movie.path.should == "#{fixture_path}/movies/awesome movie.mov"
|
72
|
-
end
|
73
|
-
|
74
|
-
it "should parse duration to number of seconds" do
|
75
|
-
@movie.duration.should == 7.5
|
76
|
-
end
|
77
|
-
|
78
|
-
it "should parse the bitrate" do
|
79
|
-
@movie.bitrate.should == 481
|
80
|
-
end
|
81
|
-
|
82
|
-
it "should parse video stream information" do
|
83
|
-
@movie.video_stream.should == "h264, yuv420p, 640x480 [PAR 1:1 DAR 4:3], 371 kb/s, 16.75 fps, 15 tbr, 600 tbn, 1200 tbc"
|
84
|
-
end
|
85
|
-
|
86
|
-
it "should know the video codec" do
|
87
|
-
@movie.video_codec.should == "h264"
|
88
|
-
end
|
89
|
-
|
90
|
-
it "should know the colorspace" do
|
91
|
-
@movie.colorspace.should == "yuv420p"
|
92
|
-
end
|
93
|
-
|
94
|
-
it "should know the resolution" do
|
95
|
-
@movie.resolution.should == "640x480"
|
96
|
-
end
|
97
|
-
|
98
|
-
it "should know the width and height" do
|
99
|
-
@movie.width.should == 640
|
100
|
-
@movie.height.should == 480
|
101
|
-
end
|
102
|
-
|
103
|
-
it "should know the framerate" do
|
104
|
-
@movie.frame_rate.should == 16.75
|
105
|
-
end
|
106
|
-
|
107
|
-
it "should parse audio stream information" do
|
108
|
-
@movie.audio_stream.should == "aac, 44100 Hz, stereo, s16, 75 kb/s"
|
109
|
-
end
|
110
|
-
|
111
|
-
it "should know the audio codec" do
|
112
|
-
@movie.audio_codec.should == "aac"
|
113
|
-
end
|
114
|
-
|
115
|
-
it "should know the sample rate" do
|
116
|
-
@movie.audio_sample_rate.should == 44100
|
117
|
-
end
|
118
|
-
|
119
|
-
it "should know the number of audio channels" do
|
120
|
-
@movie.audio_channels.should == 2
|
121
|
-
end
|
122
|
-
|
123
|
-
it "should should be valid" do
|
124
|
-
@movie.should be_valid
|
125
|
-
end
|
126
|
-
|
127
|
-
it "should calculate the aspect ratio" do
|
128
|
-
@movie.calculated_aspect_ratio.to_s[0..15].should == "1.33333333333333" # substringed to be 1.9 compatible
|
129
|
-
end
|
130
|
-
|
131
|
-
it "should know the file size" do
|
132
|
-
@movie.size.should == 455546
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
describe "transcode" do
|
138
|
-
it "should run the transcoder" do
|
139
|
-
movie = Movie.new("#{fixture_path}/movies/awesome movie.mov")
|
140
|
-
|
141
|
-
mockery = mock(Transcoder)
|
142
|
-
Transcoder.should_receive(:new).with(movie, "#{tmp_path}/awesome.flv", {:custom => "-vcodec libx264"}, :preserve_aspect_ratio => :width).and_return(mockery)
|
143
|
-
mockery.should_receive(:run)
|
144
|
-
|
145
|
-
movie.transcode("#{tmp_path}/awesome.flv", {:custom => "-vcodec libx264"}, :preserve_aspect_ratio => :width)
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
end
|
@@ -1,161 +0,0 @@
|
|
1
|
-
require 'spec_helper.rb'
|
2
|
-
|
3
|
-
module FFMPEG
|
4
|
-
describe Transcoder do
|
5
|
-
describe "initialization" do
|
6
|
-
before(:each) do
|
7
|
-
@movie = Movie.new("#{fixture_path}/movies/awesome movie.mov")
|
8
|
-
@output_path = "#{tmp_path}/awesome.flv"
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should accept EncodingOptions as options" do
|
12
|
-
lambda { Transcoder.new(@movie, @output_path, EncodingOptions.new) }.should_not raise_error(ArgumentError)
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should accept Hash as options" do
|
16
|
-
lambda { Transcoder.new(@movie, @output_path, :video_codec => "libx264") }.should_not raise_error(ArgumentError)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should accept String as options" do
|
20
|
-
lambda { Transcoder.new(@movie, @output_path, "-vcodec libx264") }.should_not raise_error(ArgumentError)
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should not accept anything else as options" do
|
24
|
-
lambda { Transcoder.new(@movie, @output_path, ["array?"]) }.should raise_error(ArgumentError, /Unknown options format/)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe "transcoding" do
|
29
|
-
before(:each) do
|
30
|
-
FFMPEG.logger.should_receive(:info).at_least(:once)
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should transcode the movie with progress given an awesome movie" do
|
34
|
-
FileUtils.rm_f "#{tmp_path}/awesome.flv"
|
35
|
-
|
36
|
-
movie = Movie.new("#{fixture_path}/movies/awesome movie.mov")
|
37
|
-
|
38
|
-
transcoder = Transcoder.new(movie, "#{tmp_path}/awesome.flv")
|
39
|
-
stored_progress = 0
|
40
|
-
transcoder.run { |progress| stored_progress = progress }
|
41
|
-
transcoder.encoded.should be_valid
|
42
|
-
stored_progress.should == 1.0
|
43
|
-
File.exists?("#{tmp_path}/awesome.flv").should be_true
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should transcode the movie with EncodingOptions" do
|
47
|
-
FileUtils.rm_f "#{tmp_path}/optionalized.mp4"
|
48
|
-
|
49
|
-
movie = Movie.new("#{fixture_path}/movies/awesome movie.mov")
|
50
|
-
options = {:video_codec => "libx264", :frame_rate => 10, :resolution => "320x240", :video_bitrate => 300,
|
51
|
-
:audio_codec => "libfaac", :audio_bitrate => 32, :audio_sample_rate => 22050, :audio_channels => 1,
|
52
|
-
:custom => "-flags +loop -cmp +chroma -partitions +parti4x4+partp8x8 -flags2 +mixed_refs -me_method umh -subq 6 -refs 6 -rc_eq 'blurCplx^(1-qComp)' -coder 0 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 21"}
|
53
|
-
|
54
|
-
encoded = Transcoder.new(movie, "#{tmp_path}/optionalized.mp4", options).run
|
55
|
-
encoded.video_codec.should == "h264"
|
56
|
-
encoded.resolution.should == "320x240"
|
57
|
-
encoded.frame_rate.should == 10.0
|
58
|
-
encoded.audio_codec.should == "aac"
|
59
|
-
encoded.audio_sample_rate.should == 22050
|
60
|
-
encoded.audio_channels.should == 1
|
61
|
-
end
|
62
|
-
|
63
|
-
describe "aspect ratio preservation" do
|
64
|
-
before(:each) do
|
65
|
-
@movie = Movie.new("#{fixture_path}/movies/awesome_widescreen.mov")
|
66
|
-
@options = {:resolution => "320x240"}
|
67
|
-
end
|
68
|
-
|
69
|
-
it "should work on width" do
|
70
|
-
special_options = {:preserve_aspect_ratio => :width}
|
71
|
-
|
72
|
-
encoded = Transcoder.new(@movie, "#{tmp_path}/preserved_aspect.mp4", @options, special_options).run
|
73
|
-
encoded.resolution.should == "320x180"
|
74
|
-
end
|
75
|
-
|
76
|
-
it "should work on height" do
|
77
|
-
special_options = {:preserve_aspect_ratio => :height}
|
78
|
-
|
79
|
-
encoded = Transcoder.new(@movie, "#{tmp_path}/preserved_aspect.mp4", @options, special_options).run
|
80
|
-
encoded.resolution.should == "426x240"
|
81
|
-
end
|
82
|
-
|
83
|
-
it "should not be used if original resolution is undeterminable" do
|
84
|
-
@movie.should_receive(:calculated_aspect_ratio).and_return(nil)
|
85
|
-
special_options = {:preserve_aspect_ratio => :height}
|
86
|
-
|
87
|
-
encoded = Transcoder.new(@movie, "#{tmp_path}/preserved_aspect.mp4", @options, special_options).run
|
88
|
-
encoded.resolution.should == "320x240"
|
89
|
-
end
|
90
|
-
|
91
|
-
it "should round to resolutions divisible by 2" do
|
92
|
-
@movie.should_receive(:calculated_aspect_ratio).at_least(:once).and_return(1.234)
|
93
|
-
special_options = {:preserve_aspect_ratio => :width}
|
94
|
-
|
95
|
-
encoded = Transcoder.new(@movie, "#{tmp_path}/preserved_aspect.mp4", @options, special_options).run
|
96
|
-
encoded.resolution.should == "320x260" # 320 / 1.234 should at first be rounded to 259
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
it "should transcode the movie with String options" do
|
101
|
-
FileUtils.rm_f "#{tmp_path}/string_optionalized.flv"
|
102
|
-
|
103
|
-
movie = Movie.new("#{fixture_path}/movies/awesome movie.mov")
|
104
|
-
|
105
|
-
encoded = Transcoder.new(movie, "#{tmp_path}/string_optionalized.flv", "-s 300x200 -ac 2").run
|
106
|
-
encoded.resolution.should == "300x200"
|
107
|
-
encoded.audio_channels.should == 2
|
108
|
-
end
|
109
|
-
|
110
|
-
it "should fail when given an invalid movie" do
|
111
|
-
FFMPEG.logger.should_receive(:error)
|
112
|
-
movie = Movie.new(__FILE__)
|
113
|
-
transcoder = Transcoder.new(movie, "#{tmp_path}/fail.flv")
|
114
|
-
lambda { transcoder.run }.should raise_error(RuntimeError, /no output file created/)
|
115
|
-
end
|
116
|
-
|
117
|
-
it "should fail if duration differs from original" do
|
118
|
-
movie = Movie.new("#{fixture_path}/sounds/napoleon.mp3")
|
119
|
-
movie.stub!(:duration).and_return(200)
|
120
|
-
movie.stub!(:uncertain_duration?).and_return(false)
|
121
|
-
transcoder = Transcoder.new(movie, "#{tmp_path}/duration_fail.flv")
|
122
|
-
lambda { transcoder.run }.should raise_error(RuntimeError, /encoded file duration differed from original/)
|
123
|
-
end
|
124
|
-
|
125
|
-
it "should skip duration check if originals duration is uncertain" do
|
126
|
-
movie = Movie.new("#{fixture_path}/sounds/napoleon.mp3")
|
127
|
-
movie.stub!(:duration).and_return(200)
|
128
|
-
movie.stub!(:uncertain_duration?).and_return(true)
|
129
|
-
transcoder = Transcoder.new(movie, "#{tmp_path}/duration_fail.flv")
|
130
|
-
lambda { transcoder.run }.should_not raise_error(RuntimeError)
|
131
|
-
end
|
132
|
-
|
133
|
-
it "should be able to transcode to images" do
|
134
|
-
movie = Movie.new("#{fixture_path}/movies/awesome movie.mov")
|
135
|
-
|
136
|
-
encoded = Transcoder.new(movie, "#{tmp_path}/image.png", :custom => "-ss 00:00:03 -vframes 1 -f image2").run
|
137
|
-
encoded.resolution.should == "640x480"
|
138
|
-
|
139
|
-
encoded = Transcoder.new(movie, "#{tmp_path}/image.jpg", :custom => "-ss 00:00:03 -vframes 1 -f image2").run
|
140
|
-
encoded.resolution.should == "640x480"
|
141
|
-
end
|
142
|
-
|
143
|
-
it "should validate duration to the specified duration if given" do
|
144
|
-
movie = Movie.new("#{fixture_path}/movies/awesome movie.mov")
|
145
|
-
|
146
|
-
encoded = Transcoder.new(movie, "#{tmp_path}/durationalized.mp4", :duration => 2).run
|
147
|
-
|
148
|
-
encoded.duration.should >= 1.8
|
149
|
-
encoded.duration.should <= 2.2
|
150
|
-
end
|
151
|
-
|
152
|
-
it "should validate duration to original movies duration if duration specified to higher number than original" do
|
153
|
-
movie = Movie.new("#{fixture_path}/movies/awesome movie.mov")
|
154
|
-
|
155
|
-
expect {
|
156
|
-
Transcoder.new(movie, "#{tmp_path}/durationalized.mp4", :duration => 10).run
|
157
|
-
}.to_not raise_error
|
158
|
-
end
|
159
|
-
end
|
160
|
-
end
|
161
|
-
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/spec/spec.opts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--color
|
data/spec/spec_helper.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
-
require 'streamio-ffmpeg'
|
4
|
-
require 'spec'
|
5
|
-
require 'spec/autorun'
|
6
|
-
require 'fileutils'
|
7
|
-
|
8
|
-
FFMPEG.logger = Logger.new(nil)
|
9
|
-
|
10
|
-
Spec::Runner.configure do |config|
|
11
|
-
end
|
12
|
-
|
13
|
-
def fixture_path
|
14
|
-
@fixture_path ||= File.join(File.dirname(__FILE__), 'fixtures')
|
15
|
-
end
|
16
|
-
|
17
|
-
def tmp_path
|
18
|
-
@tmp_path ||= File.join(File.dirname(__FILE__), "..", "tmp")
|
19
|
-
end
|
20
|
-
|
21
|
-
FileUtils.mkdir_p tmp_path
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe FFMPEG do
|
4
|
-
describe "logger" do
|
5
|
-
after(:each) do
|
6
|
-
FFMPEG.logger = Logger.new(nil)
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should be a Logger" do
|
10
|
-
FFMPEG.logger.should be_instance_of(Logger)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should be at info level" do
|
14
|
-
FFMPEG.logger = nil # Reset the logger so that we get the default
|
15
|
-
FFMPEG.logger.level.should == Logger::INFO
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should be assignable" do
|
19
|
-
new_logger = Logger.new(STDOUT)
|
20
|
-
FFMPEG.logger = new_logger
|
21
|
-
FFMPEG.logger.should == new_logger
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
data/streamio-ffmpeg.gemspec
DELETED
@@ -1,70 +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{streamio-ffmpeg}
|
8
|
-
s.version = "0.7.2"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["David Backeus"]
|
12
|
-
s.date = %q{2010-08-11}
|
13
|
-
s.description = %q{Simple wrapper around ffmpeg to get metadata from movies and do transcoding}
|
14
|
-
s.email = %q{duztdruid@gmail.com}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE",
|
17
|
-
"README.rdoc"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".document",
|
21
|
-
".gitignore",
|
22
|
-
"CHANGELOG",
|
23
|
-
"LICENSE",
|
24
|
-
"README.rdoc",
|
25
|
-
"Rakefile",
|
26
|
-
"VERSION",
|
27
|
-
"lib/ffmpeg/encoding_options.rb",
|
28
|
-
"lib/ffmpeg/movie.rb",
|
29
|
-
"lib/ffmpeg/transcoder.rb",
|
30
|
-
"lib/streamio-ffmpeg.rb",
|
31
|
-
"spec/ffmpeg/encoding_options_spec.rb",
|
32
|
-
"spec/ffmpeg/movie_spec.rb",
|
33
|
-
"spec/ffmpeg/transcoder_spec.rb",
|
34
|
-
"spec/fixtures/movies/awesome movie.mov",
|
35
|
-
"spec/fixtures/movies/awesome_widescreen.mov",
|
36
|
-
"spec/fixtures/movies/broken.mp4",
|
37
|
-
"spec/fixtures/movies/weird_aspect.small.mpg",
|
38
|
-
"spec/fixtures/sounds/napoleon.mp3",
|
39
|
-
"spec/spec.opts",
|
40
|
-
"spec/spec_helper.rb",
|
41
|
-
"spec/streamio-ffmpeg_spec.rb",
|
42
|
-
"streamio-ffmpeg.gemspec"
|
43
|
-
]
|
44
|
-
s.homepage = %q{http://github.com/streamio/streamio-ffmpeg}
|
45
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
46
|
-
s.require_paths = ["lib"]
|
47
|
-
s.rubygems_version = %q{1.3.7}
|
48
|
-
s.summary = %q{Simple wrapper around ffmpeg to get metadata from movies and do transcoding}
|
49
|
-
s.test_files = [
|
50
|
-
"spec/ffmpeg/encoding_options_spec.rb",
|
51
|
-
"spec/ffmpeg/movie_spec.rb",
|
52
|
-
"spec/ffmpeg/transcoder_spec.rb",
|
53
|
-
"spec/spec_helper.rb",
|
54
|
-
"spec/streamio-ffmpeg_spec.rb"
|
55
|
-
]
|
56
|
-
|
57
|
-
if s.respond_to? :specification_version then
|
58
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
59
|
-
s.specification_version = 3
|
60
|
-
|
61
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
62
|
-
s.add_development_dependency(%q<rspec>, ["= 1.3.0"])
|
63
|
-
else
|
64
|
-
s.add_dependency(%q<rspec>, ["= 1.3.0"])
|
65
|
-
end
|
66
|
-
else
|
67
|
-
s.add_dependency(%q<rspec>, ["= 1.3.0"])
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|