Class: Wavesync::FFMPEG::Probe
- Inherits:
-
Object
- Object
- Wavesync::FFMPEG::Probe
- Defined in:
- lib/wavesync/ffmpeg/probe.rb
Instance Method Summary collapse
-
#bit_depth ⇒ Object
: () -> Integer?.
-
#bitrate ⇒ Object
: () -> Integer?.
-
#duration ⇒ Object
: () -> Float.
-
#initialize(file_path) ⇒ Probe
constructor
: (String file_path) -> void.
-
#sample_rate ⇒ Object
: () -> Integer?.
-
#tags ⇒ Object
: () -> Hash[String, String].
Constructor Details
#initialize(file_path) ⇒ Probe
: (String file_path) -> void
11 12 13 |
# File 'lib/wavesync/ffmpeg/probe.rb', line 11 def initialize(file_path) @file_path = file_path #: String end |
Instance Method Details
#bit_depth ⇒ Object
: () -> Integer?
27 28 29 30 |
# File 'lib/wavesync/ffmpeg/probe.rb', line 27 def bit_depth bits = audio_stream&.fetch('bits_per_sample', nil)&.to_i bits&.positive? ? bits : nil end |
#bitrate ⇒ Object
: () -> Integer?
33 34 35 36 37 38 |
# File 'lib/wavesync/ffmpeg/probe.rb', line 33 def bitrate bits_per_second = audio_stream&.fetch('bit_rate', nil)&.to_i return nil unless bits_per_second&.positive? (bits_per_second / 1000.0).round end |
#duration ⇒ Object
: () -> Float
16 17 18 |
# File 'lib/wavesync/ffmpeg/probe.rb', line 16 def duration format_data.fetch('duration', '0').to_f end |
#sample_rate ⇒ Object
: () -> Integer?
21 22 23 24 |
# File 'lib/wavesync/ffmpeg/probe.rb', line 21 def sample_rate rate = audio_stream&.fetch('sample_rate', nil) rate&.to_i end |
#tags ⇒ Object
: () -> Hash[String, String]
41 42 43 |
# File 'lib/wavesync/ffmpeg/probe.rb', line 41 def format_data['tags'] || {} end |