strip_audio 0.0.1
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/.gitignore +23 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/Guardfile +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +26 -0
- data/Rakefile +2 -0
- data/bin/strip_audio +54 -0
- data/lib/strip_audio/exceptions.rb +15 -0
- data/lib/strip_audio/stripper.rb +64 -0
- data/lib/strip_audio/version.rb +3 -0
- data/lib/strip_audio.rb +5 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/stripper_spec.rb +15 -0
- data/strip_audio.gemspec +24 -0
- metadata +113 -0
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
*.swp
|
data/.rspec
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Jikku Jose
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# StripAudio
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Install it yourself as:
|
8
|
+
|
9
|
+
$ gem install strip_audio
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
strip_audio file.mp4 # will produce file.mp3
|
14
|
+
|
15
|
+
## Todo
|
16
|
+
|
17
|
+
* Progress bar denoting status.
|
18
|
+
* Batch processing of all files from location.
|
19
|
+
|
20
|
+
## Contributing
|
21
|
+
|
22
|
+
1. Fork it ( https://github.com/jikkujose/strip_audio/fork )
|
23
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
24
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
25
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
26
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/strip_audio
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'strip_audio'
|
4
|
+
|
5
|
+
module StripAudio
|
6
|
+
|
7
|
+
class InValidArguments < StandardError
|
8
|
+
end
|
9
|
+
|
10
|
+
class CLI
|
11
|
+
|
12
|
+
VIDEO_FORMATS = %w[mp4 avi flv mkv mov]
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
@videos = ARGV
|
16
|
+
|
17
|
+
doctor
|
18
|
+
|
19
|
+
@stripper = Stripper.new format:"mp3"
|
20
|
+
process
|
21
|
+
end
|
22
|
+
|
23
|
+
def process
|
24
|
+
@videos.each do |video|
|
25
|
+
@stripper.strip(video)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def doctor
|
32
|
+
unless files_exist? && valid_video_formats?
|
33
|
+
raise InValidArguments, "Please check the video file names provided."
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def files_exist?
|
38
|
+
@videos.all? do |video|
|
39
|
+
File.file?(video)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def valid_video_formats?
|
44
|
+
@videos.all? do |video|
|
45
|
+
VIDEO_FORMATS.include? File.extname(video)[1..-1]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
app = CLI.new
|
52
|
+
|
53
|
+
end
|
54
|
+
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require "strip_audio/exceptions"
|
2
|
+
|
3
|
+
module StripAudio
|
4
|
+
|
5
|
+
class Stripper
|
6
|
+
|
7
|
+
@@options = {format: "mp3", bitrate: "160k"}
|
8
|
+
|
9
|
+
def initialize options
|
10
|
+
@@options.merge(options)
|
11
|
+
|
12
|
+
doctor
|
13
|
+
end
|
14
|
+
|
15
|
+
def strip video_file
|
16
|
+
|
17
|
+
begin
|
18
|
+
audio_file_exists?( video_file )
|
19
|
+
rescue Exception => e
|
20
|
+
puts e.message
|
21
|
+
exit
|
22
|
+
end
|
23
|
+
|
24
|
+
o = `ffmpeg -i #{video_file} -ab #{@@options[:bitrate]} -ac 2 -ar 44100 -vn #{audio_file(video_file)} 2>&1`
|
25
|
+
begin
|
26
|
+
command_output o
|
27
|
+
rescue Exception => e
|
28
|
+
puts e.message
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def command_output output
|
35
|
+
case output
|
36
|
+
when /Invalid data found/
|
37
|
+
raise InvalidSourceFile, "Source file doesn't seem to be valid."
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
def doctor
|
43
|
+
ffmpeg_exists?
|
44
|
+
end
|
45
|
+
|
46
|
+
def ffmpeg_exists?
|
47
|
+
if `which ffmpeg` == ""
|
48
|
+
raise FfmpegMissing, "ffmpeg is missing, please install and try again."
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def audio_file_exists? video_file
|
53
|
+
if File.file?( audio_file(video_file) )
|
54
|
+
raise AudioFileAlreadyExists, "#{audio_file(video_file)} already exists. Perhaps you stripped the file already?"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def audio_file video_file
|
59
|
+
"#{File.basename(video_file, ".*")}.#{@@options[:format]}"
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
data/lib/strip_audio.rb
ADDED
data/spec/spec_helper.rb
ADDED
data/strip_audio.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'strip_audio/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "strip_audio"
|
8
|
+
spec.version = StripAudio::VERSION
|
9
|
+
spec.authors = ["Jikku Jose"]
|
10
|
+
spec.email = ["jikkujose@gmail.com"]
|
11
|
+
spec.summary = %q{Strips audio from video files.}
|
12
|
+
spec.description = %q{A simple wrapper for ffmpeg to strip audio from video files.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "guard"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: strip_audio
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jikku Jose
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-05-10 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.6'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.6'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: guard
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description: A simple wrapper for ffmpeg to strip audio from video files.
|
63
|
+
email:
|
64
|
+
- jikkujose@gmail.com
|
65
|
+
executables:
|
66
|
+
- strip_audio
|
67
|
+
extensions: []
|
68
|
+
extra_rdoc_files: []
|
69
|
+
files:
|
70
|
+
- .gitignore
|
71
|
+
- .rspec
|
72
|
+
- Gemfile
|
73
|
+
- Guardfile
|
74
|
+
- LICENSE.txt
|
75
|
+
- README.md
|
76
|
+
- Rakefile
|
77
|
+
- bin/strip_audio
|
78
|
+
- lib/strip_audio.rb
|
79
|
+
- lib/strip_audio/exceptions.rb
|
80
|
+
- lib/strip_audio/stripper.rb
|
81
|
+
- lib/strip_audio/version.rb
|
82
|
+
- spec/spec_helper.rb
|
83
|
+
- spec/stripper_spec.rb
|
84
|
+
- strip_audio.gemspec
|
85
|
+
homepage: ''
|
86
|
+
licenses:
|
87
|
+
- MIT
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
94
|
+
requirements:
|
95
|
+
- - ! '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
100
|
+
requirements:
|
101
|
+
- - ! '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 1.8.23
|
107
|
+
signing_key:
|
108
|
+
specification_version: 3
|
109
|
+
summary: Strips audio from video files.
|
110
|
+
test_files:
|
111
|
+
- spec/spec_helper.rb
|
112
|
+
- spec/stripper_spec.rb
|
113
|
+
has_rdoc:
|