Permalink
Browse files

Merge pull request #22 from mikesager/master

Add missing filename escaping.
  • Loading branch information...
2 parents 538301f + 80de5de commit c49ea2db897a621e6250e90be439d5731fe6dc4c @dbackeus dbackeus committed Mar 28, 2012
Showing with 18 additions and 2 deletions.
  1. +1 −1 lib/ffmpeg/movie.rb
  2. +1 −1 lib/ffmpeg/transcoder.rb
  3. +8 −0 spec/ffmpeg/movie_spec.rb
  4. +8 −0 spec/ffmpeg/transcoder_spec.rb
View
2 lib/ffmpeg/movie.rb
@@ -9,7 +9,7 @@ def initialize(path)
@path = path
- stdin, stdout, stderr = Open3.popen3("#{FFMPEG.ffmpeg_binary} -i '#{path}'") # Output will land in stderr
+ stdin, stdout, stderr = Open3.popen3("#{FFMPEG.ffmpeg_binary} -i #{Shellwords.escape(path)}") # Output will land in stderr
output = stderr.read
fix_encoding(output)
View
2 lib/ffmpeg/transcoder.rb
@@ -24,7 +24,7 @@ def initialize(movie, output_file, options = EncodingOptions.new, transcoder_opt
# ffmpeg < 0.8: frame= 413 fps= 48 q=31.0 size= 2139kB time=16.52 bitrate=1060.6kbits/s
# ffmpeg >= 0.8: frame= 4855 fps= 46 q=31.0 size= 45306kB time=00:02:42.28 bitrate=2287.0kbits/
def run
- command = "#{FFMPEG.ffmpeg_binary} -y -i #{Shellwords.escape(@movie.path)} #{@raw_options} '#{@output_file}'"
+ command = "#{FFMPEG.ffmpeg_binary} -y -i #{Shellwords.escape(@movie.path)} #{@raw_options} #{Shellwords.escape(@output_file)}"
FFMPEG.logger.info("Running transcoding...\n#{command}\n")
output = ""
last_output = nil
View
8 spec/ffmpeg/movie_spec.rb
@@ -9,6 +9,14 @@ module FFMPEG
end
end
+ describe "given a file containing a single quotation mark in the filename" do
+ it "should run ffmpeg successfully" do
+ @movie = Movie.new("#{fixture_path}/movies/awesome'movie.mov")
+ @movie.duration.should == 7.56
+ @movie.frame_rate.should == 16.75
+ end
+ end
+
describe "parsing" do
describe "given a non movie file" do
before(:all) do
View
8 spec/ffmpeg/transcoder_spec.rb
@@ -116,6 +116,14 @@ module FFMPEG
lambda { Transcoder.new(movie, "#{tmp_path}/output.flv").run }.should_not raise_error
end
+ it "should transcode when output filename includes single quotation mark" do
+ FileUtils.rm_f "#{tmp_path}/output with 'quote.flv"
+
+ movie = Movie.new("#{fixture_path}/movies/awesome movie.mov")
+
+ lambda { Transcoder.new(movie, "#{tmp_path}/output with 'quote.flv").run }.should_not raise_error
+ end
+
pending "should not crash on ISO-8859-1 characters (dont know how to spec this)"
it "should fail when given an invalid movie" do

0 comments on commit c49ea2d

Please sign in to comment.