Class: Wavesync::FFMPEG::Probe

Inherits:
Object
  • Object
show all
Defined in:
lib/wavesync/ffmpeg/probe.rb

Instance Method Summary collapse

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_depthObject

: () -> 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

#bitrateObject

: () -> 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

#durationObject

: () -> Float



16
17
18
# File 'lib/wavesync/ffmpeg/probe.rb', line 16

def duration
  format_data.fetch('duration', '0').to_f
end

#sample_rateObject

: () -> 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

#tagsObject

: () -> Hash[String, String]



41
42
43
# File 'lib/wavesync/ffmpeg/probe.rb', line 41

def tags
  format_data['tags'] || {}
end