streamio-ffmpeg 3.0.1 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d040320bc3f959563977e37be82de8c7dcc0b6dd
4
- data.tar.gz: f3074b7953107d34c7560efc1be4ae5ab104341d
3
+ metadata.gz: 08518b33cf87b6865e01d8b69f7f0cd00cbd97c4
4
+ data.tar.gz: 790f1693d24204bc9e666d1c9ea8d78fea404edd
5
5
  SHA512:
6
- metadata.gz: aedc131eef3f61197c5db195f8ed3f22dbd8dff133b47f8b3cdfc9c1c64640fee671cb087011e27a3d795e95d7764d431c6212ebcd763f0fa09c993a6de8bafe
7
- data.tar.gz: 0ceaeb9d374541e9de8d1b70623632913ff69d60a39c8482fe7a28cc9a56be5bd983a7fa4414117045791355ebd7a2aa1a6bdf402a7b76b2571c0b068b31174c
6
+ metadata.gz: 57178e111057a58fe46314656a9d7da0c2060b70d6d03b54972d600fb086bfb07495d7628ac0158cdfbe336d58b61547c6b162888787e41b2b1dc4a41e28385b
7
+ data.tar.gz: fb5c8b00b1906ecd7790a42cba66acf9baf699e2137d62a3dc68f6696219933e6ab7dc17f8051300418f69a7c38ee955ddc76b9dc3cc8c249d2802d2ef3d4281
data/CHANGELOG CHANGED
@@ -1,6 +1,12 @@
1
1
  == Master
2
2
 
3
- Current with 3.0.1
3
+ Current with 3.0.2
4
+
5
+ == 3.0.2 2016-11-18
6
+
7
+ Improvements:
8
+ * Issue #153 Adds support for multiple audio streams
9
+ * Issue #150 Does not trust reported SAR/DAR as these may not be defined per https://trac.ffmpeg.org/ticket/3798
4
10
 
5
11
  == 3.0.1 2016-11-10
6
12
 
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
1
  Streamio FFMPEG
2
2
  ===============
3
3
 
4
- [![Code Climate](https://codeclimate.com/github/streamio/streamio-ffmpeg/badges/gpa.svg)](https://codeclimate.com/github/streamio/streamio-ffmpeg)
4
+ [![Build Status](https://travis-ci.org/bikeath1337/streamio-ffmpeg.svg?branch=master)](https://travis-ci.org/bikeath1337/streamio-ffmpeg)
5
+ [![Code Climate](https://codeclimate.com/github/bikeath1337/streamio-ffmpeg/badges/gpa.svg)](https://codeclimate.com/github/bikeath1337/streamio-ffmpeg)
6
+ [![Test Coverage](https://codeclimate.com/github/bikeath1337/streamio-ffmpeg/badges/coverage.svg)](https://codeclimate.com/github/bikeath1337/streamio-ffmpeg/coverage)
5
7
 
6
8
  Simple yet powerful wrapper around the ffmpeg command for reading metadata and transcoding movies.
7
9
 
@@ -62,6 +64,9 @@ movie.audio_codec # "aac"
62
64
  movie.audio_sample_rate # 44100
63
65
  movie.audio_channels # 2
64
66
 
67
+ # Multiple audio streams
68
+ movie.audio_streams[0] # "aac, 44100 Hz, stereo, s16, 75 kb/s" (raw audio stream info)
69
+
65
70
  movie.valid? # true (would be false if ffmpeg fails to read the movie)
66
71
  ```
67
72
 
@@ -6,7 +6,7 @@ module FFMPEG
6
6
  class Movie
7
7
  attr_reader :path, :duration, :time, :bitrate, :rotation, :creation_time
8
8
  attr_reader :video_stream, :video_codec, :video_bitrate, :colorspace, :width, :height, :sar, :dar, :frame_rate
9
- attr_reader :audio_stream, :audio_codec, :audio_bitrate, :audio_sample_rate, :audio_channels
9
+ attr_reader :audio_streams, :audio_stream, :audio_codec, :audio_bitrate, :audio_sample_rate, :audio_channels, :audio_tags
10
10
  attr_reader :container
11
11
  attr_reader :metadata, :format_tags
12
12
 
@@ -97,15 +97,28 @@ module FFMPEG
97
97
  end
98
98
  end
99
99
 
100
- # TODO: Handle multiple audio codecs
101
- audio_stream = audio_streams.first
100
+ @audio_streams = audio_streams.map do |stream|
101
+ {
102
+ :index => stream[:index],
103
+ :channels => stream[:channels].to_i,
104
+ :codec_name => stream[:codec_name],
105
+ :sample_rate => stream[:sample_rate].to_i,
106
+ :bitrate => stream[:bit_rate].to_i,
107
+ :channel_layout => stream[:channel_layout],
108
+ :tags => stream[:streams],
109
+ :overview => "#{stream[:codec_name]} (#{stream[:codec_tag_string]} / #{stream[:codec_tag]}), #{stream[:sample_rate]} Hz, #{stream[:channel_layout]}, #{stream[:sample_fmt]}, #{stream[:bit_rate]} bit/s"
110
+ }
111
+ end
112
+
113
+ audio_stream = @audio_streams.first
102
114
  unless audio_stream.nil?
103
- @audio_channels = audio_stream[:channels].to_i
115
+ @audio_channels = audio_stream[:channels]
104
116
  @audio_codec = audio_stream[:codec_name]
105
- @audio_sample_rate = audio_stream[:sample_rate].to_i
106
- @audio_bitrate = audio_stream[:bit_rate].to_i
117
+ @audio_sample_rate = audio_stream[:sample_rate]
118
+ @audio_bitrate = audio_stream[:bitrate]
107
119
  @audio_channel_layout = audio_stream[:channel_layout]
108
- @audio_stream = "#{audio_codec} (#{audio_stream[:codec_tag_string]} / #{audio_stream[:codec_tag]}), #{audio_sample_rate} Hz, #{audio_channel_layout}, #{audio_stream[:sample_fmt]}, #{audio_bitrate} bit/s"
120
+ @audio_tags = audio_stream[:audio_tags]
121
+ @audio_stream = audio_stream[:overview]
109
122
  end
110
123
 
111
124
  end
@@ -193,17 +206,18 @@ module FFMPEG
193
206
 
194
207
  protected
195
208
  def aspect_from_dar
196
- return nil unless dar
197
- w, h = dar.split(":")
198
- aspect = (@rotation==nil) || (@rotation==180)? (w.to_f / h.to_f):(h.to_f / w.to_f)
199
- aspect.zero? ? nil : aspect
209
+ calculate_aspect(dar)
200
210
  end
201
211
 
202
212
  def aspect_from_sar
203
- return nil unless sar
204
- w, h = sar.split(":")
205
- aspect = (@rotation==nil) || (@rotation==180)? (w.to_f / h.to_f):(h.to_f / w.to_f)
206
- aspect.zero? ? nil : aspect
213
+ calculate_aspect(sar)
214
+ end
215
+
216
+ def calculate_aspect(ratio)
217
+ return nil unless ratio
218
+ w, h = ratio.split(':')
219
+ return nil if w == '0' || h == '0'
220
+ @rotation.nil? || (@rotation == 180) ? (w.to_f / h.to_f) : (h.to_f / w.to_f)
207
221
  end
208
222
 
209
223
  def aspect_from_dimensions
@@ -1,3 +1,3 @@
1
1
  module FFMPEG
2
- VERSION = '3.0.1'
2
+ VERSION = '3.0.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: streamio-ffmpeg
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rackfish AB
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-11 00:00:00.000000000 Z
11
+ date: 2016-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json