streamio-ffmpeg 0.6.2 → 0.6.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 +4 -0
- data/VERSION +1 -1
- data/lib/ffmpeg/movie.rb +9 -3
- data/lib/ffmpeg/transcoder.rb +4 -4
- data/spec/ffmpeg/movie_spec.rb +14 -0
- data/spec/fixtures/movies/weird_aspect.small.mpg +0 -0
- data/streamio-ffmpeg.gemspec +2 -1
- metadata +3 -2
data/CHANGELOG
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.3
|
data/lib/ffmpeg/movie.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module FFMPEG
|
2
2
|
class Movie
|
3
3
|
attr_reader :path, :duration, :bitrate
|
4
|
-
attr_reader :video_stream, :video_codec, :colorspace, :resolution
|
4
|
+
attr_reader :video_stream, :video_codec, :colorspace, :resolution, :dar
|
5
5
|
attr_reader :audio_stream, :audio_codec, :audio_sample_rate
|
6
6
|
|
7
7
|
def initialize(path)
|
@@ -29,6 +29,7 @@ module FFMPEG
|
|
29
29
|
if video_stream
|
30
30
|
@video_codec, @colorspace, resolution = video_stream.split(/\s?,\s?/)
|
31
31
|
@resolution = resolution.split(" ").first # get rid of [PAR 1:1 DAR 16:9]
|
32
|
+
@dar = $1 if video_stream[/DAR (\d+:\d+)/]
|
32
33
|
end
|
33
34
|
|
34
35
|
if audio_stream
|
@@ -56,8 +57,13 @@ module FFMPEG
|
|
56
57
|
end
|
57
58
|
|
58
59
|
def calculated_aspect_ratio
|
59
|
-
|
60
|
-
|
60
|
+
if dar
|
61
|
+
width, height = dar.split(":")
|
62
|
+
width.to_f / height.to_f
|
63
|
+
else
|
64
|
+
aspect = width.to_f / height.to_f
|
65
|
+
aspect.nan? ? nil : aspect
|
66
|
+
end
|
61
67
|
end
|
62
68
|
|
63
69
|
def audio_channels
|
data/lib/ffmpeg/transcoder.rb
CHANGED
@@ -22,7 +22,7 @@ module FFMPEG
|
|
22
22
|
|
23
23
|
def run
|
24
24
|
command = "ffmpeg -y -i '#{@movie.path}' #{@raw_options} '#{@output_file}'"
|
25
|
-
FFMPEG.logger.info("Running transcoding...\n#{command}")
|
25
|
+
FFMPEG.logger.info("Running transcoding...\n#{command}\n")
|
26
26
|
output = ""
|
27
27
|
last_output = nil
|
28
28
|
Open3.popen3(command) do |stdin, stdout, stderr|
|
@@ -34,7 +34,7 @@ module FFMPEG
|
|
34
34
|
yield(progress) if block_given?
|
35
35
|
end
|
36
36
|
if line =~ /Unsupported codec/
|
37
|
-
FFMPEG.logger.error "Failed encoding...\nCommand\n#{command}\nOutput\n#{output}"
|
37
|
+
FFMPEG.logger.error "Failed encoding...\nCommand\n#{command}\nOutput\n#{output}\n"
|
38
38
|
raise "Failed encoding: #{line}"
|
39
39
|
end
|
40
40
|
last_output = line
|
@@ -42,11 +42,11 @@ module FFMPEG
|
|
42
42
|
end
|
43
43
|
|
44
44
|
if encoding_succeeded?
|
45
|
-
FFMPEG.logger.info "Transcoding of #{@movie.path} to #{@output_file} succeeded"
|
45
|
+
FFMPEG.logger.info "Transcoding of #{@movie.path} to #{@output_file} succeeded\n"
|
46
46
|
yield(1.0) if block_given?
|
47
47
|
else
|
48
48
|
errors = @errors.empty? ? "" : "Errors: #{@errors.join(", ")}"
|
49
|
-
FFMPEG.logger.error "Failed encoding...\n#{command}\n\n#{output}\n#{errors}"
|
49
|
+
FFMPEG.logger.error "Failed encoding...\n#{command}\n\n#{output}\n#{errors}\n"
|
50
50
|
raise "Failed encoding. Last output: #{last_output}. #{errors}"
|
51
51
|
end
|
52
52
|
|
data/spec/ffmpeg/movie_spec.rb
CHANGED
@@ -44,6 +44,20 @@ module FFMPEG
|
|
44
44
|
end
|
45
45
|
end
|
46
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.should == "1.73827160493827"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
47
61
|
describe "given an awesome movie file" do
|
48
62
|
before(:all) do
|
49
63
|
@movie = Movie.new("#{fixture_path}/movies/awesome movie.mov")
|
Binary file
|
data/streamio-ffmpeg.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{streamio-ffmpeg}
|
8
|
-
s.version = "0.6.
|
8
|
+
s.version = "0.6.3"
|
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"]
|
@@ -34,6 +34,7 @@ Gem::Specification.new do |s|
|
|
34
34
|
"spec/fixtures/movies/awesome movie.mov",
|
35
35
|
"spec/fixtures/movies/awesome_widescreen.mov",
|
36
36
|
"spec/fixtures/movies/broken.mp4",
|
37
|
+
"spec/fixtures/movies/weird_aspect.small.mpg",
|
37
38
|
"spec/fixtures/sounds/napoleon.mp3",
|
38
39
|
"spec/spec.opts",
|
39
40
|
"spec/spec_helper.rb",
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 6
|
8
|
-
-
|
9
|
-
version: 0.6.
|
8
|
+
- 3
|
9
|
+
version: 0.6.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- David Backeus
|
@@ -58,6 +58,7 @@ files:
|
|
58
58
|
- spec/fixtures/movies/awesome movie.mov
|
59
59
|
- spec/fixtures/movies/awesome_widescreen.mov
|
60
60
|
- spec/fixtures/movies/broken.mp4
|
61
|
+
- spec/fixtures/movies/weird_aspect.small.mpg
|
61
62
|
- spec/fixtures/sounds/napoleon.mp3
|
62
63
|
- spec/spec.opts
|
63
64
|
- spec/spec_helper.rb
|