polly-ffmpeg 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +20 -0
- data/README.rdoc +24 -24
- data/Rakefile +45 -0
- data/ffmpeg.gemspec +50 -0
- data/lib/ffmpeg.rb +5 -3
- data/lib/ffmpeg/audio_options.rb +47 -0
- data/lib/ffmpeg/video_options.rb +130 -3
- data/spec/audio_options_spec.rb +72 -0
- data/spec/ffmpeg_spec.rb +14 -29
- data/spec/video_options_spec.rb +200 -0
- metadata +19 -16
- data/VERSION.yml +0 -4
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 Patrik Hedman
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= FFMpeg
|
2
2
|
|
3
|
-
|
3
|
+
A DSL for building and executing ffmpeg commands.
|
4
4
|
|
5
5
|
== Requirements
|
6
6
|
|
@@ -12,30 +12,30 @@
|
|
12
12
|
|
13
13
|
== Usage
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
15
|
+
To build and execute a command you would use the FFMpeg::convert method and then call the FFMpeg::run method like this:
|
16
|
+
|
17
|
+
include FFMpeg
|
18
|
+
|
19
|
+
convert "file.ext", :to => "new_file.ext" do
|
20
|
+
seek "00:01:13"
|
21
|
+
duration "00:10:01"
|
22
|
+
end.run
|
23
23
|
|
24
24
|
== Extending
|
25
|
-
|
26
|
-
FFMpeg takes a lot of options, I mean alot ;), so I haven't been able to add methods for wrapping them all yet.
|
27
|
-
Luckily it's really easy to add your own wrapper methods, just add them to the class that's including the FFMpeg module.
|
28
|
-
So if you wanted to add a method for say, setting the video quantizer scale blur for example, here's how you could do it:
|
29
25
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
26
|
+
FFMpeg takes a lot of options, I mean alot ;), so I haven't been able to add methods for wrapping them all yet.
|
27
|
+
Luckily it's really easy to add your own wrapper methods, just add them to the class that's including the FFMpeg module.
|
28
|
+
So if you wanted to add a method for say, setting the video quantizer scale blur for example, here's how you could do it:
|
29
|
+
|
30
|
+
def quantizer_scale_blur(blur)
|
31
|
+
FFMpegCommand << "-qblur #{blur}"
|
32
|
+
end
|
33
|
+
|
34
|
+
You would then call it inside the convert block just like any other method:
|
35
|
+
|
36
|
+
convert "file.ext", :to => "new_file.ext" do
|
37
|
+
quantizer_scale_blur "0.5"
|
38
|
+
end
|
39
39
|
|
40
|
-
|
41
|
-
|
40
|
+
If you where to add a method with the same name as one already defined in the library your method will take precedence
|
41
|
+
over the predefined one, a warning message informing you about the conflict will be printed out through $stderr however.
|
data/Rakefile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'rake'
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'jeweler'
|
5
|
+
Jeweler::Tasks.new do |s|
|
6
|
+
s.name = "ffmpeg"
|
7
|
+
s.summary = %Q{TODO}
|
8
|
+
s.email = "patrik@moresale.se"
|
9
|
+
s.homepage = "http://github.com/polly/ffmpeg"
|
10
|
+
s.description = "TODO"
|
11
|
+
s.authors = ["Patrik Hedman"]
|
12
|
+
end
|
13
|
+
rescue LoadError
|
14
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
15
|
+
end
|
16
|
+
|
17
|
+
require 'rake/rdoctask'
|
18
|
+
Rake::RDocTask.new do |rdoc|
|
19
|
+
rdoc.rdoc_dir = 'rdoc'
|
20
|
+
rdoc.title = 'ffmpeg'
|
21
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
22
|
+
rdoc.rdoc_files.include('README*')
|
23
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
24
|
+
end
|
25
|
+
|
26
|
+
require 'spec/rake/spectask'
|
27
|
+
Spec::Rake::SpecTask.new(:spec) do |t|
|
28
|
+
t.libs << 'lib' << 'spec'
|
29
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
30
|
+
end
|
31
|
+
|
32
|
+
Spec::Rake::SpecTask.new(:rcov) do |t|
|
33
|
+
t.libs << 'lib' << 'spec'
|
34
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
35
|
+
t.rcov = true
|
36
|
+
end
|
37
|
+
|
38
|
+
begin
|
39
|
+
require 'cucumber/rake/task'
|
40
|
+
Cucumber::Rake::Task.new(:features)
|
41
|
+
rescue LoadError
|
42
|
+
puts "Cucumber is not available. In order to run features, you must: sudo gem install cucumber"
|
43
|
+
end
|
44
|
+
|
45
|
+
task :default => :spec
|
data/ffmpeg.gemspec
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{ffmpeg}
|
5
|
+
s.version = "0.1.2"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Patrik Hedman"]
|
9
|
+
s.date = %q{2009-07-03}
|
10
|
+
s.description = %q{Need to write one}
|
11
|
+
s.email = %q{patrik@moresale.se}
|
12
|
+
s.extra_rdoc_files = [
|
13
|
+
"LICENSE",
|
14
|
+
"README.rdoc"
|
15
|
+
]
|
16
|
+
s.files = [
|
17
|
+
"LICENSE",
|
18
|
+
"README.rdoc",
|
19
|
+
"Rakefile",
|
20
|
+
"ffmpeg.gemspec",
|
21
|
+
"lib/ffmpeg.rb",
|
22
|
+
"lib/ffmpeg/audio_options.rb",
|
23
|
+
"lib/ffmpeg/class_methods.rb",
|
24
|
+
"lib/ffmpeg/ffmpeg_command.rb",
|
25
|
+
"lib/ffmpeg/helper_methods.rb",
|
26
|
+
"lib/ffmpeg/main_options.rb",
|
27
|
+
"lib/ffmpeg/video_options.rb"
|
28
|
+
]
|
29
|
+
s.homepage = %q{http://github.com/polly/ffmpeg}
|
30
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
31
|
+
s.require_paths = ["lib"]
|
32
|
+
s.rubygems_version = %q{1.3.4}
|
33
|
+
s.summary = %q{Need to write one}
|
34
|
+
s.test_files = [
|
35
|
+
"spec/audio_options_spec.rb",
|
36
|
+
"spec/ffmpeg_spec.rb",
|
37
|
+
"spec/spec_helper.rb",
|
38
|
+
"spec/video_options_spec.rb"
|
39
|
+
]
|
40
|
+
|
41
|
+
if s.respond_to? :specification_version then
|
42
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
43
|
+
s.specification_version = 3
|
44
|
+
|
45
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
46
|
+
else
|
47
|
+
end
|
48
|
+
else
|
49
|
+
end
|
50
|
+
end
|
data/lib/ffmpeg.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'ffmpeg/class_methods'
|
2
2
|
require 'ffmpeg/main_options'
|
3
3
|
require 'ffmpeg/video_options'
|
4
|
+
require 'ffmpeg/audio_options'
|
4
5
|
require 'ffmpeg/ffmpeg_command'
|
5
6
|
require 'ffmpeg/helper_methods'
|
6
7
|
|
@@ -8,6 +9,7 @@ module FFMpeg
|
|
8
9
|
include HelperMethods
|
9
10
|
include MainOptions
|
10
11
|
include VideoOptions
|
12
|
+
include AudioOptions
|
11
13
|
|
12
14
|
#
|
13
15
|
# When mixed into a class, extend
|
@@ -37,13 +39,13 @@ module FFMpeg
|
|
37
39
|
#
|
38
40
|
def convert(from_file, to_file = {})
|
39
41
|
FFMpegCommand << "-i #{from_file}"
|
40
|
-
FFMpegCommand << "#{to_file[:to]}" unless to_file[:to].nil?
|
41
42
|
begin
|
42
43
|
yield if block_given?
|
43
44
|
rescue Exception => exception
|
44
|
-
Thread.current[:'method checking
|
45
|
+
Thread.current[:'method checking disabled'] = true
|
45
46
|
raise exception
|
46
47
|
end
|
48
|
+
FFMpegCommand << "#{to_file[:to]}" unless to_file[:to].nil?
|
47
49
|
end
|
48
50
|
|
49
51
|
#
|
@@ -59,7 +61,7 @@ module FFMpeg
|
|
59
61
|
#
|
60
62
|
#
|
61
63
|
def method_checking_enabled?
|
62
|
-
!Thread.current[:'method checking
|
64
|
+
!Thread.current[:'method checking disabled']
|
63
65
|
end
|
64
66
|
|
65
67
|
#
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module FFMpeg
|
2
|
+
module AudioOptions
|
3
|
+
# Set the number of audio frames to record.
|
4
|
+
def audio_frames(number)
|
5
|
+
FFMpegCommand << "-aframes #{number}"
|
6
|
+
end
|
7
|
+
|
8
|
+
# Set the audio sampling frequency (default = 44100 Hz).
|
9
|
+
def audio_sampling(frequency)
|
10
|
+
FFMpegCommand << "-ar #{frequency}"
|
11
|
+
end
|
12
|
+
|
13
|
+
# Set the audio bitrate in bit/s (default = 64k).
|
14
|
+
def audio_bitrate(bitrate)
|
15
|
+
FFMpegCommand << "-ab #{bitrate}"
|
16
|
+
end
|
17
|
+
|
18
|
+
# Set the number of audio channels (default = 1).
|
19
|
+
def audio_channels(number)
|
20
|
+
FFMpegCommand << "-ac #{number}"
|
21
|
+
end
|
22
|
+
|
23
|
+
# Disable audio recording.
|
24
|
+
def disable_audio
|
25
|
+
FFMpegCommand << "-an"
|
26
|
+
end
|
27
|
+
|
28
|
+
# Force audio codec to codec. Use the copy special value to specify that the raw codec data must be copied as is.
|
29
|
+
def audio_codec(codec)
|
30
|
+
FFMpegCommand << "-acodec #{codec}"
|
31
|
+
end
|
32
|
+
|
33
|
+
# Add a new audio track to the output file. If you want to specify parameters, do so before -newaudio (-acodec,
|
34
|
+
# -ab, etc..). Mapping will be done automatically, if the number of output streams is equal to the number of input
|
35
|
+
# streams, else it will pick the first one that matches. You can override the mapping using -map as usual. Example:
|
36
|
+
#
|
37
|
+
# ffmpeg -i file.mpg -vcodec copy -acodec ac3 -ab 384k test.mpg -acodec mp2 -ab 192k -newaudio
|
38
|
+
def new_audio
|
39
|
+
FFMpegCommand << "-newaudio"
|
40
|
+
end
|
41
|
+
|
42
|
+
# Set the ISO 639 language code (3 letters) of the current audio stream.
|
43
|
+
def audio_language(code)
|
44
|
+
FFMpegCommand << "-alang #{code}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/ffmpeg/video_options.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module FFMpeg
|
2
2
|
module VideoOptions
|
3
3
|
#
|
4
|
-
# Set frame size. The format is `wxh' (ffserver default = 160x128, ffmpeg default = same as source).
|
4
|
+
# Set frame size. The format is `wxh' (ffserver default = 160x128, ffmpeg default = same as source).
|
5
5
|
# The following abbreviations are recognized:
|
6
6
|
#
|
7
7
|
# 'sqcif'
|
@@ -61,10 +61,137 @@ module FFMpeg
|
|
61
61
|
# 'hd1080'
|
62
62
|
# 1920x1080
|
63
63
|
#
|
64
|
-
#
|
65
|
-
#
|
66
64
|
def resolution(resolution)
|
67
65
|
FFMpegCommand << "-s #{resolution}"
|
68
66
|
end
|
67
|
+
|
68
|
+
# Set the video bitrate in bit/s (default = 200 kb/s or '200k').
|
69
|
+
def video_bitrate(bitrate)
|
70
|
+
FFMpegCommand << "-vb #{bitrate}"
|
71
|
+
end
|
72
|
+
|
73
|
+
# Set the number of video frames to record.
|
74
|
+
def video_frames(number)
|
75
|
+
FFMpegCommand << "-vframes #{number}"
|
76
|
+
end
|
77
|
+
|
78
|
+
# Set frame rate (Hz value, fraction or abbreviation), (default = 25).
|
79
|
+
def framerate(fps)
|
80
|
+
FFMpegCommand << "-r #{fps}"
|
81
|
+
end
|
82
|
+
|
83
|
+
# Set aspect ratio (4:3, 16:9 or 1.3333, 1.7777).
|
84
|
+
def aspect(aspect)
|
85
|
+
FFMpegCommand << "-aspect #{aspect}"
|
86
|
+
end
|
87
|
+
|
88
|
+
# Set top crop band size (in pixels).
|
89
|
+
def crop_top(size)
|
90
|
+
FFMpegCommand << "-croptop #{size}"
|
91
|
+
end
|
92
|
+
|
93
|
+
# Set bottom crop band size (in pixels).
|
94
|
+
def crop_bottom(size)
|
95
|
+
FFMpegCommand << "-cropbottom #{size}"
|
96
|
+
end
|
97
|
+
|
98
|
+
# Set left crop band size (in pixels).
|
99
|
+
def crop_left(size)
|
100
|
+
FFMpegCommand << "-cropleft #{size}"
|
101
|
+
end
|
102
|
+
|
103
|
+
# Set right crop band size (in pixels).
|
104
|
+
def crop_right(size)
|
105
|
+
FFMpegCommand << "-cropright #{size}"
|
106
|
+
end
|
107
|
+
|
108
|
+
# Set top pad band size (in pixels).
|
109
|
+
def pad_top(size)
|
110
|
+
FFMpegCommand << "-padtop #{size}"
|
111
|
+
end
|
112
|
+
|
113
|
+
# Set bottom pad band size (in pixels).
|
114
|
+
def pad_bottom(size)
|
115
|
+
FFMpegCommand << "-padbottom #{size}"
|
116
|
+
end
|
117
|
+
|
118
|
+
# Set left pad band size (in pixels).
|
119
|
+
def pad_left(size)
|
120
|
+
FFMpegCommand << "-padleft #{size}"
|
121
|
+
end
|
122
|
+
|
123
|
+
# Set right pad band size (in pixels).
|
124
|
+
def pad_right(size)
|
125
|
+
FFMpegCommand << "-padright #{size}"
|
126
|
+
end
|
127
|
+
|
128
|
+
# Set color of padded bands. The value for padcolor is expressed as a six digit hexadecimal number where the first
|
129
|
+
# two digits represent red, the middle two digits green and last two digits blue (default = 000000 (black)).
|
130
|
+
def pad_color(color)
|
131
|
+
FFMpegCommand << "-padcolor #{color}"
|
132
|
+
end
|
133
|
+
|
134
|
+
# Disable video recording.
|
135
|
+
def disable_video
|
136
|
+
FFMpegCommand << "-vn"
|
137
|
+
end
|
138
|
+
|
139
|
+
# Set video bitrate tolerance (in bits, default 4000k). Has a minimum value of: (target_bitrate/target_framerate).
|
140
|
+
# In 1-pass mode, bitrate tolerance specifies how far ratecontrol is willing to deviate from the target average
|
141
|
+
# bitrate value. This is not related to min/max bitrate. Lowering tolerance too much has an adverse effect on
|
142
|
+
# quality.
|
143
|
+
def video_bitrate_tolerance(tolerance)
|
144
|
+
FFMpegCommand << "-bt #{tolerance}"
|
145
|
+
end
|
146
|
+
|
147
|
+
# Set max video bitrate (in bit/s). Requires -bufsize to be set.
|
148
|
+
def video_maximum_bitrate(bitrate)
|
149
|
+
FFMpegCommand << "-maxrate #{bitrate}"
|
150
|
+
end
|
151
|
+
|
152
|
+
# Set min video bitrate (in bit/s). Most useful in setting up a CBR encode:
|
153
|
+
# ffmpeg -i myfile.avi -b 4000k -minrate 4000k -maxrate 4000k -bufsize 1835k out.m2v
|
154
|
+
# It is of little use elsewise.
|
155
|
+
def video_minimum_bitrate(bitrate)
|
156
|
+
FFMpegCommand << "-minrate #{bitrate}"
|
157
|
+
end
|
158
|
+
|
159
|
+
# Set video buffer verifier buffer size (in bits).
|
160
|
+
def video_buffer_size(size)
|
161
|
+
FFMpegCommand << "-bufsize #{size}"
|
162
|
+
end
|
163
|
+
|
164
|
+
# `-vcodec codec'
|
165
|
+
# Force video codec to codec. Use the copy special value to tell that the raw codec data must be copied as is.
|
166
|
+
def video_codec(codec)
|
167
|
+
FFMpegCommand << "-vcodec #{codec}"
|
168
|
+
end
|
169
|
+
|
170
|
+
# Use same video quality as source (implies VBR).
|
171
|
+
def same_video_quality
|
172
|
+
FFMpegCommand << "-sameq"
|
173
|
+
end
|
174
|
+
|
175
|
+
# Select the pass number (1 or 2). It is used to do two-pass video encoding. The statistics of the video are
|
176
|
+
# recorded in the first pass into a log file (see also the option -passlogfile), and in the second pass that log
|
177
|
+
# file is used to generate the video at the exact requested bitrate. On pass 1, you may just deactivate audio and
|
178
|
+
# set output to null, examples for Windows and Unix:
|
179
|
+
#
|
180
|
+
# ffmpeg -i foo.mov -vcodec libxvid -pass 1 -an -f rawvideo -y NUL
|
181
|
+
# ffmpeg -i foo.mov -vcodec libxvid -pass 1 -an -f rawvideo -y /dev/null
|
182
|
+
def video_pass(index)
|
183
|
+
FFMpegCommand << "-pass #{index}"
|
184
|
+
end
|
185
|
+
|
186
|
+
# Set two-pass log file name prefix to prefix, the default file name prefix is "ffmpeg2pass". The complete file
|
187
|
+
# name will be `PREFIX-N.log', where N is a number specific to the output stream.
|
188
|
+
def video_pass_logfile(prefix)
|
189
|
+
FFMpegCommand << "-passlogfile #{prefix}"
|
190
|
+
end
|
191
|
+
|
192
|
+
# Add a new video stream to the current output stream.
|
193
|
+
def new_video
|
194
|
+
FFMpegCommand << "-newvideo"
|
195
|
+
end
|
69
196
|
end
|
70
197
|
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe "FFMpeg Audio Options" do
|
4
|
+
before(:each) do
|
5
|
+
@from_file, @to_file = "~/Desktop/test.avi", "~/Desktop/test2.avi"
|
6
|
+
FFMpegCommand.clear
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should set number of frames to record" do
|
10
|
+
convert @from_file, :to => @to_file do
|
11
|
+
audio_frames 200
|
12
|
+
end
|
13
|
+
|
14
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -aframes 200 #{@to_file}")
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should set sampling frequency" do
|
18
|
+
convert @from_file, :to => @to_file do
|
19
|
+
audio_sampling 22050
|
20
|
+
end
|
21
|
+
|
22
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -ar 22050 #{@to_file}")
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should set bitrate" do
|
26
|
+
convert @from_file, :to => @to_file do
|
27
|
+
audio_bitrate "128k"
|
28
|
+
end
|
29
|
+
|
30
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -ab 128k #{@to_file}")
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should set number of channels" do
|
34
|
+
convert @from_file, :to => @to_file do
|
35
|
+
audio_channels 2
|
36
|
+
end
|
37
|
+
|
38
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -ac 2 #{@to_file}")
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should disable recording" do
|
42
|
+
convert @from_file, :to => @to_file do
|
43
|
+
disable_audio
|
44
|
+
end
|
45
|
+
|
46
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -an #{@to_file}")
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should set the codec explicitly" do
|
50
|
+
convert @from_file, :to => @to_file do
|
51
|
+
audio_codec "mp3"
|
52
|
+
end
|
53
|
+
|
54
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -acodec mp3 #{@to_file}")
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should set that a new audio stream is being added to the current output stream" do
|
58
|
+
convert @from_file, :to => @to_file do
|
59
|
+
new_audio
|
60
|
+
end
|
61
|
+
|
62
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -newaudio #{@to_file}")
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should set the language code" do
|
66
|
+
convert @from_file, :to => @to_file do
|
67
|
+
audio_language "eng"
|
68
|
+
end
|
69
|
+
|
70
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -alang eng #{@to_file}")
|
71
|
+
end
|
72
|
+
end
|
data/spec/ffmpeg_spec.rb
CHANGED
@@ -38,7 +38,7 @@ describe "FFMpeg Main Options" do
|
|
38
38
|
duration "00:03:01"
|
39
39
|
end
|
40
40
|
|
41
|
-
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file}
|
41
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -t 00:03:01 #{@to_file}")
|
42
42
|
end
|
43
43
|
|
44
44
|
it "should set a file size limit" do
|
@@ -46,7 +46,7 @@ describe "FFMpeg Main Options" do
|
|
46
46
|
file_size_limit 104_857_600
|
47
47
|
end
|
48
48
|
|
49
|
-
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} #{@to_file}
|
49
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -fs 104857600 #{@to_file}")
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should seek to the specified time position" do
|
@@ -54,7 +54,7 @@ describe "FFMpeg Main Options" do
|
|
54
54
|
seek "00:03:01"
|
55
55
|
end
|
56
56
|
|
57
|
-
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file}
|
57
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -ss 00:03:01 #{@to_file}")
|
58
58
|
end
|
59
59
|
|
60
60
|
it "should the input time offset" do
|
@@ -62,7 +62,7 @@ describe "FFMpeg Main Options" do
|
|
62
62
|
offset "00:03:01"
|
63
63
|
end
|
64
64
|
|
65
|
-
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file}
|
65
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -itsoffset 00:03:01 #{@to_file}")
|
66
66
|
end
|
67
67
|
|
68
68
|
it "should the title" do
|
@@ -70,7 +70,7 @@ describe "FFMpeg Main Options" do
|
|
70
70
|
title "Some Title"
|
71
71
|
end
|
72
72
|
|
73
|
-
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file}
|
73
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -title 'Some Title' #{@to_file}")
|
74
74
|
end
|
75
75
|
|
76
76
|
it "should the author" do
|
@@ -78,7 +78,7 @@ describe "FFMpeg Main Options" do
|
|
78
78
|
author "PMH"
|
79
79
|
end
|
80
80
|
|
81
|
-
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file}
|
81
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -author 'PMH' #{@to_file}")
|
82
82
|
end
|
83
83
|
|
84
84
|
it "should the copyright" do
|
@@ -86,7 +86,7 @@ describe "FFMpeg Main Options" do
|
|
86
86
|
copyright "(c) Patrik Hedman 2009"
|
87
87
|
end
|
88
88
|
|
89
|
-
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file}
|
89
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -copyright '(c) Patrik Hedman 2009' #{@to_file}")
|
90
90
|
end
|
91
91
|
|
92
92
|
it "should the comment" do
|
@@ -94,7 +94,7 @@ describe "FFMpeg Main Options" do
|
|
94
94
|
comment "Some Comment"
|
95
95
|
end
|
96
96
|
|
97
|
-
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file}
|
97
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -comment 'Some Comment' #{@to_file}")
|
98
98
|
end
|
99
99
|
|
100
100
|
it "should the album" do
|
@@ -102,7 +102,7 @@ describe "FFMpeg Main Options" do
|
|
102
102
|
album "An awesome album"
|
103
103
|
end
|
104
104
|
|
105
|
-
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file}
|
105
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -album 'An awesome album' #{@to_file}")
|
106
106
|
end
|
107
107
|
|
108
108
|
it "should the track" do
|
@@ -110,7 +110,7 @@ describe "FFMpeg Main Options" do
|
|
110
110
|
track 1
|
111
111
|
end
|
112
112
|
|
113
|
-
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} #{@to_file}
|
113
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -track 1 #{@to_file}")
|
114
114
|
end
|
115
115
|
|
116
116
|
it "should the year" do
|
@@ -118,7 +118,7 @@ describe "FFMpeg Main Options" do
|
|
118
118
|
year 1985
|
119
119
|
end
|
120
120
|
|
121
|
-
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} #{@to_file}
|
121
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -year 1985 #{@to_file}")
|
122
122
|
end
|
123
123
|
|
124
124
|
it "should the target" do
|
@@ -126,7 +126,7 @@ describe "FFMpeg Main Options" do
|
|
126
126
|
target "vcd"
|
127
127
|
end
|
128
128
|
|
129
|
-
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} #{@to_file}
|
129
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -target vcd #{@to_file}")
|
130
130
|
end
|
131
131
|
|
132
132
|
it "should the number of frames to record" do
|
@@ -134,7 +134,7 @@ describe "FFMpeg Main Options" do
|
|
134
134
|
frames_to_record 50
|
135
135
|
end
|
136
136
|
|
137
|
-
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} #{@to_file}
|
137
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -dframes 50 #{@to_file}")
|
138
138
|
end
|
139
139
|
|
140
140
|
it "should set the subtitle codec" do
|
@@ -142,21 +142,6 @@ describe "FFMpeg Main Options" do
|
|
142
142
|
subtitle_codec 'copy'
|
143
143
|
end
|
144
144
|
|
145
|
-
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} #{@to_file}
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
describe "FFMpeg Video Options" do
|
150
|
-
before(:each) do
|
151
|
-
@from_file, @to_file = "~/Desktop/test.avi", "~/Desktop/test2.avi"
|
152
|
-
FFMpegCommand.clear
|
153
|
-
end
|
154
|
-
|
155
|
-
it "should set the resolution" do
|
156
|
-
convert @from_file, :to => @to_file do
|
157
|
-
resolution "vga"
|
158
|
-
end
|
159
|
-
|
160
|
-
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} #{@to_file} -s vga")
|
145
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -scodec copy #{@to_file}")
|
161
146
|
end
|
162
147
|
end
|
@@ -0,0 +1,200 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe "FFMpeg Video Options" do
|
4
|
+
before(:each) do
|
5
|
+
@from_file, @to_file = "~/Desktop/test.avi", "~/Desktop/test2.avi"
|
6
|
+
FFMpegCommand.clear
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should set the resolution" do
|
10
|
+
convert @from_file, :to => @to_file do
|
11
|
+
resolution "vga"
|
12
|
+
end
|
13
|
+
|
14
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -s vga #{@to_file}")
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should set the video bitrate" do
|
18
|
+
convert @from_file, :to => @to_file do
|
19
|
+
video_bitrate "200k"
|
20
|
+
end
|
21
|
+
|
22
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -vb 200k #{@to_file}")
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should set the number of video frames to record" do
|
26
|
+
convert @from_file, :to => @to_file do
|
27
|
+
video_frames 200
|
28
|
+
end
|
29
|
+
|
30
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -vframes 200 #{@to_file}")
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should set framerate" do
|
34
|
+
convert @from_file, :to => @to_file do
|
35
|
+
framerate 24
|
36
|
+
end
|
37
|
+
|
38
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -r 24 #{@to_file}")
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should set aspect ratio" do
|
42
|
+
convert @from_file, :to => @to_file do
|
43
|
+
aspect "4:3"
|
44
|
+
end
|
45
|
+
|
46
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -aspect 4:3 #{@to_file}")
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should set size of top crop band" do
|
50
|
+
convert @from_file, :to => @to_file do
|
51
|
+
crop_top 20
|
52
|
+
end
|
53
|
+
|
54
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -croptop 20 #{@to_file}")
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should set size of bottom crop band" do
|
58
|
+
convert @from_file, :to => @to_file do
|
59
|
+
crop_bottom 20
|
60
|
+
end
|
61
|
+
|
62
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -cropbottom 20 #{@to_file}")
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should set size of left crop band" do
|
66
|
+
convert @from_file, :to => @to_file do
|
67
|
+
crop_left 20
|
68
|
+
end
|
69
|
+
|
70
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -cropleft 20 #{@to_file}")
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should set size of right crop band" do
|
74
|
+
convert @from_file, :to => @to_file do
|
75
|
+
crop_right 20
|
76
|
+
end
|
77
|
+
|
78
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -cropright 20 #{@to_file}")
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should set size of top pad band" do
|
82
|
+
convert @from_file, :to => @to_file do
|
83
|
+
pad_top 20
|
84
|
+
end
|
85
|
+
|
86
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -padtop 20 #{@to_file}")
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should set size of bottom pad band" do
|
90
|
+
convert @from_file, :to => @to_file do
|
91
|
+
pad_bottom 20
|
92
|
+
end
|
93
|
+
|
94
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -padbottom 20 #{@to_file}")
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should set size of left pad band" do
|
98
|
+
convert @from_file, :to => @to_file do
|
99
|
+
pad_left 20
|
100
|
+
end
|
101
|
+
|
102
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -padleft 20 #{@to_file}")
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should set size of right pad band" do
|
106
|
+
convert @from_file, :to => @to_file do
|
107
|
+
pad_right 20
|
108
|
+
end
|
109
|
+
|
110
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -padright 20 #{@to_file}")
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should set color for padded bands" do
|
114
|
+
convert @from_file, :to => @to_file do
|
115
|
+
pad_color "ffffff"
|
116
|
+
end
|
117
|
+
|
118
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -padcolor ffffff #{@to_file}")
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should disable video encoding" do
|
122
|
+
convert @from_file, :to => @to_file do
|
123
|
+
disable_video
|
124
|
+
end
|
125
|
+
|
126
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -vn #{@to_file}")
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should set the bitrate tolerance" do
|
130
|
+
convert @from_file, :to => @to_file do
|
131
|
+
video_bitrate_tolerance "8000k"
|
132
|
+
end
|
133
|
+
|
134
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -bt 8000k #{@to_file}")
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should set maximum bitrate" do
|
138
|
+
convert @from_file, :to => @to_file do
|
139
|
+
video_maximum_bitrate "1000k"
|
140
|
+
end
|
141
|
+
|
142
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -maxrate 1000k #{@to_file}")
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should set minimum bitrate" do
|
146
|
+
convert @from_file, :to => @to_file do
|
147
|
+
video_minimum_bitrate "5000k"
|
148
|
+
end
|
149
|
+
|
150
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -minrate 5000k #{@to_file}")
|
151
|
+
end
|
152
|
+
|
153
|
+
it "should set buffer verifier size" do
|
154
|
+
convert @from_file, :to => @to_file do
|
155
|
+
video_buffer_size "2M"
|
156
|
+
end
|
157
|
+
|
158
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -bufsize 2M #{@to_file}")
|
159
|
+
end
|
160
|
+
|
161
|
+
it "should set the codec explicitly" do
|
162
|
+
convert @from_file, :to => @to_file do
|
163
|
+
video_codec "x264"
|
164
|
+
end
|
165
|
+
|
166
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -vcodec x264 #{@to_file}")
|
167
|
+
end
|
168
|
+
|
169
|
+
it "should set same quality encoding flag" do
|
170
|
+
convert @from_file, :to => @to_file do
|
171
|
+
same_video_quality
|
172
|
+
end
|
173
|
+
|
174
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -sameq #{@to_file}")
|
175
|
+
end
|
176
|
+
|
177
|
+
it "should set the pass number for encoding" do
|
178
|
+
convert @from_file, :to => @to_file do
|
179
|
+
video_pass 2
|
180
|
+
end
|
181
|
+
|
182
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -pass 2 #{@to_file}")
|
183
|
+
end
|
184
|
+
|
185
|
+
it "should set the logfile prefix for multi-pass encoding" do
|
186
|
+
convert @from_file, :to => @to_file do
|
187
|
+
video_pass_logfile "test"
|
188
|
+
end
|
189
|
+
|
190
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -passlogfile test #{@to_file}")
|
191
|
+
end
|
192
|
+
|
193
|
+
it "should set that a new video stream is being added to the current output stream" do
|
194
|
+
convert @from_file, :to => @to_file do
|
195
|
+
new_video
|
196
|
+
end
|
197
|
+
|
198
|
+
FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -newvideo #{@to_file}")
|
199
|
+
end
|
200
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polly-ffmpeg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrik Hedman
|
@@ -9,35 +9,35 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-03
|
12
|
+
date: 2009-07-03 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
16
|
-
description:
|
16
|
+
description: Need to write one
|
17
17
|
email: patrik@moresale.se
|
18
18
|
executables: []
|
19
19
|
|
20
20
|
extensions: []
|
21
21
|
|
22
|
-
extra_rdoc_files:
|
23
|
-
|
22
|
+
extra_rdoc_files:
|
23
|
+
- LICENSE
|
24
|
+
- README.rdoc
|
24
25
|
files:
|
26
|
+
- LICENSE
|
25
27
|
- README.rdoc
|
26
|
-
-
|
27
|
-
-
|
28
|
+
- Rakefile
|
29
|
+
- ffmpeg.gemspec
|
30
|
+
- lib/ffmpeg.rb
|
31
|
+
- lib/ffmpeg/audio_options.rb
|
28
32
|
- lib/ffmpeg/class_methods.rb
|
29
33
|
- lib/ffmpeg/ffmpeg_command.rb
|
30
34
|
- lib/ffmpeg/helper_methods.rb
|
31
35
|
- lib/ffmpeg/main_options.rb
|
32
36
|
- lib/ffmpeg/video_options.rb
|
33
|
-
|
34
|
-
- spec/ffmpeg_spec.rb
|
35
|
-
- spec/spec_helper.rb
|
36
|
-
has_rdoc: true
|
37
|
+
has_rdoc: false
|
37
38
|
homepage: http://github.com/polly/ffmpeg
|
38
39
|
post_install_message:
|
39
40
|
rdoc_options:
|
40
|
-
- --inline-source
|
41
41
|
- --charset=UTF-8
|
42
42
|
require_paths:
|
43
43
|
- lib
|
@@ -58,7 +58,10 @@ requirements: []
|
|
58
58
|
rubyforge_project:
|
59
59
|
rubygems_version: 1.2.0
|
60
60
|
signing_key:
|
61
|
-
specification_version:
|
62
|
-
summary:
|
63
|
-
test_files:
|
64
|
-
|
61
|
+
specification_version: 3
|
62
|
+
summary: Need to write one
|
63
|
+
test_files:
|
64
|
+
- spec/audio_options_spec.rb
|
65
|
+
- spec/ffmpeg_spec.rb
|
66
|
+
- spec/spec_helper.rb
|
67
|
+
- spec/video_options_spec.rb
|
data/VERSION.yml
DELETED