From f8d4a99201a9d94a4ce1bbd69d58f48bbd2d36a9 Mon Sep 17 00:00:00 2001 From: Nirav Aga Date: Tue, 29 Jul 2014 17:18:16 +0530 Subject: [PATCH 1/2] Fixes for making the audio extraction work on windows --- helper/audio-helper.rb | 4 +++- helper/utility-helper.rb | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/helper/audio-helper.rb b/helper/audio-helper.rb index a57c43a..0269c79 100644 --- a/helper/audio-helper.rb +++ b/helper/audio-helper.rb @@ -35,11 +35,13 @@ def self.extract(file_name, save_dir) end no_ext_filename = File.basename(file_name, File.extname(file_name)) output_file_path = File.join(save_dir, "#{no_ext_filename}.#{output_extension}") - escaped_output_file_path = Shellwords.escape(output_file_path) + escaped_output_file_path = UtilityHelper.make_shellsafe_path(output_file_path) if File.exist?(output_file_path) puts "Audio file seems to exist already, removing it before extraction." File.delete(output_file_path) end + puts escaped_input_file_path + puts escaped_output_file_path Open3.popen3("ffmpeg -i #{escaped_input_file_path} -vn -acodec copy #{escaped_output_file_path}") { |stdin, stdout, stderr, wait_thr| stdout.read } puts "Done extracting audio to #{output_file_path}" else diff --git a/helper/utility-helper.rb b/helper/utility-helper.rb index 34ea3b4..5d9256f 100644 --- a/helper/utility-helper.rb +++ b/helper/utility-helper.rb @@ -41,7 +41,7 @@ def self.jruby? def self.make_shellsafe_path(path) # JRuby cannot open some paths that are escaped with Shellwords.escape so this is a workaround. - if jruby? + if jruby? || windows? '"' + path + '"' else Shellwords.escape(path) From 382a5789998c6452d2ee9526681b9f074d882786 Mon Sep 17 00:00:00 2001 From: Nirav Aga Date: Tue, 29 Jul 2014 17:21:32 +0530 Subject: [PATCH 2/2] Removed debug code --- helper/audio-helper.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/helper/audio-helper.rb b/helper/audio-helper.rb index 0269c79..0868496 100644 --- a/helper/audio-helper.rb +++ b/helper/audio-helper.rb @@ -40,8 +40,6 @@ def self.extract(file_name, save_dir) puts "Audio file seems to exist already, removing it before extraction." File.delete(output_file_path) end - puts escaped_input_file_path - puts escaped_output_file_path Open3.popen3("ffmpeg -i #{escaped_input_file_path} -vn -acodec copy #{escaped_output_file_path}") { |stdin, stdout, stderr, wait_thr| stdout.read } puts "Done extracting audio to #{output_file_path}" else