spec/ffmpeg/encoding_options_spec.rb in streamio-ffmpeg-0.5.0 vs spec/ffmpeg/encoding_options_spec.rb in streamio-ffmpeg-0.6.0
- old
+ new
@@ -5,15 +5,42 @@
describe "ffmpeg arguments conversion" do
it "should convert video codec" do
EncodingOptions.new(:video_codec => "libx264").to_s.should == "-vcodec libx264"
end
+ it "should convert cropping options" do
+ EncodingOptions.new(:croptop => 20).to_s.should == "-croptop 20"
+ EncodingOptions.new(:cropbottom => 20).to_s.should == "-cropbottom 20"
+ EncodingOptions.new(:cropleft => 20).to_s.should == "-cropleft 20"
+ EncodingOptions.new(:cropright => 20).to_s.should == "-cropright 20"
+ end
+
+ it "should know the width from the resolution or be nil" do
+ EncodingOptions.new(:resolution => "320x240").width.should == 320
+ EncodingOptions.new.width.should be_nil
+ end
+
+ it "should know the height from the resolution or be nil" do
+ EncodingOptions.new(:resolution => "320x240").height.should == 240
+ EncodingOptions.new.height.should be_nil
+ end
+
it "should convert frame rate" do
EncodingOptions.new(:frame_rate => 29.9).to_s.should == "-r 29.9"
end
it "should convert the resolution" do
- EncodingOptions.new(:resolution => "640x480").to_s.should == "-s 640x480"
+ EncodingOptions.new(:resolution => "640x480").to_s.should include("-s 640x480")
+ end
+
+ it "should add calculated aspect ratio" do
+ EncodingOptions.new(:resolution => "640x480").to_s.should include("-aspect 1.3333333")
+ EncodingOptions.new(:resolution => "640x360").to_s.should include("-aspect 1.77777777777778")
+ end
+
+ it "should use specified aspect ratio if given" do
+ EncodingOptions.new(:resolution => "640x480",
+ :aspect => 1.77777777777778).to_s.should == "-s 640x480 -aspect 1.77777777777778"
end
it "should convert video bitrate" do
EncodingOptions.new(:video_bitrate => "600k").to_s.should == "-b 600k"
end