From b975f4917639a43c76bec998e2c419f8b8be4291 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 26 Aug 2013 07:59:00 +0000 Subject: source/sox: bail out if zero samples are detected soxi may not handle some files correctly and detect zero samples without error-ing out. If sox can't detect the sample count or the file is really empty, then there's no point trying futher and we'll fall back to avconv. --- lib/dtas/source/sox.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/dtas/source/sox.rb b/lib/dtas/source/sox.rb index e1baee9..eba53d4 100644 --- a/lib/dtas/source/sox.rb +++ b/lib/dtas/source/sox.rb @@ -22,8 +22,15 @@ class DTAS::Source::Sox # :nodoc: def try(infile, offset = nil) err = "" - qx(@env, %W(soxi #{infile}), err_str: err, no_raise: true) + cmd = %W(soxi -s #{infile}) + s = qx(@env, cmd, err_str: err, no_raise: true) return if err =~ /soxi FAIL formats:/ + case s + when %r{\A0\s*\z} + return warn "`#{Shellwords.join(cmd)}' detected zero samples" + when Process::Status + return warn "`#{Shellwords.join(cmd)}' failed with #{s.exitstatus}" + end source_file_dup(infile, offset) end -- cgit v1.2.3-24-ge0c7