scissor 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/scissor/writer.rb +16 -17
- metadata +2 -2
data/Rakefile
CHANGED
@@ -18,7 +18,7 @@ DESCRIPTION = "utility to chop sound files"
|
|
18
18
|
RUBYFORGE_PROJECT = "scissor"
|
19
19
|
HOMEPATH = "http://github.com/youpy/scissor"
|
20
20
|
BIN_FILES = %w( )
|
21
|
-
VERS = "0.1.
|
21
|
+
VERS = "0.1.2"
|
22
22
|
|
23
23
|
REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
|
24
24
|
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
|
data/lib/scissor/writer.rb
CHANGED
@@ -37,14 +37,10 @@ module Scissor
|
|
37
37
|
cmd = %w/ecasound/
|
38
38
|
end
|
39
39
|
|
40
|
-
|
41
|
-
fragment_outfile = fragment_filename
|
42
|
-
else
|
43
|
-
fragment_outfile = tmpdir + (Digest::MD5.hexdigest(fragment_filename.to_s) + '.wav')
|
44
|
-
end
|
40
|
+
fragment_outfile = tmpdir + (Digest::MD5.hexdigest(fragment_filename.to_s) + '.wav')
|
45
41
|
|
46
42
|
unless fragment_outfile.exist?
|
47
|
-
run_command("ffmpeg -i \"#{fragment_filename}\" \"#{fragment_outfile}\"")
|
43
|
+
run_command("ffmpeg -i \"#{fragment_filename}\" -ar 44100 \"#{fragment_outfile}\"")
|
48
44
|
end
|
49
45
|
|
50
46
|
cmd << "-a:#{index} -o:#{outfile} -y:#{position}"
|
@@ -52,8 +48,8 @@ module Scissor
|
|
52
48
|
if fragment.stretched? && fragment.pitch.to_f != 100.0
|
53
49
|
rubberband_out = tmpdir + (Digest::MD5.hexdigest(fragment_filename.to_s) + "rubberband_#{index}.wav")
|
54
50
|
rubberband_temp = tmpdir + "_rubberband.wav"
|
55
|
-
|
56
|
-
run_command("ecasound " +
|
51
|
+
|
52
|
+
run_command("ecasound " +
|
57
53
|
"-i:" +
|
58
54
|
(fragment.reversed? ? 'reverse,' : '') +
|
59
55
|
"select,#{fragment.start},#{fragment.original_duration},\"#{fragment_outfile}\" -o:#{rubberband_temp} "
|
@@ -62,7 +58,7 @@ module Scissor
|
|
62
58
|
|
63
59
|
cmd << "-i:\"#{rubberband_out}\""
|
64
60
|
else
|
65
|
-
cmd <<
|
61
|
+
cmd <<
|
66
62
|
"-i:" +
|
67
63
|
(fragment.reversed? ? 'reverse,' : '') +
|
68
64
|
"select,#{fragment.start},#{fragment.original_duration},\"#{fragment_outfile}\" " +
|
@@ -119,11 +115,7 @@ module Scissor
|
|
119
115
|
|
120
116
|
mix_files(tmpfiles, final_tmpfile = tmpdir + 'tmp.wav')
|
121
117
|
|
122
|
-
|
123
|
-
File.rename(final_tmpfile, full_filename)
|
124
|
-
else
|
125
|
-
run_command("ffmpeg -ab #{options[:bitrate]} -i \"#{final_tmpfile}\" \"#{full_filename}\"")
|
126
|
-
end
|
118
|
+
run_command("ffmpeg -ab #{options[:bitrate]} -i \"#{final_tmpfile}\" -ar 44100 \"#{full_filename}\"")
|
127
119
|
end
|
128
120
|
end
|
129
121
|
|
@@ -137,10 +129,17 @@ module Scissor
|
|
137
129
|
logger.debug("run_command: #{cmd}")
|
138
130
|
|
139
131
|
result, error = '', ''
|
140
|
-
status = Open4.spawn cmd, 'stdout' => result, 'stderr' => error
|
141
|
-
logger.debug(error)
|
142
132
|
|
143
|
-
|
133
|
+
begin
|
134
|
+
status = Open4.spawn cmd, 'stdout' => result, 'stderr' => error
|
135
|
+
rescue Open4::SpawnError => e
|
136
|
+
raise CommandFailed.new(e.cmd)
|
137
|
+
ensure
|
138
|
+
logger.debug(result)
|
139
|
+
logger.debug(error)
|
140
|
+
end
|
141
|
+
|
142
|
+
if status && status.exitstatus != 0
|
144
143
|
raise CommandFailed.new(cmd)
|
145
144
|
end
|
146
145
|
|