dragonfly_video 0.2.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 +29 -0
- data/.travis.yml +14 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +4 -0
- data/Guardfile +8 -0
- data/LICENSE.txt +22 -0
- data/README.md +83 -0
- data/Rakefile +9 -0
- data/dragonfly_video.gemspec +31 -0
- data/lib/dragonfly_video.rb +7 -0
- data/lib/dragonfly_video/analysers/video_properties.rb +30 -0
- data/lib/dragonfly_video/plugin.rb +20 -0
- data/lib/dragonfly_video/processors/screenshot.rb +27 -0
- data/lib/dragonfly_video/version.rb +3 -0
- data/samples/IMG_0064.mp4 +0 -0
- metadata +159 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7e20751709a0eea6abb9fdfe5a6cff50f0dc50bf
|
4
|
+
data.tar.gz: 1608f75afd045d35dd699b5d0374830a8d99e9da
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cfe61e277c515758f13d01923cb73ec53660b100e7afccdf371fa7f94039f81475df47c98634d28781001dab9dd439e8491e63fd948e32fbe4bc1421733ceed8
|
7
|
+
data.tar.gz: 9f52f77d60059affd3234e7d84c780666f1eacd3f6ae8e3a28bad1a434ec44096720737ca8b4e4810af6044f955163f09ccfc04212982f857a0887996e2909d7
|
data/.gitignore
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
_yardoc
|
2
|
+
.bundle
|
3
|
+
.config
|
4
|
+
.rspec_status
|
5
|
+
.yardoc
|
6
|
+
*.a
|
7
|
+
*.bundle
|
8
|
+
*.gem
|
9
|
+
*.o
|
10
|
+
*.rbc
|
11
|
+
*.so
|
12
|
+
/_yardoc/
|
13
|
+
/.bundle/
|
14
|
+
/.yardoc
|
15
|
+
/bin/
|
16
|
+
/coverage
|
17
|
+
/coverage/
|
18
|
+
/doc/
|
19
|
+
/dragonfly.log
|
20
|
+
/Gemfile.lock
|
21
|
+
/InstalledFiles
|
22
|
+
/lib/bundler/man
|
23
|
+
/mkmf.log
|
24
|
+
/pkg/
|
25
|
+
/rdoc
|
26
|
+
/spec/reports/
|
27
|
+
/test/tmp
|
28
|
+
/test/version_tmp
|
29
|
+
/tmp/
|
data/.travis.yml
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
language: ruby
|
2
|
+
cache: bundler
|
3
|
+
script: 'bundle exec rake'
|
4
|
+
rvm:
|
5
|
+
- 2.3.1
|
6
|
+
before_install:
|
7
|
+
- wget http://johnvansickle.com/ffmpeg/releases/ffmpeg-release-64bit-static.tar.xz -O - | sudo tar -xJ --strip-components=1 -C /usr/local/bin/
|
8
|
+
|
9
|
+
notifications:
|
10
|
+
email:
|
11
|
+
recipients:
|
12
|
+
- a@asgerbehnckejacobsen.dk
|
13
|
+
on_failure: change
|
14
|
+
on_success: never
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2018 Asger Behncke Jacobsen
|
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,83 @@
|
|
1
|
+
# Dragonfly Video
|
2
|
+
|
3
|
+
[](https://travis-ci.org/asgerb/dragonfly_video) [](http://badge.fury.io/rb/dragonfly_video) [](https://codeclimate.com/github/asgerb/dragonfly_video/maintainability)
|
4
|
+
[](https://codeclimate.com/github/asgerb/dragonfly_video/test_coverage)
|
5
|
+
|
6
|
+
Wraps common video-related tasks into [Dragonfly](http://markevans.github.io/dragonfly) analysers and processors.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'dragonfly_video'
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install dragonfly_video
|
23
|
+
|
24
|
+
## Dependencies
|
25
|
+
|
26
|
+
The gem relies on `ffmpeg` (and ruby implementation [streamio-ffmpeg](https://github.com/streamio/streamio-ffmpeg)) for reading metadata and generating screenshots of video files.
|
27
|
+
|
28
|
+
On a Mac you can install ffmpeg with homebrew: `brew install ffmpeg`.
|
29
|
+
|
30
|
+
## Usage
|
31
|
+
|
32
|
+
Add the `:video` plugin to your Dragonfly config block:
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
Dragonfly.app.configure do
|
36
|
+
plugin :video
|
37
|
+
end
|
38
|
+
```
|
39
|
+
|
40
|
+
## Analysers
|
41
|
+
|
42
|
+
### `video_properties`
|
43
|
+
|
44
|
+
Reads properties of a video file:
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
video.video_properties
|
48
|
+
|
49
|
+
# => {
|
50
|
+
# duration: 7.5,
|
51
|
+
# bitrate: 481,
|
52
|
+
# size: 455546,
|
53
|
+
# video_stream: "h264, yuv420p, 640x480 [PAR 1:1 DAR 4:3], 371 kb/s, 16.75 fps, 15 tbr, 600 tbn, 1200 tbc",
|
54
|
+
# video_codec: "h264",
|
55
|
+
# colorspace: "yuv420p",
|
56
|
+
# resolution: "640x480",
|
57
|
+
# width: 640,
|
58
|
+
# height: 480,
|
59
|
+
# frame_rate: 16.72,
|
60
|
+
# audio_stream: "aac, 44100 Hz, stereo, s16, 75 kb/s",
|
61
|
+
# audio_codec: "aac",
|
62
|
+
# audio_sample_rate: 44100,
|
63
|
+
# audio_channels: 2
|
64
|
+
# }
|
65
|
+
```
|
66
|
+
|
67
|
+
## Processors
|
68
|
+
|
69
|
+
### `screenshot`
|
70
|
+
|
71
|
+
Generates a screenshot of the video's first frame:
|
72
|
+
|
73
|
+
```ruby
|
74
|
+
video.screenshot
|
75
|
+
```
|
76
|
+
|
77
|
+
## Contributing
|
78
|
+
|
79
|
+
1. Fork it ( https://github.com/asgerb/dragonfly_video/fork )
|
80
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
81
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
82
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
83
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'dragonfly_video/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "dragonfly_video"
|
8
|
+
spec.version = DragonflyVideo::VERSION
|
9
|
+
spec.authors = ["Asger Behncke Jacobsen"]
|
10
|
+
spec.email = ["asger@8kilo.com"]
|
11
|
+
|
12
|
+
spec.summary = 'Wraps common video-related tasks into Dragonfly analysers and processors.'
|
13
|
+
spec.homepage = 'https://github.com/asgerb/dragonfly_video'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_dependency 'dragonfly', '~> 1.0'
|
24
|
+
spec.add_dependency 'streamio-ffmpeg', '~> 3.0'
|
25
|
+
|
26
|
+
spec.add_development_dependency 'bundler', '~> 1.14'
|
27
|
+
spec.add_development_dependency 'rake'
|
28
|
+
spec.add_development_dependency 'guard'
|
29
|
+
spec.add_development_dependency 'guard-minitest'
|
30
|
+
spec.add_development_dependency 'minitest'
|
31
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'streamio-ffmpeg'
|
2
|
+
|
3
|
+
# IMPORTANT: See https://github.com/streamio/streamio-ffmpeg
|
4
|
+
|
5
|
+
module DragonflyVideo
|
6
|
+
module Analysers
|
7
|
+
class VideoProperties
|
8
|
+
VIDEO_PROPS = %i(duration bitrate size video_stream video_codec colorspace
|
9
|
+
resolution width height frame_rate audio_stream audio_codec
|
10
|
+
audio_sample_rate audio_channels).freeze
|
11
|
+
|
12
|
+
def call(content)
|
13
|
+
ffmpeg(content)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def ffmpeg(content)
|
19
|
+
res = {}
|
20
|
+
movie = FFMPEG::Movie.new(content.path)
|
21
|
+
if movie.valid?
|
22
|
+
VIDEO_PROPS.each do |prop_name|
|
23
|
+
res[prop_name] = movie.send(prop_name)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
res
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'dragonfly_video/analysers/video_properties'
|
2
|
+
require 'dragonfly_video/processors/screenshot'
|
3
|
+
|
4
|
+
class DragonflyVideo::Plugin
|
5
|
+
def call(app, _opts = {})
|
6
|
+
app.add_analyser :video_properties, DragonflyVideo::Analysers::VideoProperties.new
|
7
|
+
|
8
|
+
[
|
9
|
+
DragonflyVideo::Analysers::VideoProperties::VIDEO_PROPS
|
10
|
+
].flatten.each do |analyser|
|
11
|
+
app.add_analyser analyser do |content|
|
12
|
+
content.analyse(:video_properties)[analyser]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
app.add_processor :screenshot, DragonflyVideo::Processors::Screenshot.new
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
Dragonfly::App.register_plugin(:video) { DragonflyVideo::Plugin.new }
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'streamio-ffmpeg'
|
2
|
+
|
3
|
+
# IMPORTANT: See https://github.com/streamio/streamio-ffmpeg
|
4
|
+
|
5
|
+
module DragonflyVideo
|
6
|
+
module Processors
|
7
|
+
class Screenshot
|
8
|
+
FFMPEG_COMMAND = 'ffmpeg'.freeze
|
9
|
+
|
10
|
+
def call(content, options = {})
|
11
|
+
format = options.delete(:format) { :jpg }
|
12
|
+
|
13
|
+
content.shell_update(ext: format) do |old_path, new_path|
|
14
|
+
"#{FFMPEG_COMMAND} -y -i #{old_path} -vframes 1 #{new_path}"
|
15
|
+
end
|
16
|
+
|
17
|
+
content.ext = format
|
18
|
+
content
|
19
|
+
end
|
20
|
+
|
21
|
+
def update_url(attrs, options = {})
|
22
|
+
format = options.fetch(:format, :jpg)
|
23
|
+
attrs.ext = format.to_s
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dragonfly_video
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Asger Behncke Jacobsen
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-03-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: dragonfly
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.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: '3.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.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.14'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.14'
|
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
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: guard
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: guard-minitest
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: minitest
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description:
|
112
|
+
email:
|
113
|
+
- asger@8kilo.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- ".travis.yml"
|
120
|
+
- CHANGELOG.md
|
121
|
+
- Gemfile
|
122
|
+
- Guardfile
|
123
|
+
- LICENSE.txt
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- bin/console
|
127
|
+
- bin/setup
|
128
|
+
- dragonfly_video.gemspec
|
129
|
+
- lib/dragonfly_video.rb
|
130
|
+
- lib/dragonfly_video/analysers/video_properties.rb
|
131
|
+
- lib/dragonfly_video/plugin.rb
|
132
|
+
- lib/dragonfly_video/processors/screenshot.rb
|
133
|
+
- lib/dragonfly_video/version.rb
|
134
|
+
- samples/IMG_0064.mp4
|
135
|
+
homepage: https://github.com/asgerb/dragonfly_video
|
136
|
+
licenses:
|
137
|
+
- MIT
|
138
|
+
metadata: {}
|
139
|
+
post_install_message:
|
140
|
+
rdoc_options: []
|
141
|
+
require_paths:
|
142
|
+
- lib
|
143
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
requirements: []
|
154
|
+
rubyforge_project:
|
155
|
+
rubygems_version: 2.6.12
|
156
|
+
signing_key:
|
157
|
+
specification_version: 4
|
158
|
+
summary: Wraps common video-related tasks into Dragonfly analysers and processors.
|
159
|
+
test_files: []
|