streamio-ffmpeg 0.7.4 → 0.7.5

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.5 2011-01-14
2
+
3
+ * Fixed some ruby 1.9 issues
4
+ * Added Movie#video_bitrate and Movie#audio_bitrate (thanks to mbj)
5
+
1
6
  == 0.7.4 2010-12-07
2
7
 
3
8
  * Fixed broken duration on movies with start times over 0 by reducing duration with start-time
data/lib/ffmpeg/movie.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  module FFMPEG
2
2
  class Movie
3
3
  attr_reader :path, :duration, :time, :bitrate
4
- attr_reader :video_stream, :video_codec, :colorspace, :resolution, :dar
5
- attr_reader :audio_stream, :audio_codec, :audio_sample_rate
4
+ attr_reader :video_stream, :video_codec, :video_bitrate, :colorspace, :resolution, :dar
5
+ attr_reader :audio_stream, :audio_codec, :audio_bitrate, :audio_sample_rate
6
6
 
7
7
  def initialize(path)
8
8
  raise Errno::ENOENT, "the file '#{path}' does not exist" unless File.exists?(path)
@@ -12,6 +12,8 @@ module FFMPEG
12
12
  stdin, stdout, stderr = Open3.popen3("ffmpeg -i '#{path}'") # Output will land in stderr
13
13
  output = stderr.read
14
14
 
15
+ fix_encoding(output)
16
+
15
17
  output[/Duration: (\d{2}):(\d{2}):(\d{2}\.\d{1})/]
16
18
  @duration = ($1.to_i*60*60) + ($2.to_i*60) + $3.to_f
17
19
 
@@ -32,13 +34,15 @@ module FFMPEG
32
34
  @uncertain_duration = output.include?("Estimating duration from bitrate, this may be inaccurate")
33
35
 
34
36
  if video_stream
35
- @video_codec, @colorspace, resolution = video_stream.split(/\s?,\s?/)
37
+ @video_codec, @colorspace, resolution, video_bitrate = video_stream.split(/\s?,\s?/)
38
+ @video_bitrate = video_bitrate =~ %r(\A(\d+) kb/s\Z) ? $1.to_i : nil
36
39
  @resolution = resolution.split(" ").first rescue nil # get rid of [PAR 1:1 DAR 16:9]
37
40
  @dar = $1 if video_stream[/DAR (\d+:\d+)/]
38
41
  end
39
42
 
40
43
  if audio_stream
41
- @audio_codec, audio_sample_rate, @audio_channels = audio_stream.split(/\s?,\s?/)
44
+ @audio_codec, audio_sample_rate, @audio_channels, unused, audio_bitrate = audio_stream.split(/\s?,\s?/)
45
+ @audio_bitrate = audio_bitrate =~ %r(\A(\d+) kb/s\Z) ? $1.to_i : nil
42
46
  @audio_sample_rate = audio_sample_rate[/\d*/].to_i
43
47
  end
44
48
 
@@ -94,5 +98,11 @@ module FFMPEG
94
98
  map = { '\\' => '\\\\', '</' => '<\/', "\r\n" => '\n', "\n" => '\n', "\r" => '\n', '"' => '\\"', "'" => "\\'" }
95
99
  path.gsub(/(\\|<\/|\r\n|[\n\r"'])/) { map[$1] }
96
100
  end
101
+
102
+ def fix_encoding(output)
103
+ output[/test/] # Running a regexp on the string throws error if it's not UTF-8
104
+ rescue ArgumentError
105
+ output.force_encoding("ISO-8859-1")
106
+ end
97
107
  end
98
108
  end
@@ -99,6 +99,7 @@ module FFMPEG
99
99
  def validate_duration?
100
100
  return false if @movie.uncertain_duration?
101
101
  return false if %w(.jpg .png).include?(File.extname(@output_file))
102
+ return false if @raw_options.is_a?(String)
102
103
  true
103
104
  end
104
105
  end
@@ -1,3 +1,3 @@
1
1
  module FFMPEG
2
- VERSION = "0.7.4"
2
+ VERSION = "0.7.5"
3
3
  end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: streamio-ffmpeg
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 7
9
- - 4
10
- version: 0.7.4
8
+ - 5
9
+ version: 0.7.5
11
10
  platform: ruby
12
11
  authors:
13
12
  - David Backeus
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-12-07 00:00:00 +01:00
17
+ date: 2011-01-14 00:00:00 +01:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
@@ -26,7 +25,6 @@ dependencies:
26
25
  requirements:
27
26
  - - "="
28
27
  - !ruby/object:Gem::Version
29
- hash: 27
30
28
  segments:
31
29
  - 1
32
30
  - 3
@@ -66,7 +64,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
66
64
  requirements:
67
65
  - - ">="
68
66
  - !ruby/object:Gem::Version
69
- hash: 3
70
67
  segments:
71
68
  - 0
72
69
  version: "0"
@@ -75,7 +72,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
72
  requirements:
76
73
  - - ">="
77
74
  - !ruby/object:Gem::Version
78
- hash: 23
79
75
  segments:
80
76
  - 1
81
77
  - 3