stack-encode 0.0.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.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +38 -0
- data/Rakefile +2 -0
- data/bin/stack-encode +5 -0
- data/lib/stack-encode.rb +2 -0
- data/lib/stack-encode/cli.rb +64 -0
- data/lib/stack-encode/version.rb +3 -0
- data/stack-encode.gemspec +28 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 03616382d07016371d7a1c18f72be0d40f6c16bd
|
4
|
+
data.tar.gz: 4d2754cb59e14cd9c7327c76f5ae66b24d336010
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: acb165b3ac089efd0e253b678d14bc08ac480f95f1f91aabb6d98399bbbc3ad1d4c39278196622d309c73cc1198c945fa42c8feaf427862effccd15c832ff185
|
7
|
+
data.tar.gz: a01747eba0f809385ac594fa0c5407b60d11b9dd77f672d1258fd85f4e8aaeb9c60c5f27c3e3101fea2e3192d69b7b1f02917d68aba40d2e498fc861751fdb90
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 niwo
|
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,38 @@
|
|
1
|
+
# Stack Encode
|
2
|
+
|
3
|
+
A simple gem for automating the encoding process with ffmpeg.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
$ gem install stack-encode
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
See the help screen:
|
12
|
+
|
13
|
+
```bash
|
14
|
+
$ stack-encode help
|
15
|
+
|
16
|
+
stack-encode commands:
|
17
|
+
stack-encode encode FILES # Encodes a number video or audio files
|
18
|
+
stack-encode help [COMMAND] # Describe available commands or one specific command
|
19
|
+
stack-encode version # Outputs the version
|
20
|
+
```
|
21
|
+
|
22
|
+
Example encode command:
|
23
|
+
|
24
|
+
```bash
|
25
|
+
$ stack-encode encode -d ~/destination/ /source/files/*
|
26
|
+
Trancoding 2011-05-31_0053_lo.mpg to Mp4: [#################################] 100%
|
27
|
+
Trancoding 2011-05-31_0053_loaud3.mp2 to Mp3: [#################################] 100%
|
28
|
+
Trancoding 2011-05-31_0053_loaud4.mp2 to Mp3: [#################################] 100%
|
29
|
+
Trancoding 2014-05-26_0010_lo.mp4 to Mp4: [#################################] 100%
|
30
|
+
```
|
31
|
+
|
32
|
+
## Contributing
|
33
|
+
|
34
|
+
1. Fork it
|
35
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
36
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
37
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
38
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/stack-encode
ADDED
data/lib/stack-encode.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
module StackEncode
|
2
|
+
require 'find'
|
3
|
+
require 'thor'
|
4
|
+
require 'streamio-ffmpeg'
|
5
|
+
|
6
|
+
class Cli < Thor
|
7
|
+
include Thor::Actions
|
8
|
+
|
9
|
+
# catch control-c and exit
|
10
|
+
trap("SIGINT") {
|
11
|
+
puts " bye"
|
12
|
+
exit!
|
13
|
+
}
|
14
|
+
|
15
|
+
package_name "stack-encode"
|
16
|
+
map %w(-v --version) => :version
|
17
|
+
|
18
|
+
desc "version", "Outputs the version"
|
19
|
+
def version
|
20
|
+
say "stack-encode v#{StackEncode::VERSION}"
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "encode FILES", "Encodes a number video or audio files"
|
24
|
+
option :destination,
|
25
|
+
desc: "destination directory",
|
26
|
+
aliases: '-d'
|
27
|
+
option :video_format,
|
28
|
+
desc: "video format",
|
29
|
+
aliases: '-v',
|
30
|
+
default: 'mp4'
|
31
|
+
option :audio_format,
|
32
|
+
desc: "audio format",
|
33
|
+
aliases: '-a',
|
34
|
+
default: 'mp3'
|
35
|
+
def encode(*files)
|
36
|
+
FFMPEG.logger = Logger.new('/dev/null')
|
37
|
+
files.each do |source|
|
38
|
+
movie = FFMPEG::Movie.new(source)
|
39
|
+
dest_format = movie.video_stream ? options[:video_format] : options[:audio_format]
|
40
|
+
dest_dir = options[:destination] || File.dirname(source)
|
41
|
+
banner = "Trancoding #{File.basename(source)} to #{dest_format.upcase}"
|
42
|
+
transcoded_movie = movie.transcode(
|
43
|
+
File.expand_path(
|
44
|
+
"#{dest_dir}/" + File.basename(source,
|
45
|
+
File.extname(source)
|
46
|
+
) + ".#{dest_format}"
|
47
|
+
)
|
48
|
+
) {|progress| print_progress(progress * 100, banner)}
|
49
|
+
puts
|
50
|
+
transcoded_movie
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
no_commands do
|
55
|
+
# Helper function to print a progress bar in the console
|
56
|
+
def print_progress(progress, banner)
|
57
|
+
print "\r#{banner}:\t[" + ('#' * (progress.round / 3)) + (' ' * (100/3 - progress.round / 3)) + ']'
|
58
|
+
printf (progress < 100 ? " %02d\%" : " %3d\%"), progress
|
59
|
+
$stdout.flush
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'stack-encode/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "stack-encode"
|
8
|
+
spec.version = StackEncode::VERSION
|
9
|
+
spec.authors = ["Nik Wolfgramm"]
|
10
|
+
spec.email = ["nik.wolfgramm@swisstxt.ch"]
|
11
|
+
spec.description = %q{A simple gem for automating the encoding process with ffmpeg}
|
12
|
+
spec.summary = %q{stack-encode - automating the encoding process with ffmpeg}
|
13
|
+
spec.homepage = "https://github.com/swisstxt/stack-encode"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
|
17
|
+
spec.files = `git ls-files`.split($/)
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
spec.required_ruby_version = '>= 1.9.3'
|
22
|
+
|
23
|
+
spec.add_dependency "thor"
|
24
|
+
spec.add_dependency "streamio-ffmpeg"
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
27
|
+
spec.add_development_dependency "rake"
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: stack-encode
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nik Wolfgramm
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: streamio-ffmpeg
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: A simple gem for automating the encoding process with ffmpeg
|
70
|
+
email:
|
71
|
+
- nik.wolfgramm@swisstxt.ch
|
72
|
+
executables:
|
73
|
+
- stack-encode
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- bin/stack-encode
|
83
|
+
- lib/stack-encode.rb
|
84
|
+
- lib/stack-encode/cli.rb
|
85
|
+
- lib/stack-encode/version.rb
|
86
|
+
- stack-encode.gemspec
|
87
|
+
homepage: https://github.com/swisstxt/stack-encode
|
88
|
+
licenses:
|
89
|
+
- MIT
|
90
|
+
metadata: {}
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: 1.9.3
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 2.0.3
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: stack-encode - automating the encoding process with ffmpeg
|
111
|
+
test_files: []
|