streamio-ffmpeg 0.8.4 → 0.8.5

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 CHANGED
@@ -1,3 +1,8 @@
1
+ == 0.8.5 2011-03-05
2
+
3
+ * If a clip has a DAR that doesn't make sense fall back to calculating aspect ratio from dimensions
4
+ * Allow filenames with single quote characters (thanks to youpy)
5
+
1
6
  == 0.8.4 2011-11-30
2
7
 
3
8
  * Duration now one decimal more accurate (thanks to Russel Brooks)
data/lib/ffmpeg/movie.rb CHANGED
@@ -7,7 +7,7 @@ module FFMPEG
7
7
  def initialize(path)
8
8
  raise Errno::ENOENT, "the file '#{path}' does not exist" unless File.exists?(path)
9
9
 
10
- @path = escape(path)
10
+ @path = path
11
11
 
12
12
  stdin, stdout, stderr = Open3.popen3("#{FFMPEG.ffmpeg_binary} -i '#{path}'") # Output will land in stderr
13
13
  output = stderr.read
@@ -65,13 +65,7 @@ module FFMPEG
65
65
  end
66
66
 
67
67
  def calculated_aspect_ratio
68
- if dar
69
- w, h = dar.split(":")
70
- w.to_f / h.to_f
71
- else
72
- aspect = width.to_f / height.to_f
73
- aspect.nan? ? nil : aspect
74
- end
68
+ aspect_from_dar || aspect_from_dimensions
75
69
  end
76
70
 
77
71
  def size
@@ -95,9 +89,16 @@ module FFMPEG
95
89
  end
96
90
 
97
91
  protected
98
- def escape(path)
99
- map = { '\\' => '\\\\', '</' => '<\/', "\r\n" => '\n', "\n" => '\n', "\r" => '\n', '"' => '\\"', "'" => "\\'" }
100
- path.gsub(/(\\|<\/|\r\n|[\n\r"'])/) { map[$1] }
92
+ def aspect_from_dar
93
+ return nil unless dar
94
+ w, h = dar.split(":")
95
+ aspect = w.to_f / h.to_f
96
+ aspect.zero? ? nil : aspect
97
+ end
98
+
99
+ def aspect_from_dimensions
100
+ aspect = width.to_f / height.to_f
101
+ aspect.nan? ? nil : aspect
101
102
  end
102
103
 
103
104
  def fix_encoding(output)
@@ -1,4 +1,5 @@
1
1
  require 'open3'
2
+ require 'shellwords'
2
3
 
3
4
  module FFMPEG
4
5
  class Transcoder
@@ -23,7 +24,7 @@ module FFMPEG
23
24
  # ffmpeg < 0.8: frame= 413 fps= 48 q=31.0 size= 2139kB time=16.52 bitrate=1060.6kbits/s
24
25
  # ffmpeg >= 0.8: frame= 4855 fps= 46 q=31.0 size= 45306kB time=00:02:42.28 bitrate=2287.0kbits/
25
26
  def run
26
- command = "#{FFMPEG.ffmpeg_binary} -y -i '#{@movie.path}' #{@raw_options} '#{@output_file}'"
27
+ command = "#{FFMPEG.ffmpeg_binary} -y -i #{Shellwords.escape(@movie.path)} #{@raw_options} '#{@output_file}'"
27
28
  FFMPEG.logger.info("Running transcoding...\n#{command}\n")
28
29
  output = ""
29
30
  last_output = nil
@@ -1,3 +1,3 @@
1
1
  module FFMPEG
2
- VERSION = "0.8.4"
2
+ VERSION = "0.8.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: streamio-ffmpeg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.4
4
+ version: 0.8.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-30 00:00:00.000000000 Z
12
+ date: 2012-03-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70109521076240 !ruby/object:Gem::Requirement
16
+ requirement: &70155720045540 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '2.7'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70109521076240
24
+ version_requirements: *70155720045540
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &70109521075560 !ruby/object:Gem::Requirement
27
+ requirement: &70155720044980 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: 0.9.2
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70109521075560
35
+ version_requirements: *70155720044980
36
36
  description: Simple yet powerful wrapper around ffmpeg to get metadata from movies
37
37
  and do transcoding.
38
38
  email:
@@ -63,7 +63,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
63
63
  version: '0'
64
64
  segments:
65
65
  - 0
66
- hash: -2761617016111549392
66
+ hash: -4488954591217010798
67
67
  required_rubygems_version: !ruby/object:Gem::Requirement
68
68
  none: false
69
69
  requirements:
@@ -72,10 +72,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
72
  version: '0'
73
73
  segments:
74
74
  - 0
75
- hash: -2761617016111549392
75
+ hash: -4488954591217010798
76
76
  requirements: []
77
77
  rubyforge_project:
78
- rubygems_version: 1.8.10
78
+ rubygems_version: 1.8.17
79
79
  signing_key:
80
80
  specification_version: 3
81
81
  summary: Reads metadata and transcodes movies.