video_screenshoter 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/lib/video_screenshoter/abstract.rb +4 -4
- data/lib/video_screenshoter/hls.rb +2 -2
- data/lib/video_screenshoter/version.rb +1 -1
- data/test/fixtures/short_test.avi +0 -0
- data/test/video_screenshoter_test.rb +23 -7
- data/video_screenshoter.gemspec +2 -0
- metadata +46 -32
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ebd62aaa7d30b174bb766ad5b6aef4f6a7f4b2f1
|
4
|
+
data.tar.gz: 1bde0dad5f3e7945cee3cdb9e46a9fa3cdb23062
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7609fc92bbca169199b93a0d59da85ffe800b1b67bd6440ac054ba9658142de354f7900b97e5692afb40c284234d8d59ce18632b53e30c40a4ef5880381dc5c7
|
7
|
+
data.tar.gz: ba14f3b3869d3feccc405a4888c8a575d5a94683f1b70265f69185f002cc0444de2cf2c454a43ad3bcd0d85a4f89abccf1897943dc786bc1593da2f5c75b892c
|
data/.gitignore
CHANGED
@@ -14,11 +14,11 @@ module VideoScreenshoter
|
|
14
14
|
FileUtils.mkdir_p self.output_dir
|
15
15
|
self.input = params[:input]
|
16
16
|
self.duration = input_duration
|
17
|
-
raise ArgumentError.new('Incorrect or empty m3u8 playlist') if duration.
|
18
|
-
|
17
|
+
raise ArgumentError.new('Incorrect or empty m3u8 playlist') if duration.nil? || duration <= 0
|
18
|
+
|
19
19
|
# if false ffmpeg uses fast seek by keyframes like: ffmpeg -ss ... -i
|
20
20
|
self.exact = params[:exact]
|
21
|
-
|
21
|
+
|
22
22
|
if params[:times]
|
23
23
|
self.exact = true if exact.nil?
|
24
24
|
self.times = params[:times].to_a.map do |time|
|
@@ -41,7 +41,7 @@ module VideoScreenshoter
|
|
41
41
|
else
|
42
42
|
raise ArgumentError.new('times or number required') if times.empty?
|
43
43
|
end
|
44
|
-
|
44
|
+
|
45
45
|
self.size = params[:size] ? "-s #{params[:size]}" : ''
|
46
46
|
|
47
47
|
# TODO possibility to replace original image by presetted image
|
@@ -35,13 +35,13 @@ module VideoScreenshoter
|
|
35
35
|
alias :make_thumbnails :run
|
36
36
|
|
37
37
|
private
|
38
|
-
|
38
|
+
|
39
39
|
attr_accessor :chunks
|
40
40
|
|
41
41
|
def input_duration
|
42
42
|
(self.chunks = parse_playlist).map(&:first).inject(:+)
|
43
43
|
end
|
44
|
-
|
44
|
+
|
45
45
|
def parse_playlist
|
46
46
|
require 'open-uri'
|
47
47
|
open(input) { |f| f.read }.scan(/EXTINF:([\d.]+).*?\n(.*?)\n/).map { |c| [c.first.to_f, c.last] }
|
Binary file
|
@@ -4,15 +4,16 @@ class VideoScreenshoterTest < Test::Unit::TestCase
|
|
4
4
|
context 'video' do
|
5
5
|
setup do
|
6
6
|
@input = 'http://techslides.com/demos/sample-videos/small.mp4'
|
7
|
+
@short_input = File.join(Dir.pwd, 'test/fixtures/short_test.avi')
|
7
8
|
@output_dir = '/tmp/video_screenshots_test'
|
8
9
|
`rm -r #{@output_dir}` if File.exists?(@output_dir)
|
9
10
|
end
|
10
|
-
|
11
|
+
|
11
12
|
context '' do
|
12
13
|
setup do
|
13
|
-
VideoScreenshoter.new(:input => @input, :output_dir => @output_dir, :times => [1, -2, '50%', '-10%']).make_screenshots
|
14
|
+
VideoScreenshoter.new(:input => @input, :output_dir => @output_dir, :times => [1, -2, '50%', '-10%'], verbose: true).make_screenshots
|
14
15
|
end
|
15
|
-
|
16
|
+
|
16
17
|
should 'create screenshots' do
|
17
18
|
[1, 2, 3, 5].each do |sec|
|
18
19
|
assert File.exists? File.join(@output_dir, "scr00#{sec}.jpg")
|
@@ -21,9 +22,25 @@ class VideoScreenshoterTest < Test::Unit::TestCase
|
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
25
|
+
context 'with short video' do
|
26
|
+
setup do
|
27
|
+
VideoScreenshoter.new(:input => @short_input, :output_dir => @output_dir, :times => [1, -2, '50%', '-10%'], verbose: true).make_screenshots
|
28
|
+
end
|
29
|
+
|
30
|
+
should 'create screenshots' do
|
31
|
+
[-1, 0].each do |sec|
|
32
|
+
puts "FILE: #{File.join(@output_dir, "scr00#{sec}.jpg")}"
|
33
|
+
assert File.exists? File.join(@output_dir, "scr-01.jpg")
|
34
|
+
assert File.exists? File.join(@output_dir, "scr000.jpg")
|
35
|
+
assert File.size(File.join(@output_dir, "scr-01.jpg")) > 0
|
36
|
+
assert File.size(File.join(@output_dir, "scr000.jpg")) > 0
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
24
41
|
context 'with presets' do
|
25
42
|
setup do
|
26
|
-
VideoScreenshoter.new(:input => @input, :output_dir => @output_dir, :times => [1, -1], :presets => {:big => '1024x768', :small => '-resize 400x100^ -gravity center -crop 400x100+0+0'}
|
43
|
+
VideoScreenshoter.new(:input => @input, :output_dir => @output_dir, :times => [1, -1], :presets => {:big => '1024x768', :small => '-resize 400x100^ -gravity center -crop 400x100+0+0'}).make_screenshots
|
27
44
|
end
|
28
45
|
should 'create screenshots' do
|
29
46
|
[1,4].each do |sec|
|
@@ -52,7 +69,7 @@ class VideoScreenshoterTest < Test::Unit::TestCase
|
|
52
69
|
@output_dir = '/tmp/hls_screenshots_test'
|
53
70
|
`rm -r #{@output_dir}` if File.exists? @output_dir
|
54
71
|
end
|
55
|
-
|
72
|
+
|
56
73
|
context '' do
|
57
74
|
setup do
|
58
75
|
VideoScreenshoter.new(:input => @input, :output_dir => @output_dir, :times => ['10%', '50%', '-10%']).make_thumbnails
|
@@ -67,8 +84,7 @@ class VideoScreenshoterTest < Test::Unit::TestCase
|
|
67
84
|
|
68
85
|
context 'with presets' do
|
69
86
|
setup do
|
70
|
-
VideoScreenshoter.
|
71
|
-
VideoScreenshoter.new(:input => @input, :output_dir => @output_dir, :times => ['10%', '50%', '-10%'], :presets => {:big => '1024x768', :small => '140x100!'}).make_thumbnails
|
87
|
+
VideoScreenshoter.new(:input => @input, :output_dir => @output_dir, :times => ['10%', '50%', '-10%'], :presets => {:big => '1024x768', :small => '140x100!'}, verbose: true).make_thumbnails
|
72
88
|
end
|
73
89
|
should 'create screenshots' do
|
74
90
|
["scr1620.jpg", "scr180.jpg", "scr900.jpg"].each do |scr|
|
data/video_screenshoter.gemspec
CHANGED
@@ -22,6 +22,8 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_development_dependency "rake"
|
23
23
|
spec.add_development_dependency "test-unit"
|
24
24
|
spec.add_development_dependency "shoulda-context"
|
25
|
+
spec.add_development_dependency "pry"
|
26
|
+
spec.add_development_dependency "pry-byebug"
|
25
27
|
|
26
28
|
spec.requirements << 'ffmpeg'
|
27
29
|
spec.requirements << 'imagemagick'
|
metadata
CHANGED
@@ -1,78 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: video_screenshoter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.4
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- novikov
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2016-03-10 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: bundler
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '1.3'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- - ~>
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '1.3'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: test-unit
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ">="
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: shoulda-context
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - ">="
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '0'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
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: pry-byebug
|
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
|
+
- - ">="
|
76
95
|
- !ruby/object:Gem::Version
|
77
96
|
version: '0'
|
78
97
|
description: Documentation coming soon...
|
@@ -82,7 +101,7 @@ executables: []
|
|
82
101
|
extensions: []
|
83
102
|
extra_rdoc_files: []
|
84
103
|
files:
|
85
|
-
- .gitignore
|
104
|
+
- ".gitignore"
|
86
105
|
- Gemfile
|
87
106
|
- LICENSE.txt
|
88
107
|
- README.md
|
@@ -93,6 +112,7 @@ files:
|
|
93
112
|
- lib/video_screenshoter/image.rb
|
94
113
|
- lib/video_screenshoter/version.rb
|
95
114
|
- lib/video_screenshoter/video.rb
|
115
|
+
- test/fixtures/short_test.avi
|
96
116
|
- test/fixtures/test.jpg
|
97
117
|
- test/test_helper.rb
|
98
118
|
- test/video_screenshoter_test.rb
|
@@ -100,37 +120,31 @@ files:
|
|
100
120
|
homepage: ''
|
101
121
|
licenses:
|
102
122
|
- MIT
|
123
|
+
metadata: {}
|
103
124
|
post_install_message:
|
104
125
|
rdoc_options: []
|
105
126
|
require_paths:
|
106
127
|
- lib
|
107
128
|
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
-
none: false
|
109
129
|
requirements:
|
110
|
-
- -
|
130
|
+
- - ">="
|
111
131
|
- !ruby/object:Gem::Version
|
112
132
|
version: '0'
|
113
|
-
segments:
|
114
|
-
- 0
|
115
|
-
hash: 811301849327222069
|
116
133
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
-
none: false
|
118
134
|
requirements:
|
119
|
-
- -
|
135
|
+
- - ">="
|
120
136
|
- !ruby/object:Gem::Version
|
121
137
|
version: '0'
|
122
|
-
segments:
|
123
|
-
- 0
|
124
|
-
hash: 811301849327222069
|
125
138
|
requirements:
|
126
139
|
- ffmpeg
|
127
140
|
- imagemagick
|
128
141
|
rubyforge_project:
|
129
|
-
rubygems_version:
|
142
|
+
rubygems_version: 2.2.2
|
130
143
|
signing_key:
|
131
|
-
specification_version:
|
144
|
+
specification_version: 4
|
132
145
|
summary: Make screenshots from video or m3u8 files using ffmpeg
|
133
146
|
test_files:
|
147
|
+
- test/fixtures/short_test.avi
|
134
148
|
- test/fixtures/test.jpg
|
135
149
|
- test/test_helper.rb
|
136
150
|
- test/video_screenshoter_test.rb
|