thumbsdown 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 +2 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +22 -0
- data/LICENSE.txt +21 -0
- data/README.md +32 -0
- data/Rakefile +1 -0
- data/exe/thumbsdown +151 -0
- data/thumbsdown.gemspec +32 -0
- metadata +97 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 1a194b3ca34c21bd2ad13b860198e9d1aa8309f4bb2eaf603755952d896f8d11
|
|
4
|
+
data.tar.gz: e1aafa51b2729c7f2c4dd336fc4c03f09889d695a299b22ee54c69b19764dc15
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: a548e41d19a1e9ba6162633b34ed9e36e34722cce2b838df08918a5e2f987dd6119d35f23f2dfc9d4910a8853e594603a19e87fd532b0ed95ec0efb1032c57d9
|
|
7
|
+
data.tar.gz: 5f2725291f3d927b9356e480ef5f67248a6194cb052d564b42930b6efa62c90d82f7b10cbd18ad2e5807bb52ef269f5047a993373499a91303448e3418950b80
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
thumbsdown (0.1.0)
|
|
5
|
+
tqdm
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
rake (10.5.0)
|
|
11
|
+
tqdm (0.3.0)
|
|
12
|
+
|
|
13
|
+
PLATFORMS
|
|
14
|
+
ruby
|
|
15
|
+
|
|
16
|
+
DEPENDENCIES
|
|
17
|
+
bundler (~> 1.16)
|
|
18
|
+
rake (~> 10.0)
|
|
19
|
+
thumbsdown!
|
|
20
|
+
|
|
21
|
+
BUNDLED WITH
|
|
22
|
+
1.16.2
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Adam Ladachowski
|
|
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,32 @@
|
|
|
1
|
+
# Thumbsdown
|
|
2
|
+
|
|
3
|
+
Thumbnail generator for video files
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
$ gem install thumbsdown
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
Usage: thumbsdown [OPTIONS]
|
|
15
|
+
|
|
16
|
+
Create a multi-thumbnail image of a video file
|
|
17
|
+
|
|
18
|
+
-h, --help show this message
|
|
19
|
+
-v, --[no-]verbose=[FLAG] run verbosly
|
|
20
|
+
-o, --output=STRING Output filename (default out.(png|jpeg))
|
|
21
|
+
-c, --columns=INT Number of thumbnail columns (default: 5)
|
|
22
|
+
-s, --start=INT Start point for making thumbnails in seconds (default: 1)
|
|
23
|
+
-T, --temp=STRING Specify a temporary directory (default /tmp)
|
|
24
|
+
-t, --thumbs=INT Number of thumbs to generate - the length of the video is divided equally by this (default: 20)
|
|
25
|
+
-w, --width=INT Width of a single thumbnail - Height calculated automaticly (default: 320px)
|
|
26
|
+
-f, --[no-]force=[FLAG] force mode - override output
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## License
|
|
31
|
+
|
|
32
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'bundler/gem_tasks'
|
data/exe/thumbsdown
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
# check for stuff we need to make this work:
|
|
4
|
+
# - imagemagick
|
|
5
|
+
# - mplayer
|
|
6
|
+
|
|
7
|
+
used_binaries = %w[convert mogrify mplayer]
|
|
8
|
+
|
|
9
|
+
used_binaries.each do |file|
|
|
10
|
+
if `which #{file}` == ''
|
|
11
|
+
puts "Error: missing #{file}"
|
|
12
|
+
exit
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
require 'optparse'
|
|
17
|
+
require 'fileutils'
|
|
18
|
+
require 'pp'
|
|
19
|
+
require 'tqdm'
|
|
20
|
+
|
|
21
|
+
start = 1
|
|
22
|
+
thumbs = 20
|
|
23
|
+
columns = 5
|
|
24
|
+
output = 'thumbs.png'
|
|
25
|
+
temp = '/tmp'
|
|
26
|
+
width = 320
|
|
27
|
+
verbose = false
|
|
28
|
+
force = false
|
|
29
|
+
|
|
30
|
+
ARGV.options do |opts|
|
|
31
|
+
opts.banner = "\nUsage: #{File.basename $PROGRAM_NAME} [OPTIONS]\n\nCreate a multi-thumbnail image of a video file\n\n"
|
|
32
|
+
|
|
33
|
+
opts.on('-h', '--help', 'show this message') do
|
|
34
|
+
puts opts
|
|
35
|
+
exit
|
|
36
|
+
end
|
|
37
|
+
opts.on('-v', '--[no-]verbose=[FLAG]', TrueClass, 'run verbosly') { |v| verbose = v }
|
|
38
|
+
opts.on('-o', '--output=STRING', String, 'Output filename (default out.(png|jpeg))') { |o| output = o }
|
|
39
|
+
opts.on('-c', '--columns=INT', Integer, 'Number of thumbnail columns (default: 5)') { |c| columns = c }
|
|
40
|
+
opts.on('-s', '--start=INT', Integer, 'Start point for making thumbnails in seconds (default: 1)') { |s| start = s }
|
|
41
|
+
opts.on('-T', '--temp=STRING', String, 'Specify a temporary directory (default /tmp)') { |t| temp = t }
|
|
42
|
+
opts.on('-t', '--thumbs=INT', Integer, 'Number of thumbs to generate - the length of the video is divided equally by this (default: 20)') { |th| thumbs = th }
|
|
43
|
+
opts.on('-w', '--width=INT', Integer, 'Width of a single thumbnail - Height calculated automaticly (default: 320px)') { |w| width = w }
|
|
44
|
+
opts.on('-f', '--[no-]force=[FLAG]', TrueClass, 'force mode - override output') { |f| force = f }
|
|
45
|
+
opts.parse!
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
if ARGV.empty?
|
|
49
|
+
puts ARGV.options
|
|
50
|
+
exit
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
identify_args = '-frames 1 -nosound -vo null -identify '
|
|
54
|
+
identify_cmd = 'mplayer -nolirc ' + identify_args + '"' + ARGV[0] + '" 2> /dev/null'
|
|
55
|
+
thumb_args = '-osdlevel 2 -vo png -nosound -frames 1 -vf expand=-1:-1:-1:-1:1 '
|
|
56
|
+
thumb_cmd = 'mplayer -nolirc ' + thumb_args + '"' + ARGV[0] + '" 2> /dev/null'
|
|
57
|
+
|
|
58
|
+
unless File.exist?(ARGV[0])
|
|
59
|
+
puts 'Input video file does not exits'
|
|
60
|
+
exit
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
if File.exist?(output) && !defined? force
|
|
64
|
+
puts 'Output file already exists: use -f to override'
|
|
65
|
+
exit
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
if File.exist?(output) && defined? force
|
|
69
|
+
puts 'Output file already exists: deleting' if verbose
|
|
70
|
+
File.unlink(output)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
unless File.directory?(temp)
|
|
74
|
+
puts 'Temp directory does not exists'
|
|
75
|
+
exit
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
unless File.writable?(temp)
|
|
79
|
+
puts 'Temp directory is not writable'
|
|
80
|
+
exit
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
puts "Temp directory: #{temp} - exists and is writable" if verbose
|
|
84
|
+
|
|
85
|
+
id = {}
|
|
86
|
+
|
|
87
|
+
`#{identify_cmd}`.split("\n").grep(/^ID/).each do |line|
|
|
88
|
+
key = line.chomp.split('=')[0]
|
|
89
|
+
value = line.chomp.split('=')[1]
|
|
90
|
+
id[key] = value
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
step = (id['ID_LENGTH'].to_i / thumbs).to_i
|
|
94
|
+
|
|
95
|
+
1.upto(thumbs).tqdm.each do |i|
|
|
96
|
+
thumb_time = i * step
|
|
97
|
+
break if thumb_time > id['ID_LENGTH'].to_i
|
|
98
|
+
`#{thumb_cmd} -ss #{thumb_time}`
|
|
99
|
+
index = format('%.8d', i)
|
|
100
|
+
if verbose
|
|
101
|
+
tt = format('%.8d', thumb_time)
|
|
102
|
+
puts "Dumping [Time: #{tt}] #{temp}/screen-#{index}.png"
|
|
103
|
+
end
|
|
104
|
+
FileUtils.move '00000001.png', "#{temp}/screen-#{index}.png"
|
|
105
|
+
`mogrify -border 10 -sample #{width}x #{temp}/screen-#{index}.png`
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
header = File.basename(id['ID_FILENAME']) + "\nvcodec: " + id['ID_VIDEO_FORMAT'] + ', fps: ' + id['ID_VIDEO_FPS'] + ', resolution: ' + id['ID_VIDEO_WIDTH'] + 'x' + id['ID_VIDEO_HEIGHT'] + "\n"
|
|
109
|
+
|
|
110
|
+
`echo "#{header}" | convert -background none -pointsize 18 text:- -trim +repage -flatten #{temp}/header.png`
|
|
111
|
+
|
|
112
|
+
thumbs = Dir.new(temp).grep(/screen/).sort
|
|
113
|
+
|
|
114
|
+
len = thumbs.length
|
|
115
|
+
|
|
116
|
+
col = 0
|
|
117
|
+
row = ''
|
|
118
|
+
cmd = 'convert'
|
|
119
|
+
|
|
120
|
+
len.times do |idx|
|
|
121
|
+
row = row + ' ' + temp + '/' + thumbs[idx]
|
|
122
|
+
col += 1
|
|
123
|
+
next unless col == columns || idx + 1 == len
|
|
124
|
+
row += ' +append'
|
|
125
|
+
col = 0
|
|
126
|
+
cmd += ' \\(' + row + ' \\)'
|
|
127
|
+
row = ''
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
cmd += " -append #{temp}/tmp.png"
|
|
131
|
+
|
|
132
|
+
if verbose
|
|
133
|
+
puts "Joining thumbs to: #{output}"
|
|
134
|
+
puts 'Executing: ' + cmd
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
`#{cmd}`
|
|
138
|
+
|
|
139
|
+
Dir.new(temp).grep(/screen-.*png/).each do |file|
|
|
140
|
+
puts "Deleting #{temp}/#{file}" if verbose
|
|
141
|
+
File.unlink("#{temp}/#{file}")
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
`convert -gravity center -background white #{temp}/header.png #{temp}/tmp.png -append #{output}`
|
|
145
|
+
|
|
146
|
+
puts "Deleting #{temp}/tmp.png" if verbose
|
|
147
|
+
File.unlink("#{temp}/tmp.png")
|
|
148
|
+
puts "Deleting #{temp}/header.png" if verbose
|
|
149
|
+
File.unlink("#{temp}/header.png")
|
|
150
|
+
|
|
151
|
+
puts 'DONE.' if verbose
|
data/thumbsdown.gemspec
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
Gem::Specification.new do |spec|
|
|
2
|
+
spec.name = 'thumbsdown'
|
|
3
|
+
spec.version = '0.1.0'
|
|
4
|
+
spec.authors = ['Adam Ladachowski']
|
|
5
|
+
spec.email = ['adam.ladachowski@gmail.com']
|
|
6
|
+
|
|
7
|
+
spec.summary = 'Thumbnail generator for video files'
|
|
8
|
+
spec.description = 'Script to generate a thumbnail grid in the form of a PNG file from a video source'
|
|
9
|
+
spec.homepage = 'https://github.com/aladac/thumbsdown'
|
|
10
|
+
spec.license = 'MIT'
|
|
11
|
+
|
|
12
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
13
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
14
|
+
if spec.respond_to?(:metadata)
|
|
15
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
|
16
|
+
else
|
|
17
|
+
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
|
18
|
+
'public gem pushes.'
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
23
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
25
|
+
end
|
|
26
|
+
spec.bindir = 'exe'
|
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
28
|
+
|
|
29
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
|
30
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
|
31
|
+
spec.add_dependency 'tqdm'
|
|
32
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: thumbsdown
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Adam Ladachowski
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2018-07-03 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.16'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.16'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: tqdm
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
description: Script to generate a thumbnail grid in the form of a PNG file from a
|
|
56
|
+
video source
|
|
57
|
+
email:
|
|
58
|
+
- adam.ladachowski@gmail.com
|
|
59
|
+
executables:
|
|
60
|
+
- thumbsdown
|
|
61
|
+
extensions: []
|
|
62
|
+
extra_rdoc_files: []
|
|
63
|
+
files:
|
|
64
|
+
- ".gitignore"
|
|
65
|
+
- Gemfile
|
|
66
|
+
- Gemfile.lock
|
|
67
|
+
- LICENSE.txt
|
|
68
|
+
- README.md
|
|
69
|
+
- Rakefile
|
|
70
|
+
- exe/thumbsdown
|
|
71
|
+
- thumbsdown.gemspec
|
|
72
|
+
homepage: https://github.com/aladac/thumbsdown
|
|
73
|
+
licenses:
|
|
74
|
+
- MIT
|
|
75
|
+
metadata:
|
|
76
|
+
allowed_push_host: https://rubygems.org
|
|
77
|
+
post_install_message:
|
|
78
|
+
rdoc_options: []
|
|
79
|
+
require_paths:
|
|
80
|
+
- lib
|
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
82
|
+
requirements:
|
|
83
|
+
- - ">="
|
|
84
|
+
- !ruby/object:Gem::Version
|
|
85
|
+
version: '0'
|
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
|
+
requirements:
|
|
88
|
+
- - ">="
|
|
89
|
+
- !ruby/object:Gem::Version
|
|
90
|
+
version: '0'
|
|
91
|
+
requirements: []
|
|
92
|
+
rubyforge_project:
|
|
93
|
+
rubygems_version: 2.7.6
|
|
94
|
+
signing_key:
|
|
95
|
+
specification_version: 4
|
|
96
|
+
summary: Thumbnail generator for video files
|
|
97
|
+
test_files: []
|