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
12 13 14 |
# File 'lib/wavesync/ffmpeg/probe.rb', line 12 def initialize(file_path) @file_path = file_path #: String end |
Instance Method Details
#bit_depth ⇒ Object
: () -> Integer?
28 29 30 31 |
# File 'lib/wavesync/ffmpeg/probe.rb', line 28 def bit_depth bits = audio_stream&.fetch('bits_per_sample', nil)&.to_i bits&.positive? ? bits : nil end |
#bitrate ⇒ Object
: () -> Integer?
34 35 36 37 38 39 |
# File 'lib/wavesync/ffmpeg/probe.rb', line 34 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
17 18 19 |
# File 'lib/wavesync/ffmpeg/probe.rb', line 17 def duration format_data.fetch('duration', '0').to_f end |
#sample_rate ⇒ Object
: () -> Integer?
22 23 24 25 |
# File 'lib/wavesync/ffmpeg/probe.rb', line 22 def sample_rate rate = audio_stream&.fetch('sample_rate', nil) rate&.to_i end |
#tags ⇒ Object
: () -> Hash[String, String]
42 43 44 |
# File 'lib/wavesync/ffmpeg/probe.rb', line 42 def format_data['tags'] || {} end |