Permalink
Browse files

partial changes

  • Loading branch information...
guyboertje committed Apr 14, 2012
1 parent 645c812 commit 67563227e67c55b7d589ea6af6d46fb2e88c66aa
Showing with 15 additions and 10 deletions.
  1. +9 −6 lib/ffmpeg/movie.rb
  2. +6 −4 spec/ffmpeg/movie_spec.rb
View
@@ -5,14 +5,17 @@ class Movie
attr_reader :audio_stream, :audio_codec, :audio_bitrate, :audio_sample_rate
def initialize(path)
- raise Errno::ENOENT, "the file '#{path}' does not exist" unless File.exists?(path)
- @path = path
+ escaped_path = `ls #{Shellwords.escape(path)} 2>&1`.chomp
+
+
+ raise Errno::ENOENT, "the file '#{escaped_path}' does not exist" unless File.exists?(escaped_path)
+ @path = escaped_path
# ffmpeg will output to stderr
- command = "#{FFMPEG.ffmpeg_binary} -i #{Shellwords.escape(path)}"
+ command = "#{FFMPEG.ffmpeg_binary} -i \"#{Shellwords.escape(path)}\""
output = IO4.popen4(command) { |pid, stdin, stdout, stderr| stderr.read }
-
-fix_encoding(output)
+
+ fix_encoding(output)
output[/Duration: (\d{2}):(\d{2}):(\d{2}\.\d{2})/]
@duration = ($1.to_i*60*60) + ($2.to_i*60) + $3.to_f
@@ -95,7 +98,7 @@ def aspect_from_dar
aspect = w.to_f / h.to_f
aspect.zero? ? nil : aspect
end
-
+
def aspect_from_dimensions
aspect = width.to_f / height.to_f
aspect.nan? ? nil : aspect
View
@@ -11,6 +11,7 @@ module FFMPEG
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")
+ p "", "^^^^^^^^^^^^^", @movie.path
@movie.duration.should == 7.56
@movie.frame_rate.should == 16.75
end
@@ -71,20 +72,20 @@ module FFMPEG
@movie.calculated_aspect_ratio.to_s[0..15].should == "1.73827160493827" # substringed to be 1.9 compatible
end
end
-
+
describe "given an impossible DAR" do
before(:all) do
fake_output = StringIO.new(File.read("#{fixture_path}/outputs/file_with_weird_dar.txt"))
- Open3.stub!(:popen3).and_yield(nil,nil,fake_output)
+ IO4.stub!(:popen4).and_yield(nil, nil, nil, fake_output)
@movie = Movie.new(__FILE__)
end
-
+
it "should parse the DAR" do
@movie.dar.should == "0:1"
end
it "should calulate using width and height instead" do
- @movie.calculated_aspect_ratio.to_s[0..15].should == "1.77777777777777" # substringed to be 1.9 compatible
+ @movie.calculated_aspect_ratio.to_s[0..15].should == "1.77777777777777" # substringed to be 1.9 compatible
end
end
@@ -147,6 +148,7 @@ module FFMPEG
describe "given an awesome movie file" do
before(:all) do
@movie = Movie.new("#{fixture_path}/movies/awesome movie.mov")
+ p "", "^^^^^^^^^^^^^", @movie.path
end
it "should have uncertain duration (all movies are considered uncertain these days)" do

0 comments on commit 6756322

Please sign in to comment.