video2gif 0.0.32 → 0.0.33
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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +3 -5
- data/lib/video2gif/cli.rb +25 -19
- data/lib/video2gif/ffmpeg.rb +25 -3
- data/lib/video2gif/options.rb +9 -10
- data/lib/video2gif/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e4bff1ae338db86be23755a9bdf6bb4e5a877b942f3a48c32af28317e35c8508
|
|
4
|
+
data.tar.gz: d3aa41909f20f0ef78ca35fafa2efc4dc09932aa63372401a44efb65c3d315d2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d2608410cbbf81ab35a88825a66b5b9f11bfa9cbe00f42fdafa9c6a5f112ce8070595dabe4cba2cec879a7133a13defbcd633d3706b0f004f8b614c0eec28582
|
|
7
|
+
data.tar.gz: 2fe3759d6bc111f056b0f15f0c77c516d508186cedb5ca41a68281346b9428a0d0efa6ec8b1a101088d90f26990f0a41d308f51c47f4b6ee12d5e88a3753270a
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -33,15 +33,13 @@ Installation
|
|
|
33
33
|
|
|
34
34
|
`video2gif` is a command-line tool requiring both Ruby and a recent
|
|
35
35
|
version of [FFmpeg] installed and available in the system `$PATH`. If
|
|
36
|
-
you can run
|
|
37
|
-
to run `video2gif`.
|
|
36
|
+
you can run `ffmpeg` and `ffprobe` from the command line, you likely
|
|
37
|
+
have the ability to run `video2gif`.
|
|
38
38
|
|
|
39
39
|
Note that some features may not work by default. For example,
|
|
40
40
|
tonemapping (used for HDR videos) requires `libzimg` support, not
|
|
41
41
|
included by default in the [FFmpeg] supplied by [Homebrew]. If you
|
|
42
|
-
attempt to use it, you will get an error.
|
|
43
|
-
(usually supplied by [FFmpeg]) is required for subtitles and may become
|
|
44
|
-
required in the future for all functionality.
|
|
42
|
+
attempt to use it, you will get an error.
|
|
45
43
|
|
|
46
44
|
`video2gif` also requires Ruby and the ability to install a new gem. If
|
|
47
45
|
you have this available, run the following command to install it.
|
data/lib/video2gif/cli.rb
CHANGED
|
@@ -9,33 +9,39 @@ require 'video2gif'
|
|
|
9
9
|
module Video2gif
|
|
10
10
|
module CLI
|
|
11
11
|
def self.start
|
|
12
|
+
unless Utils.is_executable?('ffmpeg')
|
|
13
|
+
puts 'ERROR: Requires FFmpeg to be installed!'
|
|
14
|
+
exit 1
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
unless Utils.is_executable?('ffprobe')
|
|
18
|
+
puts 'ERROR: Requires FFmpeg utils to be installed (for ffprobe)!'
|
|
19
|
+
exit 1
|
|
20
|
+
end
|
|
21
|
+
|
|
12
22
|
logger = Logger.new(STDOUT)
|
|
13
23
|
options = Options.parse(ARGV)
|
|
14
24
|
|
|
15
|
-
|
|
16
|
-
lines = []
|
|
25
|
+
lines = []
|
|
17
26
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
Open3.popen2e(*FFmpeg.ffprobe_command(options, logger)) do |stdin, stdout_stderr, thread|
|
|
28
|
+
stdin.close
|
|
29
|
+
stdout_stderr.each do |line|
|
|
30
|
+
logger.info(line.chomp) if options[:verbose] unless options[:quiet]
|
|
31
|
+
lines << line
|
|
32
|
+
end
|
|
33
|
+
stdout_stderr.close
|
|
25
34
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
end
|
|
35
|
+
unless thread.value.success?
|
|
36
|
+
# TODO: more info, output lines with errors?
|
|
37
|
+
raise "Process #{thread.pid} failed! Try again with --verbose to see error."
|
|
30
38
|
end
|
|
39
|
+
end
|
|
31
40
|
|
|
32
|
-
|
|
41
|
+
options[:probe_infos] = JSON.parse(lines.join, symbolize_names: true)
|
|
33
42
|
|
|
34
|
-
if options[:subtitles] && !options[:probe_infos][:streams].any?
|
|
35
|
-
|
|
36
|
-
end
|
|
37
|
-
logger.warn('Could not find subtitles in the file, they will be omitted') unless options[:quiet]
|
|
38
|
-
end
|
|
43
|
+
if options[:subtitles] && !options[:probe_infos][:streams].any? { |s| s[:codec_type] == 'subtitle' }
|
|
44
|
+
logger.warn('Could not find subtitles in the file, they will be omitted') unless options[:quiet]
|
|
39
45
|
end
|
|
40
46
|
|
|
41
47
|
if options[:autocrop]
|
data/lib/video2gif/ffmpeg.rb
CHANGED
|
@@ -11,9 +11,11 @@ module Video2gif
|
|
|
11
11
|
|
|
12
12
|
# If we want subtitles and *have* subtitles, we need some info to
|
|
13
13
|
# use them.
|
|
14
|
+
video_info = options[:probe_infos][:streams].find { |s| s[:codec_type] == 'video' }
|
|
14
15
|
if options[:subtitles] && options[:probe_infos][:streams].any? { |s| s[:codec_type] == 'subtitle' }
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
subtitle_info = options[:probe_infos][:streams]
|
|
17
|
+
.find_all { |s| s[:codec_type] == 'subtitle' }
|
|
18
|
+
.fetch(options[:subtitle_index], nil)
|
|
17
19
|
end
|
|
18
20
|
|
|
19
21
|
# Bitmap formatted subtitles go first so that they get scaled
|
|
@@ -30,7 +32,24 @@ module Video2gif
|
|
|
30
32
|
filtergraph << '[0:v][subs]overlay=format=auto'
|
|
31
33
|
end
|
|
32
34
|
|
|
33
|
-
#
|
|
35
|
+
# Slow down or speed up video as early as possible so that we
|
|
36
|
+
# don't end up trying to interpolate frames in that we already
|
|
37
|
+
# dropped.
|
|
38
|
+
if options[:rate]
|
|
39
|
+
filtergraph << "setpts=PTS/#{options[:rate]}" if options[:rate]
|
|
40
|
+
if Float(options[:rate]) < 1 # interpolate slowed down video
|
|
41
|
+
minterpolate = []
|
|
42
|
+
minterpolate << 'mi_mode=mci'
|
|
43
|
+
minterpolate << 'mc_mode=aobmc'
|
|
44
|
+
minterpolate << 'me_mode=bidir'
|
|
45
|
+
minterpolate << 'me=epzs'
|
|
46
|
+
minterpolate << 'vsbmc=1'
|
|
47
|
+
minterpolate << "fps=#{video_info[:avg_frame_rate] }/#{options[:rate]}"
|
|
48
|
+
filtergraph << 'minterpolate=' + minterpolate.join(':')
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Set 'fps' filter early, drop unneeded frames instead of
|
|
34
53
|
# processing those.
|
|
35
54
|
filtergraph << "fps=#{ options[:fps] || 10 }"
|
|
36
55
|
|
|
@@ -161,6 +180,9 @@ module Video2gif
|
|
|
161
180
|
command << '-ss' << options[:seek] if options[:seek]
|
|
162
181
|
command << '-t' << options[:time] if options[:time]
|
|
163
182
|
command << '-i' << options[:input_filename]
|
|
183
|
+
command << '-an'
|
|
184
|
+
command << '-sn'
|
|
185
|
+
command << '-dn'
|
|
164
186
|
end
|
|
165
187
|
|
|
166
188
|
def self.cropdetect_command(options, logger, executable: 'ffmpeg')
|
data/lib/video2gif/options.rb
CHANGED
|
@@ -165,11 +165,6 @@ module Video2gif
|
|
|
165
165
|
'resulting GIF. May be extremely slow for text subtitles.',
|
|
166
166
|
'Takes an optional integer value to choose the subtitle',
|
|
167
167
|
'stream (defaults to the first subtitle stream, index 0)') do |s|
|
|
168
|
-
unless Utils.is_executable?('ffprobe')
|
|
169
|
-
puts 'ERROR: Requires FFmpeg utils to be installed (for ffprobe)!'
|
|
170
|
-
exit 1
|
|
171
|
-
end
|
|
172
|
-
|
|
173
168
|
options[:subtitles] = s || true
|
|
174
169
|
options[:subtitle_index] = if options[:subtitles].is_a?(TrueClass) # default to first stream
|
|
175
170
|
0
|
|
@@ -181,6 +176,15 @@ module Video2gif
|
|
|
181
176
|
end
|
|
182
177
|
end
|
|
183
178
|
|
|
179
|
+
parser.on('-r MULTIPLIER',
|
|
180
|
+
'--rate MULTIPLIER',
|
|
181
|
+
'--speed MULTIPLIER',
|
|
182
|
+
'(Experimental, SLOW) Multiplier for the speed of the',
|
|
183
|
+
'GIF, where less than 1 indicates a lower speed and',
|
|
184
|
+
'greater than 1 indicates a faster speed (default 1)') do |r|
|
|
185
|
+
options[:rate] = r
|
|
186
|
+
end
|
|
187
|
+
|
|
184
188
|
parser.separator ''
|
|
185
189
|
parser.separator 'Text overlay options (only used if text is defined):'
|
|
186
190
|
|
|
@@ -253,11 +257,6 @@ module Video2gif
|
|
|
253
257
|
|
|
254
258
|
parser.parse!
|
|
255
259
|
|
|
256
|
-
unless Utils.is_executable?('ffmpeg')
|
|
257
|
-
puts 'ERROR: Requires FFmpeg to be installed!'
|
|
258
|
-
exit 1
|
|
259
|
-
end
|
|
260
|
-
|
|
261
260
|
if args.size < 1 || args.size > 2
|
|
262
261
|
puts 'ERROR: Specify one video to convert at a time!'
|
|
263
262
|
puts ''
|
data/lib/video2gif/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: video2gif
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.33
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Emily St.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-06-
|
|
11
|
+
date: 2019-06-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|