polly-ffmpeg 0.1.7 → 0.1.8

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/README.textile ADDED
@@ -0,0 +1,30 @@
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
+ include FFMpeg
18
+
19
+ convert "file.ext", :to => "new_file.ext" do
20
+ <span>&nbsp;&nbsp;&nbsp;&nbsp;seek "00:01:13"</span>
21
+ <span>&nbsp;&nbsp;&nbsp;&nbsp;duration "00:10:01"</span>
22
+ end.run
23
+
24
+ For more information checkout the "documentation":http://polly.github.com/ffmpeg/
25
+
26
+
27
+ h2. Credit where credit's due
28
+
29
+ Thank's to "jwthompson2":http://github.com/jwthompson2, there's now support for all of the standard video and audio options from the ffmpeg documentation as well
30
+ as improved and refactored specs.
data/ffmpeg.gemspec CHANGED
@@ -2,20 +2,20 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{ffmpeg}
5
- s.version = "0.1.7"
5
+ s.version = "0.1.8"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Patrik Hedman"]
9
9
  s.date = %q{2009-07-03}
10
- s.description = %q{Need to write one}
10
+ s.description = %q{A DSL for building and executing ffmpeg commands}
11
11
  s.email = %q{patrik@moresale.se}
12
12
  s.extra_rdoc_files = [
13
13
  "LICENSE",
14
- "README.rdoc"
14
+ "README.textile"
15
15
  ]
16
16
  s.files = [
17
17
  "LICENSE",
18
- "README.rdoc",
18
+ "README.textile",
19
19
  "Rakefile",
20
20
  "ffmpeg.gemspec",
21
21
  "lib/ffmpeg.rb",
data/lib/ffmpeg.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'ffmpeg/class_methods'
2
2
  require 'ffmpeg/main_options'
3
+ require 'ffmpeg/file_extensions'
3
4
  require 'ffmpeg/video_options'
4
5
  require 'ffmpeg/audio_options'
5
6
  require 'ffmpeg/ffmpeg_command'
@@ -45,7 +46,10 @@ module FFMpeg
45
46
  disable_method_checking!
46
47
  raise exception
47
48
  end
48
- FFMpegCommand << "#{to_file[:to]}" unless to_file[:to].nil?
49
+
50
+ build_output_file_name(from_file, to_file[:to]) do |file_name|
51
+ FFMpegCommand << file_name
52
+ end
49
53
  end
50
54
 
51
55
  #
@@ -56,7 +60,7 @@ module FFMpeg
56
60
  end
57
61
 
58
62
  #
59
- # Ru§ns ffmpeg
63
+ # Runs ffmpeg
60
64
  #
61
65
  def run
62
66
  @@ffmpeg_path ||= locate_ffmpeg
@@ -70,6 +74,15 @@ module FFMpeg
70
74
 
71
75
  private
72
76
 
77
+ def build_output_file_name(from_file, to_file)
78
+ return if to_file.nil?
79
+ if FileExtensions::EXT.include?(to_file.to_s)
80
+ yield "#{from_file.delete(File.extname(from_file))}.#{to_file}"
81
+ else
82
+ yield "#{to_file}"
83
+ end
84
+ end
85
+
73
86
  #
74
87
  # Checks if the thread local varialble 'method checking disabled'
75
88
  # is true or false
data/spec/ffmpeg_spec.rb CHANGED
@@ -17,6 +17,18 @@ describe "FFMpeg" do
17
17
 
18
18
  FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} #{@to_file}")
19
19
  end
20
+
21
+ it "should generate a valid command when fed only an extensions as :to" do
22
+ convert @from_file, :to => :mp4
23
+
24
+ FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} #{@from_file.delete(File.extname(@from_file))}.mp4")
25
+ end
26
+
27
+ it "should generate a valid command without specifying :to" do
28
+ convert @from_file
29
+
30
+ FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file}")
31
+ end
20
32
  end
21
33
 
22
34
  describe "FFMpeg Main Options" do
@@ -144,4 +156,4 @@ describe "FFMpeg Main Options" do
144
156
 
145
157
  FFMpegCommand.command("ffmpeg").should eql("ffmpeg -i #{@from_file} -scodec copy #{@to_file}")
146
158
  end
147
- end
159
+ 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.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrik Hedman
@@ -13,7 +13,7 @@ date: 2009-07-03 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
16
- description: Need to write one
16
+ description: A DSL for building and executing ffmpeg commands
17
17
  email: patrik@moresale.se
18
18
  executables: []
19
19
 
@@ -21,10 +21,10 @@ extensions: []
21
21
 
22
22
  extra_rdoc_files:
23
23
  - LICENSE
24
- - README.rdoc
24
+ - README.textile
25
25
  files:
26
26
  - LICENSE
27
- - README.rdoc
27
+ - README.textile
28
28
  - Rakefile
29
29
  - ffmpeg.gemspec
30
30
  - lib/ffmpeg.rb
data/README.rdoc DELETED
@@ -1,46 +0,0 @@
1
- = FFMpeg
2
-
3
- A DSL for building and executing ffmpeg commands.
4
-
5
- == Requirements
6
-
7
- It requires that you already have ffmpeg installed, obviously :)
8
-
9
- == Install
10
-
11
- gem install polly-ffmpeg --source http://gems.github.com
12
-
13
- == 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
- 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
-
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
-
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
-
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.
42
-
43
- == Credit where credit's due
44
-
45
- Thank's to jwthompson2 (http://github.com/jwthompson2), there's now support for all of the standard video and
46
- audio options from the ffmpeg documentation as well as improved and refactored specs.