ffmpeg 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/LICENSE +20 -0
- data/README.textile +45 -0
- data/Rakefile +45 -0
- data/VERSION.yml +5 -0
- data/features/ffmpeg.feature +9 -0
- data/features/steps/ffmpeg_steps.rb +0 -0
- data/features/support/env.rb +11 -0
- data/ffmpeg.gemspec +86 -0
- data/lib/ffmpeg.rb +121 -0
- data/lib/ffmpeg/audio_options.rb +47 -0
- data/lib/ffmpeg/class_methods.rb +18 -0
- data/lib/ffmpeg/ffmpeg_command.rb +25 -0
- data/lib/ffmpeg/file_extensions.rb +150 -0
- data/lib/ffmpeg/helper_methods.rb +8 -0
- data/lib/ffmpeg/main_options.rb +165 -0
- data/lib/ffmpeg/meta_data.rb +22 -0
- data/lib/ffmpeg/video_advanced_options.rb +275 -0
- data/lib/ffmpeg/video_options.rb +197 -0
- data/rdoc/classes/FFMpeg.html +250 -0
- data/rdoc/classes/FFMpeg.src/M000005.html +27 -0
- data/rdoc/classes/FFMpeg.src/M000006.html +29 -0
- data/rdoc/classes/FFMpeg.src/M000007.html +18 -0
- data/rdoc/classes/FFMpeg.src/M000008.html +24 -0
- data/rdoc/classes/FFMpeg/AudioOptions.html +269 -0
- data/rdoc/classes/FFMpeg/AudioOptions.src/M000093.html +18 -0
- data/rdoc/classes/FFMpeg/AudioOptions.src/M000094.html +18 -0
- data/rdoc/classes/FFMpeg/AudioOptions.src/M000095.html +18 -0
- data/rdoc/classes/FFMpeg/AudioOptions.src/M000096.html +18 -0
- data/rdoc/classes/FFMpeg/AudioOptions.src/M000097.html +18 -0
- data/rdoc/classes/FFMpeg/AudioOptions.src/M000098.html +18 -0
- data/rdoc/classes/FFMpeg/AudioOptions.src/M000099.html +18 -0
- data/rdoc/classes/FFMpeg/AudioOptions.src/M000100.html +18 -0
- data/rdoc/classes/FFMpeg/ClassMethods.html +131 -0
- data/rdoc/classes/FFMpeg/ClassMethods.src/M000049.html +18 -0
- data/rdoc/classes/FFMpeg/HelperMethods.html +131 -0
- data/rdoc/classes/FFMpeg/HelperMethods.src/M000074.html +19 -0
- data/rdoc/classes/FFMpeg/MainOptions.html +494 -0
- data/rdoc/classes/FFMpeg/MainOptions.src/M000075.html +18 -0
- data/rdoc/classes/FFMpeg/MainOptions.src/M000076.html +18 -0
- data/rdoc/classes/FFMpeg/MainOptions.src/M000077.html +18 -0
- data/rdoc/classes/FFMpeg/MainOptions.src/M000078.html +18 -0
- data/rdoc/classes/FFMpeg/MainOptions.src/M000079.html +18 -0
- data/rdoc/classes/FFMpeg/MainOptions.src/M000080.html +18 -0
- data/rdoc/classes/FFMpeg/MainOptions.src/M000081.html +18 -0
- data/rdoc/classes/FFMpeg/MainOptions.src/M000082.html +18 -0
- data/rdoc/classes/FFMpeg/MainOptions.src/M000083.html +18 -0
- data/rdoc/classes/FFMpeg/MainOptions.src/M000084.html +18 -0
- data/rdoc/classes/FFMpeg/MainOptions.src/M000085.html +18 -0
- data/rdoc/classes/FFMpeg/MainOptions.src/M000086.html +18 -0
- data/rdoc/classes/FFMpeg/MainOptions.src/M000087.html +18 -0
- data/rdoc/classes/FFMpeg/MainOptions.src/M000088.html +18 -0
- data/rdoc/classes/FFMpeg/MainOptions.src/M000089.html +18 -0
- data/rdoc/classes/FFMpeg/MainOptions.src/M000090.html +18 -0
- data/rdoc/classes/FFMpeg/MainOptions.src/M000091.html +18 -0
- data/rdoc/classes/FFMpeg/MetaData.html +151 -0
- data/rdoc/classes/FFMpeg/MetaData.src/M000092.html +24 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.html +924 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000009.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000010.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000011.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000012.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000013.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000014.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000015.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000016.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000017.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000018.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000019.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000020.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000021.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000022.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000023.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000024.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000025.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000026.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000027.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000028.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000029.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000030.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000031.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000032.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000033.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000034.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000035.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000036.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000037.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000038.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000039.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000040.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000041.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000042.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000043.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000044.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000045.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000046.html +22 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000047.html +18 -0
- data/rdoc/classes/FFMpeg/VideoAdvancedOptions.src/M000048.html +18 -0
- data/rdoc/classes/FFMpeg/VideoOptions.html +630 -0
- data/rdoc/classes/FFMpeg/VideoOptions.src/M000050.html +18 -0
- data/rdoc/classes/FFMpeg/VideoOptions.src/M000051.html +18 -0
- data/rdoc/classes/FFMpeg/VideoOptions.src/M000052.html +18 -0
- data/rdoc/classes/FFMpeg/VideoOptions.src/M000053.html +18 -0
- data/rdoc/classes/FFMpeg/VideoOptions.src/M000054.html +18 -0
- data/rdoc/classes/FFMpeg/VideoOptions.src/M000055.html +18 -0
- data/rdoc/classes/FFMpeg/VideoOptions.src/M000056.html +18 -0
- data/rdoc/classes/FFMpeg/VideoOptions.src/M000057.html +18 -0
- data/rdoc/classes/FFMpeg/VideoOptions.src/M000058.html +18 -0
- data/rdoc/classes/FFMpeg/VideoOptions.src/M000059.html +18 -0
- data/rdoc/classes/FFMpeg/VideoOptions.src/M000060.html +18 -0
- data/rdoc/classes/FFMpeg/VideoOptions.src/M000061.html +18 -0
- data/rdoc/classes/FFMpeg/VideoOptions.src/M000062.html +18 -0
- data/rdoc/classes/FFMpeg/VideoOptions.src/M000063.html +18 -0
- data/rdoc/classes/FFMpeg/VideoOptions.src/M000064.html +18 -0
- data/rdoc/classes/FFMpeg/VideoOptions.src/M000065.html +18 -0
- data/rdoc/classes/FFMpeg/VideoOptions.src/M000066.html +18 -0
- data/rdoc/classes/FFMpeg/VideoOptions.src/M000067.html +18 -0
- data/rdoc/classes/FFMpeg/VideoOptions.src/M000068.html +18 -0
- data/rdoc/classes/FFMpeg/VideoOptions.src/M000069.html +18 -0
- data/rdoc/classes/FFMpeg/VideoOptions.src/M000070.html +18 -0
- data/rdoc/classes/FFMpeg/VideoOptions.src/M000071.html +18 -0
- data/rdoc/classes/FFMpeg/VideoOptions.src/M000072.html +18 -0
- data/rdoc/classes/FFMpeg/VideoOptions.src/M000073.html +18 -0
- data/rdoc/classes/FFMpegCommand.html +176 -0
- data/rdoc/classes/FFMpegCommand.src/M000001.html +18 -0
- data/rdoc/classes/FFMpegCommand.src/M000002.html +18 -0
- data/rdoc/classes/FFMpegCommand.src/M000003.html +18 -0
- data/rdoc/classes/FFMpegCommand.src/M000004.html +22 -0
- data/rdoc/classes/FileExtensions.html +118 -0
- data/rdoc/created.rid +1 -0
- data/rdoc/files/README_textile.html +171 -0
- data/rdoc/files/lib/ffmpeg/audio_options_rb.html +101 -0
- data/rdoc/files/lib/ffmpeg/class_methods_rb.html +101 -0
- data/rdoc/files/lib/ffmpeg/ffmpeg_command_rb.html +101 -0
- data/rdoc/files/lib/ffmpeg/file_extensions_rb.html +101 -0
- data/rdoc/files/lib/ffmpeg/helper_methods_rb.html +101 -0
- data/rdoc/files/lib/ffmpeg/main_options_rb.html +101 -0
- data/rdoc/files/lib/ffmpeg/meta_data_rb.html +101 -0
- data/rdoc/files/lib/ffmpeg/video_advanced_options_rb.html +101 -0
- data/rdoc/files/lib/ffmpeg/video_options_rb.html +101 -0
- data/rdoc/files/lib/ffmpeg_rb.html +116 -0
- data/rdoc/fr_class_index.html +36 -0
- data/rdoc/fr_file_index.html +36 -0
- data/rdoc/fr_method_index.html +126 -0
- data/rdoc/index.html +24 -0
- data/rdoc/rdoc-style.css +208 -0
- data/spec/audio_options_spec.rb +72 -0
- data/spec/ffmpeg_spec.rb +161 -0
- data/spec/files/terminal.mpg +0 -0
- data/spec/meta_spec.rb +15 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/video_advanced_options_spec.rb +349 -0
- data/spec/video_options_spec.rb +200 -0
- metadata +213 -0
data/.gitignore
ADDED
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.textile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
h2. FFMpeg
|
2
|
+
|
3
|
+
A DSL for building and executing ffmpeg commands.
|
4
|
+
|
5
|
+
h2. Requirements
|
6
|
+
|
7
|
+
It requires that you already have ffmpeg installed, obviously :)
|
8
|
+
|
9
|
+
h2. Install
|
10
|
+
|
11
|
+
gem install polly-ffmpeg --source http://gems.github.com
|
12
|
+
|
13
|
+
h2. Usage
|
14
|
+
|
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
|
+
require "rubygems"
|
18
|
+
require "ffmpeg"
|
19
|
+
include FFMpeg
|
20
|
+
|
21
|
+
convert "file.ext", :to => "new_file.ext" do
|
22
|
+
<span> seek "00:01:13"</span>
|
23
|
+
<span> duration "00:10:01"</span>
|
24
|
+
end.run
|
25
|
+
|
26
|
+
If you want the output file to have the same name as the input file it's enough to just specify the new file extension like this:
|
27
|
+
|
28
|
+
require "rubygems"
|
29
|
+
require "ffmpeg"
|
30
|
+
include FFMpeg
|
31
|
+
|
32
|
+
convert "finding_that_nemo_dude.avi", :to => :flv do
|
33
|
+
<span> ...</span>
|
34
|
+
end
|
35
|
+
|
36
|
+
This will produce an output file called finding_that_nemo_dude.flv
|
37
|
+
|
38
|
+
For more information checkout the "documentation":http://polly.github.com/ffmpeg/ or my "blog":http://pastbedti.me/
|
39
|
+
|
40
|
+
h2. Credit where credit's due
|
41
|
+
|
42
|
+
Thank's to "jwthompson2":http://github.com/jwthompson2 there's now support for all of the standard video and audio options and most of the advanced video options from the ffmpeg documentation as well
|
43
|
+
as improved and refactored specs.
|
44
|
+
|
45
|
+
Thanks to "jamesdaniels":http://github.com/jamesdaniels for fixing a nasty output path error while using the :to => extension option
|
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{A dsl for building and executing ffmpeg commands}
|
8
|
+
s.email = "patrik@moresale.se"
|
9
|
+
s.homepage = "http://github.com/polly/ffmpeg"
|
10
|
+
s.description = "A dsl for building and executing ffmpeg commands"
|
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/VERSION.yml
ADDED
File without changes
|
data/ffmpeg.gemspec
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{ffmpeg}
|
5
|
+
s.version = "0.2.1"
|
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-08-16}
|
10
|
+
s.description = %q{A DSL for building and executing ffmpeg commands}
|
11
|
+
s.email = %q{patrik@moresale.se}
|
12
|
+
s.extra_rdoc_files = [
|
13
|
+
"LICENSE",
|
14
|
+
"README.textile"
|
15
|
+
]
|
16
|
+
s.files = [
|
17
|
+
".gitignore",
|
18
|
+
"LICENSE",
|
19
|
+
"README.textile",
|
20
|
+
"Rakefile",
|
21
|
+
"VERSION.yml",
|
22
|
+
"features/ffmpeg.feature",
|
23
|
+
"features/steps/ffmpeg_steps.rb",
|
24
|
+
"features/support/env.rb",
|
25
|
+
"ffmpeg.gemspec",
|
26
|
+
"lib/ffmpeg.rb",
|
27
|
+
"lib/ffmpeg/audio_options.rb",
|
28
|
+
"lib/ffmpeg/class_methods.rb",
|
29
|
+
"lib/ffmpeg/ffmpeg_command.rb",
|
30
|
+
"lib/ffmpeg/file_extensions.rb",
|
31
|
+
"lib/ffmpeg/helper_methods.rb",
|
32
|
+
"lib/ffmpeg/main_options.rb",
|
33
|
+
"lib/ffmpeg/video_advanced_options.rb",
|
34
|
+
"lib/ffmpeg/video_options.rb",
|
35
|
+
"rdoc/classes/FFMpeg.html",
|
36
|
+
"rdoc/classes/FFMpeg/AudioOptions.html",
|
37
|
+
"rdoc/classes/FFMpeg/ClassMethods.html",
|
38
|
+
"rdoc/classes/FFMpeg/HelperMethods.html",
|
39
|
+
"rdoc/classes/FFMpeg/MainOptions.html",
|
40
|
+
"rdoc/classes/FFMpeg/VideoOptions.html",
|
41
|
+
"rdoc/classes/FFMpegCommand.html",
|
42
|
+
"rdoc/classes/FileExtensions.html",
|
43
|
+
"rdoc/created.rid",
|
44
|
+
"rdoc/files/README_textile.html",
|
45
|
+
"rdoc/files/lib/ffmpeg/audio_options_rb.html",
|
46
|
+
"rdoc/files/lib/ffmpeg/class_methods_rb.html",
|
47
|
+
"rdoc/files/lib/ffmpeg/ffmpeg_command_rb.html",
|
48
|
+
"rdoc/files/lib/ffmpeg/file_extensions_rb.html",
|
49
|
+
"rdoc/files/lib/ffmpeg/helper_methods_rb.html",
|
50
|
+
"rdoc/files/lib/ffmpeg/main_options_rb.html",
|
51
|
+
"rdoc/files/lib/ffmpeg/video_options_rb.html",
|
52
|
+
"rdoc/files/lib/ffmpeg_rb.html",
|
53
|
+
"rdoc/fr_class_index.html",
|
54
|
+
"rdoc/fr_file_index.html",
|
55
|
+
"rdoc/fr_method_index.html",
|
56
|
+
"rdoc/index.html",
|
57
|
+
"rdoc/rdoc-style.css",
|
58
|
+
"spec/audio_options_spec.rb",
|
59
|
+
"spec/ffmpeg_spec.rb",
|
60
|
+
"spec/spec_helper.rb",
|
61
|
+
"spec/video_advanced_options_spec.rb",
|
62
|
+
"spec/video_options_spec.rb"
|
63
|
+
]
|
64
|
+
s.homepage = %q{http://github.com/polly/ffmpeg}
|
65
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
66
|
+
s.require_paths = ["lib"]
|
67
|
+
s.rubygems_version = %q{1.3.3}
|
68
|
+
s.summary = %q{A dsl for building and executing ffmpeg commands}
|
69
|
+
s.test_files = [
|
70
|
+
"spec/audio_options_spec.rb",
|
71
|
+
"spec/ffmpeg_spec.rb",
|
72
|
+
"spec/spec_helper.rb",
|
73
|
+
"spec/video_advanced_options_spec.rb",
|
74
|
+
"spec/video_options_spec.rb"
|
75
|
+
]
|
76
|
+
|
77
|
+
if s.respond_to? :specification_version then
|
78
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
79
|
+
s.specification_version = 3
|
80
|
+
|
81
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
82
|
+
else
|
83
|
+
end
|
84
|
+
else
|
85
|
+
end
|
86
|
+
end
|
data/lib/ffmpeg.rb
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
require 'ffmpeg/class_methods'
|
2
|
+
require 'ffmpeg/main_options'
|
3
|
+
require 'ffmpeg/file_extensions'
|
4
|
+
require 'ffmpeg/video_options'
|
5
|
+
require 'ffmpeg/video_advanced_options'
|
6
|
+
require 'ffmpeg/audio_options'
|
7
|
+
require 'ffmpeg/ffmpeg_command'
|
8
|
+
require 'ffmpeg/helper_methods'
|
9
|
+
require 'ffmpeg/meta_data'
|
10
|
+
|
11
|
+
module FFMpeg
|
12
|
+
include HelperMethods
|
13
|
+
include MainOptions
|
14
|
+
include VideoOptions
|
15
|
+
include VideoAdvancedOptions
|
16
|
+
include AudioOptions
|
17
|
+
include MetaData
|
18
|
+
|
19
|
+
#
|
20
|
+
# When mixed into a class, extend
|
21
|
+
# it with the ClassMethods module
|
22
|
+
#
|
23
|
+
def self.included(klass)
|
24
|
+
klass.extend ClassMethods
|
25
|
+
|
26
|
+
#
|
27
|
+
# Everytime a method is added to the
|
28
|
+
# class, check for conflicts with existing
|
29
|
+
# module methods
|
30
|
+
#
|
31
|
+
def klass.method_added(name)
|
32
|
+
check_method(name) if method_checking_enabled?
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
#
|
37
|
+
# Sets up an FFmpegCommand for converting files:
|
38
|
+
#
|
39
|
+
# convert "file1.ext", :to => "file2.ext" do
|
40
|
+
# seek "00:03:00"
|
41
|
+
# duration "01:10:00"
|
42
|
+
# resolution "800x600"
|
43
|
+
# end
|
44
|
+
#
|
45
|
+
def convert(from_file, to_file = {})
|
46
|
+
@from_file = from_file
|
47
|
+
FFMpegCommand << "-i #{from_file}"
|
48
|
+
begin
|
49
|
+
yield if block_given?
|
50
|
+
rescue Exception => exception
|
51
|
+
disable_method_checking!
|
52
|
+
raise exception
|
53
|
+
end
|
54
|
+
|
55
|
+
build_output_file_name(from_file, to_file[:to]) do |file_name|
|
56
|
+
FFMpegCommand << file_name
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
#
|
61
|
+
# Explicitly set ffmpeg path
|
62
|
+
#
|
63
|
+
def ffmpeg_path(path)
|
64
|
+
@@ffmpeg_path = path
|
65
|
+
end
|
66
|
+
|
67
|
+
#
|
68
|
+
# Runs ffmpeg
|
69
|
+
#
|
70
|
+
def run
|
71
|
+
@@ffmpeg_path ||= locate_ffmpeg
|
72
|
+
unless @@ffmpeg_path.empty?
|
73
|
+
execute_command FFMpegCommand.command(@@ffmpeg_path)
|
74
|
+
else
|
75
|
+
$stderr.puts "Couldn't locate ffmpeg, try to specify an explicit path
|
76
|
+
with the ffmpeg_path(path) method"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
private
|
81
|
+
|
82
|
+
def build_output_file_name(from_file, to_file)
|
83
|
+
return if to_file.nil?
|
84
|
+
if FileExtensions::EXT.include?(to_file.to_s)
|
85
|
+
yield from_file.gsub(/#{File.extname(from_file)}$/, ".#{to_file}")
|
86
|
+
else
|
87
|
+
yield "#{to_file}"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
#
|
92
|
+
# Checks if the thread local varialble 'method checking disabled'
|
93
|
+
# is true or false
|
94
|
+
#
|
95
|
+
def method_checking_enabled?
|
96
|
+
!Thread.current[:'method checking disabled']
|
97
|
+
end
|
98
|
+
|
99
|
+
#
|
100
|
+
# Turns off the method checking functionality
|
101
|
+
#
|
102
|
+
def disable_method_checking!
|
103
|
+
Thread.current[:'method checking disabled'] = true
|
104
|
+
end
|
105
|
+
|
106
|
+
#
|
107
|
+
# Tries to locate the FFmpeg executable
|
108
|
+
#
|
109
|
+
def locate_ffmpeg
|
110
|
+
ffmpeg_executable = %x[which ffmpeg].strip
|
111
|
+
end
|
112
|
+
|
113
|
+
#
|
114
|
+
# Executes FFmpeg with the specified command
|
115
|
+
#
|
116
|
+
def execute_command(cmd)
|
117
|
+
puts "Executing: #{cmd}}"
|
118
|
+
%x[#{cmd}]
|
119
|
+
puts $?.success?
|
120
|
+
end
|
121
|
+
end
|
@@ -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
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module FFMpeg
|
2
|
+
module ClassMethods
|
3
|
+
def check_method(name)
|
4
|
+
print_error_message_for name if method_defined? name
|
5
|
+
end
|
6
|
+
|
7
|
+
def method_defined?(name)
|
8
|
+
FFMpeg.instance_methods.include?(name.to_s) || FFMpeg.instance_methods.include?(name.to_sym)
|
9
|
+
end
|
10
|
+
private :method_defined?
|
11
|
+
|
12
|
+
def print_error_message_for(name)
|
13
|
+
$stderr.puts "WARNING: Possible conflict with FFMpeg extension:" +
|
14
|
+
"FFMpeg##{name} already exists and will be overwritten"
|
15
|
+
end
|
16
|
+
private :print_error_message_for
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module FFMpegCommand
|
2
|
+
extend self
|
3
|
+
|
4
|
+
@commands = []
|
5
|
+
|
6
|
+
def <<(cmd)
|
7
|
+
@commands << cmd
|
8
|
+
end
|
9
|
+
|
10
|
+
def add_at(cmd, pos)
|
11
|
+
@commands.insert(pos, cmd)
|
12
|
+
end
|
13
|
+
|
14
|
+
def clear
|
15
|
+
@commands.clear
|
16
|
+
end
|
17
|
+
|
18
|
+
def command(prefix="")
|
19
|
+
returning prefix.to_s do |prefix|
|
20
|
+
@commands.each do |command|
|
21
|
+
prefix << " #{command}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|