From a10e809698f75a6b4da6b4f387f937aac1752882 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 9 Feb 2016 04:35:58 +0000 Subject: dtas-readahead: do not barf on missing ffprobe/avprobe Both of these are optional, so stop trying them if we do not detect them. --- bin/dtas-readahead | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/bin/dtas-readahead b/bin/dtas-readahead index 36d34c4..97d5a89 100755 --- a/bin/dtas-readahead +++ b/bin/dtas-readahead @@ -9,6 +9,8 @@ unless RUBY_PLATFORM =~ /linux/ warn "this relies on Linux /proc and probably does not work well for you" end +@ffprobe = 'ffprobe' +@avprobe = 'avprobe' require 'yaml' require 'io/wait' @@ -97,8 +99,17 @@ def do_ra(fp, pos, w) len: '%.3f' % (len / (1024 * 1024.0)), pos: pos }) spawn('soxi', path, @redir) - spawn('avprobe', path, @redir) - spawn('ffprobe', path, @redir) + begin + spawn(@avprobe, path, @redir) + rescue Errno::ENOENT + @avprobe = false unless File.exist?(path) + end if @avprobe + begin + spawn(@ffprobe, path, @redir) + rescue Errno::ENOENT + @ffprobe = false unless File.exist?(path) + end if @ffprobe + fp.advise(:sequential, pos, len) Thread.new(fp.dup) { |d| d.advise(:willneed, pos, len); d.close } -- cgit v1.2.3-24-ge0c7