forked from polly/ffmpeg
/
video_options_spec.rb
200 lines (151 loc) · 5.56 KB
/
video_options_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
require File.dirname(__FILE__) + '/spec_helper'
describe "FFMpeg Video Options" do
before(:each) do
@from_file, @to_file = "~/Desktop/test.avi", "~/Desktop/test2.avi"
FFMpegCommand.clear
end
it "should set the resolution" do
convert @from_file, :to => @to_file do
resolution "vga"
end
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -s vga #{@to_file}")
end
it "should set the video bitrate" do
convert @from_file, :to => @to_file do
video_bitrate "200k"
end
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -vb 200k #{@to_file}")
end
it "should set the number of video frames to record" do
convert @from_file, :to => @to_file do
video_frames 200
end
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -vframes 200 #{@to_file}")
end
it "should set framerate" do
convert @from_file, :to => @to_file do
framerate 24
end
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -r 24 #{@to_file}")
end
it "should set aspect ratio" do
convert @from_file, :to => @to_file do
aspect "4:3"
end
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -aspect 4:3 #{@to_file}")
end
it "should set size of top crop band" do
convert @from_file, :to => @to_file do
crop_top 20
end
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -croptop 20 #{@to_file}")
end
it "should set size of bottom crop band" do
convert @from_file, :to => @to_file do
crop_bottom 20
end
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -cropbottom 20 #{@to_file}")
end
it "should set size of left crop band" do
convert @from_file, :to => @to_file do
crop_left 20
end
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -cropleft 20 #{@to_file}")
end
it "should set size of right crop band" do
convert @from_file, :to => @to_file do
crop_right 20
end
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -cropright 20 #{@to_file}")
end
it "should set size of top pad band" do
convert @from_file, :to => @to_file do
pad_top 20
end
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -padtop 20 #{@to_file}")
end
it "should set size of bottom pad band" do
convert @from_file, :to => @to_file do
pad_bottom 20
end
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -padbottom 20 #{@to_file}")
end
it "should set size of left pad band" do
convert @from_file, :to => @to_file do
pad_left 20
end
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -padleft 20 #{@to_file}")
end
it "should set size of right pad band" do
convert @from_file, :to => @to_file do
pad_right 20
end
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -padright 20 #{@to_file}")
end
it "should set color for padded bands" do
convert @from_file, :to => @to_file do
pad_color "ffffff"
end
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -padcolor ffffff #{@to_file}")
end
it "should disable video encoding" do
convert @from_file, :to => @to_file do
disable_video
end
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -vn #{@to_file}")
end
it "should set the bitrate tolerance" do
convert @from_file, :to => @to_file do
video_bitrate_tolerance "8000k"
end
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -bt 8000k #{@to_file}")
end
it "should set maximum bitrate" do
convert @from_file, :to => @to_file do
video_maximum_bitrate "1000k"
end
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -maxrate 1000k #{@to_file}")
end
it "should set minimum bitrate" do
convert @from_file, :to => @to_file do
video_minimum_bitrate "5000k"
end
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -minrate 5000k #{@to_file}")
end
it "should set buffer verifier size" do
convert @from_file, :to => @to_file do
video_buffer_size "2M"
end
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -bufsize 2M #{@to_file}")
end
it "should set the codec explicitly" do
convert @from_file, :to => @to_file do
video_codec "x264"
end
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -vcodec x264 #{@to_file}")
end
it "should set same quality encoding flag" do
convert @from_file, :to => @to_file do
same_video_quality
end
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -sameq #{@to_file}")
end
it "should set the pass number for encoding" do
convert @from_file, :to => @to_file do
video_pass 2
end
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -pass 2 #{@to_file}")
end
it "should set the logfile prefix for multi-pass encoding" do
convert @from_file, :to => @to_file do
video_pass_logfile "test"
end
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -passlogfile test #{@to_file}")
end
it "should set that a new video stream is being added to the current output stream" do
convert @from_file, :to => @to_file do
new_video
end
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -newvideo #{@to_file}")
end
end