streamio-ffmpeg 0.4.3 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +6 -2
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/ffmpeg/transcoder.rb +8 -1
- data/lib/streamio-ffmpeg.rb +23 -2
- data/spec/ffmpeg/transcoder_spec.rb +5 -0
- data/spec/spec_helper.rb +3 -2
- data/spec/stremio-ffmpeg_spec.rb +24 -0
- data/streamio-ffmpeg.gemspec +6 -4
- metadata +7 -5
data/CHANGELOG
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
-
== 0.
|
1
|
+
== 0.5.0 2010-04-28
|
2
|
+
|
3
|
+
* Added logging capabilities
|
4
|
+
|
5
|
+
== 0.4.3 2010-04-06
|
2
6
|
|
3
7
|
* Correctly identify invalid movies on latest ffmpeg build (r22811)
|
4
8
|
|
5
|
-
== 0.4.2
|
9
|
+
== 0.4.2 2010-04-06
|
6
10
|
|
7
11
|
* Escape the path to handle spaces in filenames and avoid CLI injection attacks (thanks J. Weir!)
|
8
12
|
|
data/Rakefile
CHANGED
@@ -8,7 +8,7 @@ begin
|
|
8
8
|
gem.summary = %Q{Simple wrapper around ffmpeg to get metadata from movies and do transcoding}
|
9
9
|
gem.description = %Q{Simple wrapper around ffmpeg to get metadata from movies and do transcoding}
|
10
10
|
gem.email = "duztdruid@gmail.com"
|
11
|
-
gem.homepage = "http://github.com/
|
11
|
+
gem.homepage = "http://github.com/streamio/streamio-ffmpeg"
|
12
12
|
gem.authors = ["David Backeus"]
|
13
13
|
gem.add_development_dependency "rspec", ">= 1.2.9"
|
14
14
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
data/lib/ffmpeg/transcoder.rb
CHANGED
@@ -19,15 +19,19 @@ module FFMPEG
|
|
19
19
|
|
20
20
|
def run
|
21
21
|
command = "ffmpeg -y -i '#{@movie.path}' #{@raw_options} '#{@output_file}'"
|
22
|
+
FFMPEG.logger.info("Running transcoding...\n#{command}")
|
23
|
+
output = ""
|
22
24
|
last_output = nil
|
23
25
|
Open3.popen3(command) do |stdin, stdout, stderr|
|
24
26
|
stderr.each("r") do |line|
|
27
|
+
output << line
|
25
28
|
if line =~ /time=(\d+.\d+)/
|
26
29
|
time = $1.to_f
|
27
30
|
progress = time / @movie.duration
|
28
31
|
yield(progress) if block_given?
|
29
32
|
end
|
30
33
|
if line =~ /Unsupported codec/
|
34
|
+
FFMPEG.logger.error "Failed encoding...\nCommand\n#{command}\nOutput\n#{output}"
|
31
35
|
raise "Failed encoding: #{line}"
|
32
36
|
end
|
33
37
|
last_output = line
|
@@ -35,9 +39,12 @@ module FFMPEG
|
|
35
39
|
end
|
36
40
|
|
37
41
|
if encoding_succeeded?
|
42
|
+
FFMPEG.logger.info "Transcoding of #{@movie.path} to #{@output_file} succeeded"
|
38
43
|
yield(1.0) if block_given?
|
39
44
|
else
|
40
|
-
|
45
|
+
errors = @errors.empty? ? "" : "Errors: #{@errors.join(", ")}"
|
46
|
+
FFMPEG.logger.error "Failed encoding...\n#{command}\n\n#{output}\n#{errors}"
|
47
|
+
raise "Failed encoding. Last output: #{last_output}. #{errors}"
|
41
48
|
end
|
42
49
|
|
43
50
|
encoded
|
data/lib/streamio-ffmpeg.rb
CHANGED
@@ -1,9 +1,30 @@
|
|
1
1
|
$LOAD_PATH.unshift File.dirname(__FILE__)
|
2
2
|
|
3
|
+
require 'logger'
|
4
|
+
|
3
5
|
require 'ffmpeg/movie'
|
4
6
|
require 'ffmpeg/transcoder'
|
5
7
|
require 'ffmpeg/encoding_options'
|
6
8
|
|
7
9
|
module FFMPEG
|
8
|
-
VERSION = '0.
|
9
|
-
|
10
|
+
VERSION = '0.5.0'
|
11
|
+
|
12
|
+
# FFMPEG logs information about its progress when it's transcoding.
|
13
|
+
# Jack in your own logger through this method if you wish to.
|
14
|
+
#
|
15
|
+
# @param [Logger] log your own logger
|
16
|
+
# @return [Logger] the logger you set
|
17
|
+
def self.logger=(log)
|
18
|
+
@logger = log
|
19
|
+
end
|
20
|
+
|
21
|
+
# Get FFMPEG logger.
|
22
|
+
#
|
23
|
+
# @return [Logger]
|
24
|
+
def self.logger
|
25
|
+
return @logger if @logger
|
26
|
+
logger = Logger.new(STDOUT)
|
27
|
+
logger.level = Logger::INFO
|
28
|
+
@logger = logger
|
29
|
+
end
|
30
|
+
end
|
@@ -26,6 +26,10 @@ module FFMPEG
|
|
26
26
|
end
|
27
27
|
|
28
28
|
describe "transcoding" do
|
29
|
+
before(:each) do
|
30
|
+
FFMPEG.logger.should_receive(:info).at_least(:once)
|
31
|
+
end
|
32
|
+
|
29
33
|
it "should transcode the movie with progress given an awesome movie" do
|
30
34
|
FileUtils.rm_f "#{tmp_path}/awesome.flv"
|
31
35
|
|
@@ -67,6 +71,7 @@ module FFMPEG
|
|
67
71
|
end
|
68
72
|
|
69
73
|
it "should fail when given an invalid movie" do
|
74
|
+
FFMPEG.logger.should_receive(:error)
|
70
75
|
movie = Movie.new(__FILE__)
|
71
76
|
transcoder = Transcoder.new(movie, "#{tmp_path}/fail.flv")
|
72
77
|
lambda { transcoder.run }.should raise_error(RuntimeError, /no output file created/)
|
data/spec/spec_helper.rb
CHANGED
@@ -5,8 +5,9 @@ require 'spec'
|
|
5
5
|
require 'spec/autorun'
|
6
6
|
require 'fileutils'
|
7
7
|
|
8
|
+
FFMPEG.logger = Logger.new(nil)
|
9
|
+
|
8
10
|
Spec::Runner.configure do |config|
|
9
|
-
|
10
11
|
end
|
11
12
|
|
12
13
|
def fixture_path
|
@@ -17,4 +18,4 @@ def tmp_path
|
|
17
18
|
@tmp_path ||= File.join(File.dirname(__FILE__), "..", "tmp")
|
18
19
|
end
|
19
20
|
|
20
|
-
FileUtils.mkdir_p tmp_path
|
21
|
+
FileUtils.mkdir_p tmp_path
|
@@ -0,0 +1,24 @@
|
|
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
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{streamio-ffmpeg}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.5.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["David Backeus"]
|
12
|
-
s.date = %q{2010-04-
|
12
|
+
s.date = %q{2010-04-28}
|
13
13
|
s.description = %q{Simple wrapper around ffmpeg to get metadata from movies and do transcoding}
|
14
14
|
s.email = %q{duztdruid@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -34,9 +34,10 @@ Gem::Specification.new do |s|
|
|
34
34
|
"spec/fixtures/movies/awesome movie.mov",
|
35
35
|
"spec/spec.opts",
|
36
36
|
"spec/spec_helper.rb",
|
37
|
+
"spec/stremio-ffmpeg_spec.rb",
|
37
38
|
"streamio-ffmpeg.gemspec"
|
38
39
|
]
|
39
|
-
s.homepage = %q{http://github.com/
|
40
|
+
s.homepage = %q{http://github.com/streamio/streamio-ffmpeg}
|
40
41
|
s.rdoc_options = ["--charset=UTF-8"]
|
41
42
|
s.require_paths = ["lib"]
|
42
43
|
s.rubygems_version = %q{1.3.6}
|
@@ -45,7 +46,8 @@ Gem::Specification.new do |s|
|
|
45
46
|
"spec/ffmpeg/encoding_options_spec.rb",
|
46
47
|
"spec/ffmpeg/movie_spec.rb",
|
47
48
|
"spec/ffmpeg/transcoder_spec.rb",
|
48
|
-
"spec/spec_helper.rb"
|
49
|
+
"spec/spec_helper.rb",
|
50
|
+
"spec/stremio-ffmpeg_spec.rb"
|
49
51
|
]
|
50
52
|
|
51
53
|
if s.respond_to? :specification_version then
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 5
|
8
|
+
- 0
|
9
|
+
version: 0.5.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- David Backeus
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-28 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -58,9 +58,10 @@ files:
|
|
58
58
|
- spec/fixtures/movies/awesome movie.mov
|
59
59
|
- spec/spec.opts
|
60
60
|
- spec/spec_helper.rb
|
61
|
+
- spec/stremio-ffmpeg_spec.rb
|
61
62
|
- streamio-ffmpeg.gemspec
|
62
63
|
has_rdoc: true
|
63
|
-
homepage: http://github.com/
|
64
|
+
homepage: http://github.com/streamio/streamio-ffmpeg
|
64
65
|
licenses: []
|
65
66
|
|
66
67
|
post_install_message:
|
@@ -94,3 +95,4 @@ test_files:
|
|
94
95
|
- spec/ffmpeg/movie_spec.rb
|
95
96
|
- spec/ffmpeg/transcoder_spec.rb
|
96
97
|
- spec/spec_helper.rb
|
98
|
+
- spec/stremio-ffmpeg_spec.rb
|