From 619b08c9d4e43d94bac39cd395c1def6fa796f06 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 10 May 2015 09:06:35 +0000 Subject: splitfx: support -O/--outdir switch to control output dir It is useful to force output to a writable directory if the YAML file is on a read-only mount point or to force the output to a large tmpfs mount point to avoid SSD/HDD wear. --- lib/dtas/splitfx.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib/dtas/splitfx.rb') diff --git a/lib/dtas/splitfx.rb b/lib/dtas/splitfx.rb index 208ff67..3f673ee 100644 --- a/lib/dtas/splitfx.rb +++ b/lib/dtas/splitfx.rb @@ -10,7 +10,7 @@ require 'tempfile' # Unlike the stuff for dtas-player, dtas-splitfx is fairly tied to sox # (but we may still pipe to ecasound or anything else) class DTAS::SplitFX # :nodoc: - CMD = 'sox "$INFILE" $COMMENTS $OUTFMT "$TRACKNUMBER.$SUFFIX" '\ + CMD = 'sox "$INFILE" $COMMENTS $OUTFMT "$OUTDIR$TRACKNUMBER.$SUFFIX" '\ '$TRIMFX $FX $RATEFX $DITHERFX' include DTAS::Process include DTAS::XS @@ -55,6 +55,7 @@ class DTAS::SplitFX # :nodoc: @track_zpad = true @t2s = method(:t2s) @infile = nil + @outdir = nil @targets = { "flac-cdda" => { "command" => CMD, @@ -72,7 +73,7 @@ class DTAS::SplitFX # :nodoc: '$OPUSENC_BITRATE --raw-rate $RATE --raw-chan $CHANNELS ' \ '--raw-endianness $ENDIAN_OPUSENC ' \ '$OPUSENC_COMMENTS ' \ - '- $TRACKNUMBER.opus', + '- $OUTDIR$TRACKNUMBER.opus', "format" => { "bits" => 16, "rate" => 48000, @@ -197,6 +198,7 @@ class DTAS::SplitFX # :nodoc: infile_env(env, @infile) env["OUTFMT"] = xs(outfmt.to_sox_arg) env["SUFFIX"] = outfmt.type + env["OUTDIR"] = @outdir ? "#@outdir/".squeeze('/') : '' env.merge!(t.env) command = target["command"] @@ -323,6 +325,11 @@ class DTAS::SplitFX # :nodoc: end def run(target, opts = {}) + if @outdir = opts[:outdir] + require 'fileutils' + FileUtils.mkpath(@outdir) + end + fails = [] tracks = @tracks.dup pids = {} -- cgit v1.2.3-24-ge0c7