rmedia 0.1.0
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 +10 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +102 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/rmedia.rb +30 -0
- data/lib/rmedia/encode_option.rb +50 -0
- data/lib/rmedia/media.rb +114 -0
- data/lib/rmedia/option_parser.rb +52 -0
- data/lib/rmedia/transcoder.rb +44 -0
- data/lib/rmedia/version.rb +3 -0
- data/rmedia.gemspec +33 -0
- metadata +119 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b37f6b6d61fd9f327536355d5fa94c138985ed15
|
4
|
+
data.tar.gz: 2769e68b608b2cc42be7f06cb4e1a80104077ff1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 03d5798614fed877e31330fd4ba28cf95c8c1d3a17dea10db672a0d86e2dbd8c191e11da397d981eb902fa21600027a793a19081690a54ca7eb9f5fa8641da57
|
7
|
+
data.tar.gz: 36c78eda9c3f20f225ac65a4fd59a274cb7b57b564336ee26c73f52613e4c7dc7236df2399c23753a80348750277f0e0d4656d4bc1b0e041957b126982f4cfb0
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at himinato.k@gmail.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 himinato
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
# Rmedia
|
2
|
+
|
3
|
+
Rmedia is an interface between the Ruby and FFmpeg.
|
4
|
+
|
5
|
+
* http[s] input ready.
|
6
|
+
* [input seeking](https://trac.ffmpeg.org/wiki/Seeking) ready.
|
7
|
+
* 2 pass encode ready.
|
8
|
+
|
9
|
+
## Dependnecy
|
10
|
+
|
11
|
+
[FFmpeg](https://ffmpeg.org/)
|
12
|
+
|
13
|
+
How to build. [here](https://trac.ffmpeg.org/wiki/CompilationGuide)
|
14
|
+
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
|
18
|
+
Add this line to your application's Gemfile:
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
gem 'rmedia'
|
22
|
+
```
|
23
|
+
|
24
|
+
And then execute:
|
25
|
+
|
26
|
+
$ bundle
|
27
|
+
|
28
|
+
Or install it yourself as:
|
29
|
+
|
30
|
+
$ gem install rmedia
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
|
34
|
+
### Settings
|
35
|
+
|
36
|
+
Default, Rmedia need execution path and named ffmpeg / ffprobe. But you can set binary.
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
FFmpeg.ffmpeg_bin = '/path/to/bin/ffmpeg'
|
40
|
+
FFmpeg.ffprobe_bin = '/path/to/bin/ffprobe'
|
41
|
+
```
|
42
|
+
|
43
|
+
Default, Rmedia kill ffmpeg process when no 10 second IO feedback. But you can set timeout.
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
FFmpeg.timeout = 30
|
47
|
+
```
|
48
|
+
|
49
|
+
### Media
|
50
|
+
|
51
|
+
Readable data [here](https://github.com/himinato/rmedia/blob/master/lib/rmedia/media.rb#L7-L11)
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
media = FFmpeg::Media.new('path/to/media')
|
55
|
+
|
56
|
+
media.duration # 6.4
|
57
|
+
media.width # 640
|
58
|
+
```
|
59
|
+
|
60
|
+
Via http[s]
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
media = FFmpeg::Media.new('http://any/to/media')
|
64
|
+
```
|
65
|
+
|
66
|
+
### Transcode
|
67
|
+
|
68
|
+
Use encode options. human friendly options [here](https://github.com/himinato/rmedia/blob/master/lib/rmedia/encode_options.rb#L3-L22)
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
media.transcode('movie.webm', format: 'webm', video_bit_rate: '1500k') # transcode to webm
|
72
|
+
trnascoded = media.transcode('movie.webm', format: 'webm', video_bit_rate: '1500k') # return encoded media
|
73
|
+
```
|
74
|
+
|
75
|
+
Or give a string.
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
media.transcode('audio.mp3', '-f mp3 -vn') # transcode to mp3
|
79
|
+
```
|
80
|
+
|
81
|
+
You can use progress.
|
82
|
+
|
83
|
+
```ruby
|
84
|
+
media.transcode('movie.mp4') { |progress| puts progress } # 0.0 to 1.0
|
85
|
+
```
|
86
|
+
|
87
|
+
Input seeking. Give you faster performance.
|
88
|
+
|
89
|
+
```ruby
|
90
|
+
media.screenshot('out.jpg') # default screenshot make half of duration frame.
|
91
|
+
media.screenshot('out.jpg', seek_position: 3.2) # you can change it. -ss / seek_position option.
|
92
|
+
```
|
93
|
+
|
94
|
+
## Development
|
95
|
+
|
96
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
97
|
+
|
98
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
99
|
+
|
100
|
+
## License
|
101
|
+
|
102
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "rmedia"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/rmedia.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'open3'
|
2
|
+
require 'rmedia/version'
|
3
|
+
require 'rmedia/media'
|
4
|
+
require 'rmedia/encode_option'
|
5
|
+
require 'rmedia/option_parser'
|
6
|
+
require 'rmedia/transcoder'
|
7
|
+
|
8
|
+
module FFmpeg
|
9
|
+
def self.command(command)
|
10
|
+
Open3.popen3(*command) do |stdin, stdout, stderr, wait_thr|
|
11
|
+
yield(stdin, stdout, stderr, wait_thr) if block_given?
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class << self
|
16
|
+
attr_accessor :ffmpeg_bin, :ffprobe_bin, :timeout
|
17
|
+
|
18
|
+
def ffmpeg_bin
|
19
|
+
@ffmpeg_bin ||= 'ffmpeg'
|
20
|
+
end
|
21
|
+
|
22
|
+
def ffprobe_bin
|
23
|
+
@ffprobe_bin ||= 'ffprobe'
|
24
|
+
end
|
25
|
+
|
26
|
+
def timeout
|
27
|
+
@timeout ||= 10
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module FFmpeg
|
2
|
+
class EncodeOption < Hash
|
3
|
+
FRIENDLY_OPTIONS = {
|
4
|
+
format: '-f',
|
5
|
+
input: '-i',
|
6
|
+
duration: '-t',
|
7
|
+
stop_position: '-to',
|
8
|
+
limit_size: '-fs',
|
9
|
+
seek_position: '-ss',
|
10
|
+
video_bit_rate: '-b:v',
|
11
|
+
frame_rate: '-r',
|
12
|
+
resolution: '-s',
|
13
|
+
disable_video: '-vn',
|
14
|
+
video_filter: '-vf',
|
15
|
+
audio_bit_rate: '-b:a',
|
16
|
+
audio_sample_rate: '-ar',
|
17
|
+
audio_quality: '-q:a',
|
18
|
+
audio_channels: '-ac',
|
19
|
+
disable_audio: '-an',
|
20
|
+
audio_filter: '-af',
|
21
|
+
disable_subtitle: '-sn'
|
22
|
+
}.freeze
|
23
|
+
|
24
|
+
def initialize(opts = {})
|
25
|
+
opts.each do |key, value|
|
26
|
+
case
|
27
|
+
when FRIENDLY_OPTIONS[key.to_sym]
|
28
|
+
self[FRIENDLY_OPTIONS[key.to_sym]] = value
|
29
|
+
when private_methods.include?("opt_#{key}".to_sym)
|
30
|
+
send("opt_#{key}", value)
|
31
|
+
else
|
32
|
+
self[key.to_s] = value
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def to_s
|
38
|
+
map do |key, value|
|
39
|
+
value.is_a?(String) || value.is_a?(Numeric) ? "#{key} #{value}" : key
|
40
|
+
end.join(' ')
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def opt_screenshot(_v)
|
46
|
+
self['-f'] = 'image2'
|
47
|
+
self['-vframes'] = 1
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/rmedia/media.rb
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module FFmpeg
|
5
|
+
class Media
|
6
|
+
attr_accessor :status
|
7
|
+
attr_reader(
|
8
|
+
:path, :filename, :format, :duration, :size, :bit_rate,
|
9
|
+
:video_codec, :video_bit_rate, :width, :height, :resolution, :frame_rate, :sar, :dar, :pix_fmt,
|
10
|
+
:audio_codec, :audio_bit_rate, :audio_sample_rate, :channel_layout
|
11
|
+
)
|
12
|
+
|
13
|
+
def initialize(path)
|
14
|
+
raise Errno::ENOENT, "#{path} does not exist" unless path_exists?(path)
|
15
|
+
|
16
|
+
@path = path
|
17
|
+
|
18
|
+
options = '-v quiet -print_format json -show_format -show_streams'
|
19
|
+
command = "#{FFmpeg.ffprobe_bin} #{options} #{path}"
|
20
|
+
|
21
|
+
output = FFmpeg.command(command) { |_stdin, stdout| stdout.read }
|
22
|
+
json = JSON.parse(output)
|
23
|
+
|
24
|
+
raise "#{path} does not media" unless json['format']
|
25
|
+
|
26
|
+
media_info(json['format'])
|
27
|
+
streams_info(json['streams'])
|
28
|
+
end
|
29
|
+
|
30
|
+
def video?
|
31
|
+
@status & 2 == 2
|
32
|
+
end
|
33
|
+
|
34
|
+
def audio?
|
35
|
+
@status & 1 == 1
|
36
|
+
end
|
37
|
+
|
38
|
+
def transcode(output, options = {}, &block)
|
39
|
+
opts = EncodeOption.new(options)
|
40
|
+
command = OptionParser.command(@path, output, opts)
|
41
|
+
Transcoder.run(command, @duration, &block)
|
42
|
+
Media.new(output)
|
43
|
+
end
|
44
|
+
|
45
|
+
def screenshot(output, options = {}, &block)
|
46
|
+
opts = EncodeOption.new(options.merge(screenshot: true))
|
47
|
+
opts['-ss'] = @duration / 2.0 unless opts['-ss']
|
48
|
+
command = OptionParser.hacked_command(@path, output, opts)
|
49
|
+
Transcoder.run(command, @duration, &block)
|
50
|
+
Media.new(output)
|
51
|
+
end
|
52
|
+
|
53
|
+
def hacked_transcode(output, options = {}, &block)
|
54
|
+
opts = EncodeOption.new(options)
|
55
|
+
command = OptionParser.hacked_command(@path, output, opts)
|
56
|
+
Transcoder.run(command, @duration, &block)
|
57
|
+
Media.new(output)
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def path_exists?(path)
|
63
|
+
File.exist?(path) || url_exists?(path)
|
64
|
+
end
|
65
|
+
|
66
|
+
def url_exists?(path)
|
67
|
+
client = Faraday.new { |f| f.use Faraday::Adapter::NetHttp }
|
68
|
+
res = client.head(path)
|
69
|
+
res.status == 200
|
70
|
+
rescue
|
71
|
+
false
|
72
|
+
end
|
73
|
+
|
74
|
+
def media_info(format)
|
75
|
+
@filename = format['filename'].split('/')[-1]
|
76
|
+
@format = format['format_name']
|
77
|
+
@duration = format['duration'].to_f
|
78
|
+
@size = format['size'].to_i
|
79
|
+
@bit_rate = format['bit_rate'].to_i
|
80
|
+
@status = 0
|
81
|
+
end
|
82
|
+
|
83
|
+
# Attributes set first stream both video and audio
|
84
|
+
def streams_info(streams)
|
85
|
+
streams.each do |stream|
|
86
|
+
case stream['codec_type']
|
87
|
+
when 'video' then @status & 2 == 0 && video_info(stream)
|
88
|
+
when 'audio' then @status & 1 == 0 && audio_info(stream)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def video_info(stream)
|
94
|
+
@video_codec = stream['codec_name']
|
95
|
+
@video_bit_rate = stream['bit_rate'].to_i
|
96
|
+
@width = stream['width'].to_i
|
97
|
+
@height = stream['height'].to_i
|
98
|
+
@resolution = "#{width}x#{height}"
|
99
|
+
@frame_rate = stream['avg_frame_rate'] == '0/0' ? nil : Rational(stream['avg_frame_rate'])
|
100
|
+
@sar = stream['sample_aspect_ratio']
|
101
|
+
@dar = stream['display_aspect_ratio']
|
102
|
+
@pix_fmt = stream['pix_fmt']
|
103
|
+
@status += 2
|
104
|
+
end
|
105
|
+
|
106
|
+
def audio_info(stream)
|
107
|
+
@audio_codec = stream['codec_name']
|
108
|
+
@audio_bit_rate = stream['bit_rate'].to_i
|
109
|
+
@audio_sample_rate = stream['sample_rate'].to_i
|
110
|
+
@channel_layout = stream['channel_layout']
|
111
|
+
@status += 1
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module FFmpeg
|
2
|
+
module OptionParser
|
3
|
+
class << self
|
4
|
+
def command(input, output, options)
|
5
|
+
exec_ffmpeg_command(input, output, parse(options).to_s)
|
6
|
+
end
|
7
|
+
|
8
|
+
def hacked_command(input, output, options)
|
9
|
+
opts = parse(options).to_s
|
10
|
+
if opts.include?('-pass 2')
|
11
|
+
two_pass(input, output, opts)
|
12
|
+
else
|
13
|
+
input_seeking(input, output, opts)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def parse(options)
|
20
|
+
case
|
21
|
+
when options.is_a?(String) || options.is_a?(EncodeOption)
|
22
|
+
options
|
23
|
+
when options.is_a?(Hash)
|
24
|
+
EncodeOption.new(options)
|
25
|
+
else
|
26
|
+
fail ArgumentError, 'unknown options format, should be either optoins, Hash or String' # rubocop:disable LineLength
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def exec_ffmpeg_command(input, output, opts)
|
31
|
+
"#{FFmpeg.ffmpeg_bin} -y -i #{input} #{opts} #{output}"
|
32
|
+
end
|
33
|
+
|
34
|
+
def two_pass(input, output, opts)
|
35
|
+
first_opts = "#{opts.sub('-pass 2', '-pass 1')} -an"
|
36
|
+
first_command = input_seeking(input, output, first_opts)
|
37
|
+
"#{first_command} && #{input_seeking(input, output, opts)}"
|
38
|
+
end
|
39
|
+
|
40
|
+
def input_seeking(input, output, opts)
|
41
|
+
opts.sub!(/-ss \d+[\.\d]*/, '')
|
42
|
+
if Regexp.last_match
|
43
|
+
# it makes faster transcoding.
|
44
|
+
# NOTE: works only transcode, do not use -codec copy.
|
45
|
+
"#{FFmpeg.ffmpeg_bin} -y #{Regexp.last_match[0]} -i #{input} #{opts} #{output}"
|
46
|
+
else
|
47
|
+
exec_ffmpeg_command(input, output, opts)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'timeout'
|
2
|
+
|
3
|
+
module FFmpeg
|
4
|
+
module Transcoder
|
5
|
+
class << self
|
6
|
+
def run(command, duration)
|
7
|
+
yield(0.0) if block_given?
|
8
|
+
FFmpeg.command(command) do |_stdin, _stdout, stderr, wait_thr|
|
9
|
+
last_update = Time.now
|
10
|
+
|
11
|
+
stderr.each('size=') do |line|
|
12
|
+
check_timeout(wait_thr.pid, last_update)
|
13
|
+
yield(edit_time(line) / duration) if block_given?
|
14
|
+
end
|
15
|
+
end
|
16
|
+
yield(1.0) if block_given?
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def check_timeout(pid, last_update)
|
22
|
+
last_update = Time.now
|
23
|
+
if Time.now - last_update > FFmpeg.timeout
|
24
|
+
raise Timeout::Error.new('FFmpeg hung up')
|
25
|
+
end
|
26
|
+
rescue
|
27
|
+
Process.kill('KILL', pid)
|
28
|
+
raise
|
29
|
+
end
|
30
|
+
|
31
|
+
def edit_time(line)
|
32
|
+
return 0.0 unless line.include?('time=')
|
33
|
+
# ffmpeg 0.8 and above style
|
34
|
+
if line =~ /time=(\d+):(\d+):(\d+.\d+)/
|
35
|
+
(Regexp.last_match[1].to_i * 3600) +
|
36
|
+
(Regexp.last_match[2].to_i * 60) +
|
37
|
+
Regexp.last_match[3].to_f
|
38
|
+
else
|
39
|
+
0.0
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/rmedia.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rmedia/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'rmedia'
|
8
|
+
spec.version = FFmpeg::VERSION
|
9
|
+
spec.authors = ['Shinichi Okamoto']
|
10
|
+
spec.email = ['himinato.k@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = 'Ruby binding to FFmpeg'
|
13
|
+
spec.description = 'Ruby interface to FFmpeg'
|
14
|
+
spec.homepage = 'https://gihub.com/himinato/rmedia'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
19
|
+
# if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
# else
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
# end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ["lib"]
|
28
|
+
|
29
|
+
spec.add_dependency 'faraday', '~> 0.9.0'
|
30
|
+
spec.add_development_dependency 'bundler', '~> 1.11'
|
31
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
32
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rmedia
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Shinichi Okamoto
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-05-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.9.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.9.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.11'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.11'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
description: Ruby interface to FFmpeg
|
70
|
+
email:
|
71
|
+
- himinato.k@gmail.com
|
72
|
+
executables:
|
73
|
+
- console
|
74
|
+
- setup
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- ".gitignore"
|
79
|
+
- ".rspec"
|
80
|
+
- ".travis.yml"
|
81
|
+
- CODE_OF_CONDUCT.md
|
82
|
+
- Gemfile
|
83
|
+
- LICENSE.txt
|
84
|
+
- README.md
|
85
|
+
- Rakefile
|
86
|
+
- bin/console
|
87
|
+
- bin/setup
|
88
|
+
- lib/rmedia.rb
|
89
|
+
- lib/rmedia/encode_option.rb
|
90
|
+
- lib/rmedia/media.rb
|
91
|
+
- lib/rmedia/option_parser.rb
|
92
|
+
- lib/rmedia/transcoder.rb
|
93
|
+
- lib/rmedia/version.rb
|
94
|
+
- rmedia.gemspec
|
95
|
+
homepage: https://gihub.com/himinato/rmedia
|
96
|
+
licenses:
|
97
|
+
- MIT
|
98
|
+
metadata: {}
|
99
|
+
post_install_message:
|
100
|
+
rdoc_options: []
|
101
|
+
require_paths:
|
102
|
+
- lib
|
103
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
requirements: []
|
114
|
+
rubyforge_project:
|
115
|
+
rubygems_version: 2.5.1
|
116
|
+
signing_key:
|
117
|
+
specification_version: 4
|
118
|
+
summary: Ruby binding to FFmpeg
|
119
|
+
test_files: []
|