streamio-ffmpeg 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ == 0.7.2 2010-08-11
2
+
3
+ * Added encoding option duration
4
+ * Avoid crashing when ffmpeg can't find resolution of a movie
5
+
1
6
  == 0.7.1 2010-07-08
2
7
 
3
8
  * Make sure preset parameters are always put last to avoid them ending up before any codec assignments
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.1
1
+ 0.7.2
@@ -112,6 +112,10 @@ module FFMPEG
112
112
  "-threads #{value}"
113
113
  end
114
114
 
115
+ def convert_duration(value)
116
+ "-t #{value}"
117
+ end
118
+
115
119
  def convert_video_preset(value)
116
120
  "-vpre #{value}"
117
121
  end
@@ -28,7 +28,7 @@ module FFMPEG
28
28
 
29
29
  if video_stream
30
30
  @video_codec, @colorspace, resolution = video_stream.split(/\s?,\s?/)
31
- @resolution = resolution.split(" ").first # get rid of [PAR 1:1 DAR 16:9]
31
+ @resolution = resolution.split(" ").first rescue nil # get rid of [PAR 1:1 DAR 16:9]
32
32
  @dar = $1 if video_stream[/DAR (\d+:\d+)/]
33
33
  end
34
34
 
@@ -65,9 +65,10 @@ module FFMPEG
65
65
  end
66
66
 
67
67
  if validate_duration?
68
- precision = 1.1
69
- unless !(encoded.duration >= (@movie.duration * precision) or encoded.duration <= (@movie.duration / precision))
70
- @errors << "encoded file duration differed from original (original: #{@movie.duration}sec, encoded: #{encoded.duration}sec)"
68
+ precision = @raw_options[:duration] ? 1.5 : 1.1
69
+ desired_duration = @raw_options[:duration] && @raw_options[:duration] < @movie.duration ? @raw_options[:duration] : @movie.duration
70
+ if (encoded.duration >= (desired_duration * precision) or encoded.duration <= (desired_duration / precision))
71
+ @errors << "encoded file duration differed from original/specified duration (wanted: #{desired_duration}sec, got: #{encoded.duration}sec)"
71
72
  return false
72
73
  end
73
74
  end
@@ -90,6 +90,10 @@ module FFMPEG
90
90
  EncodingOptions.new(:threads => 2).to_s.should == "-threads 2"
91
91
  end
92
92
 
93
+ it "should convert duration" do
94
+ EncodingOptions.new(:duration => 30).to_s.should == "-t 30"
95
+ end
96
+
93
97
  it "should convert video preset" do
94
98
  EncodingOptions.new(:video_preset => "max").to_s.should == "-vpre max"
95
99
  end
@@ -139,6 +139,23 @@ module FFMPEG
139
139
  encoded = Transcoder.new(movie, "#{tmp_path}/image.jpg", :custom => "-ss 00:00:03 -vframes 1 -f image2").run
140
140
  encoded.resolution.should == "640x480"
141
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
142
159
  end
143
160
  end
144
161
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{streamio-ffmpeg}
8
- s.version = "0.7.1"
8
+ s.version = "0.7.2"
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-07-08}
12
+ s.date = %q{2010-08-11}
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 = [
@@ -38,7 +38,7 @@ Gem::Specification.new do |s|
38
38
  "spec/fixtures/sounds/napoleon.mp3",
39
39
  "spec/spec.opts",
40
40
  "spec/spec_helper.rb",
41
- "spec/stremio-ffmpeg_spec.rb",
41
+ "spec/streamio-ffmpeg_spec.rb",
42
42
  "streamio-ffmpeg.gemspec"
43
43
  ]
44
44
  s.homepage = %q{http://github.com/streamio/streamio-ffmpeg}
@@ -51,7 +51,7 @@ Gem::Specification.new do |s|
51
51
  "spec/ffmpeg/movie_spec.rb",
52
52
  "spec/ffmpeg/transcoder_spec.rb",
53
53
  "spec/spec_helper.rb",
54
- "spec/stremio-ffmpeg_spec.rb"
54
+ "spec/streamio-ffmpeg_spec.rb"
55
55
  ]
56
56
 
57
57
  if s.respond_to? :specification_version then
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: 1
4
+ hash: 7
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
- - 1
10
- version: 0.7.1
9
+ - 2
10
+ version: 0.7.2
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-07-08 00:00:00 +02:00
18
+ date: 2010-08-11 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -65,7 +65,7 @@ files:
65
65
  - spec/fixtures/sounds/napoleon.mp3
66
66
  - spec/spec.opts
67
67
  - spec/spec_helper.rb
68
- - spec/stremio-ffmpeg_spec.rb
68
+ - spec/streamio-ffmpeg_spec.rb
69
69
  - streamio-ffmpeg.gemspec
70
70
  has_rdoc: true
71
71
  homepage: http://github.com/streamio/streamio-ffmpeg
@@ -106,4 +106,4 @@ test_files:
106
106
  - spec/ffmpeg/movie_spec.rb
107
107
  - spec/ffmpeg/transcoder_spec.rb
108
108
  - spec/spec_helper.rb
109
- - spec/stremio-ffmpeg_spec.rb
109
+ - spec/streamio-ffmpeg_spec.rb