From 70b81da26a525486c288176e5764c875c752d0b8 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 25 Jan 2016 01:03:18 +0000 Subject: mlib: support all formats of player Almost, we will need to get a list of all suffixes supported by ffprobe or avprobe. This could prove tricky.. --- lib/dtas/source/av_ff_common.rb | 1 + lib/dtas/source/sox.rb | 4 ++++ lib/dtas/source/splitfx.rb | 4 ++++ 3 files changed, 9 insertions(+) (limited to 'lib/dtas/source') diff --git a/lib/dtas/source/av_ff_common.rb b/lib/dtas/source/av_ff_common.rb index 0fb3ace..58d9f54 100644 --- a/lib/dtas/source/av_ff_common.rb +++ b/lib/dtas/source/av_ff_common.rb @@ -19,6 +19,7 @@ module DTAS::Source::AvFfCommon # :nodoc: attr_reader :precision # always 32 attr_reader :format + attr_reader :duration def try(infile, offset = nil, trim = nil) rv = source_file_dup(infile, offset, trim) diff --git a/lib/dtas/source/sox.rb b/lib/dtas/source/sox.rb index 9d128a6..db1ace2 100644 --- a/lib/dtas/source/sox.rb +++ b/lib/dtas/source/sox.rb @@ -53,6 +53,10 @@ class DTAS::Source::Sox # :nodoc: @format ||= DTAS::Format.from_file(@env, @infile) end + def duration + samples / format.rate.to_f + end + # This is the number of samples according to the samples in the source # file itself, not the decoded output def samples diff --git a/lib/dtas/source/splitfx.rb b/lib/dtas/source/splitfx.rb index d824959..f746bee 100644 --- a/lib/dtas/source/splitfx.rb +++ b/lib/dtas/source/splitfx.rb @@ -107,6 +107,10 @@ class DTAS::Source::SplitFX < DTAS::Source::Sox # :nodoc: @sox.samples end + def duration + @sox.duration + end + def source_defaults SPLITFX_DEFAULTS end -- cgit v1.2.3-24-ge0c7