lib/scissor/writer.rb in scissor-0.1.2 vs lib/scissor/writer.rb in scissor-0.2.0
- old
+ new
@@ -1,9 +1,10 @@
require 'digest/md5'
require 'pathname'
require 'open4'
require 'temp_dir'
+require 'streamio-ffmpeg'
module Scissor
class Writer
include Loggable
@@ -15,11 +16,10 @@
def initialize
@tracks = []
which('ecasound')
- which('ffmpeg')
which('rubberband')
end
def add_track(fragments)
@tracks << fragments
@@ -38,11 +38,12 @@
end
fragment_outfile = tmpdir + (Digest::MD5.hexdigest(fragment_filename.to_s) + '.wav')
unless fragment_outfile.exist?
- run_command("ffmpeg -i \"#{fragment_filename}\" -ar 44100 \"#{fragment_outfile}\"")
+ movie = FFMPEG::Movie.new(fragment_filename.to_s)
+ movie.transcode(fragment_outfile.to_s, :audio_sample_rate => 44100)
end
cmd << "-a:#{index} -o:#{outfile} -y:#{position}"
if fragment.stretched? && fragment.pitch.to_f != 100.0
@@ -113,10 +114,11 @@
join_fragments(fragments, tmpfile, tmpdir)
end
mix_files(tmpfiles, final_tmpfile = tmpdir + 'tmp.wav')
- run_command("ffmpeg -ab #{options[:bitrate]} -i \"#{final_tmpfile}\" -ar 44100 \"#{full_filename}\"")
+ movie = FFMPEG::Movie.new(final_tmpfile.to_s)
+ movie.transcode(full_filename.to_s, :audio_sample_rate => 44100, :audio_bitrate => options[:bitrate])
end
end
def which(command)
run_command("which #{command}")