diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-08-26 07:59:00 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-08-26 07:59:00 +0000 |
commit | b975f4917639a43c76bec998e2c419f8b8be4291 (patch) | |
tree | f61232d18e809619c47bef871d8810cbf3ecf767 | |
parent | 33ad8374da5d782d174c70a9023d181378151040 (diff) | |
download | dtas-b975f4917639a43c76bec998e2c419f8b8be4291.tar.gz |
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.
-rw-r--r-- | lib/dtas/source/sox.rb | 9 |
1 files changed, 8 insertions, 1 deletions
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 |