video2gif 0.0.32 → 0.0.33

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f2905fc3a1a3ebebfa2f2e9cfe464ddff85f3e287d163b4eb5195a6b9766e3bb
4
- data.tar.gz: 4fd1a4c2233f36261253684a57ed285b06dfde299c66c953d30467fe905591f7
3
+ metadata.gz: e4bff1ae338db86be23755a9bdf6bb4e5a877b942f3a48c32af28317e35c8508
4
+ data.tar.gz: d3aa41909f20f0ef78ca35fafa2efc4dc09932aa63372401a44efb65c3d315d2
5
5
  SHA512:
6
- metadata.gz: 3f086509e0375b35179c4e583601c5808c5958ee2f16a7093831ef305b0c5e35dc7c179f222cc9814057e5f62cca2edff974c2cdca07c1780625fb27cda4ecc1
7
- data.tar.gz: de455ff906c6a4a8c0254edb74dc646e55facb932c0f07fe866732e057ac867e407f032733258a14f981bf62086c98062e41bee5f5f7d6e2a02208e38cc987c6
6
+ metadata.gz: d2608410cbbf81ab35a88825a66b5b9f11bfa9cbe00f42fdafa9c6a5f112ce8070595dabe4cba2cec879a7133a13defbcd633d3706b0f004f8b614c0eec28582
7
+ data.tar.gz: 2fe3759d6bc111f056b0f15f0c77c516d508186cedb5ca41a68281346b9428a0d0efa6ec8b1a101088d90f26990f0a41d308f51c47f4b6ee12d5e88a3753270a
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- video2gif (0.0.31)
4
+ video2gif (0.0.33)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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 [FFmpeg] from the command line, you likely have the ability
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. Additionally, `ffprobe`
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.
@@ -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
- if options[:subtitles]
16
- lines = []
25
+ lines = []
17
26
 
18
- Open3.popen2e(*FFmpeg.ffprobe_command(options, logger)) do |stdin, stdout_stderr, thread|
19
- stdin.close
20
- stdout_stderr.each do |line|
21
- logger.info(line.chomp) if options[:verbose] unless options[:quiet]
22
- lines << line
23
- end
24
- stdout_stderr.close
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
- unless thread.value.success?
27
- # TODO: more info, output lines with errors?
28
- raise "Process #{thread.pid} failed! Try again with --verbose to see error."
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
- options[:probe_infos] = JSON.parse(lines.join, symbolize_names: true)
41
+ options[:probe_infos] = JSON.parse(lines.join, symbolize_names: true)
33
42
 
34
- if options[:subtitles] && !options[:probe_infos][:streams].any? do |s|
35
- s[:codec_type] == 'subtitle'
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]
@@ -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
- video_info = options[:probe_infos][:streams].find { |s| s[:codec_type] == 'video' }
16
- subtitle_info = options[:probe_infos][:streams].find_all { |s| s[:codec_type] == 'subtitle' }[options[:subtitle_index]]
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
- # Set 'fps' filter first, drop unneeded frames instead of
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')
@@ -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 ''
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Video2gif
4
- VERSION = '0.0.32'
4
+ VERSION = '0.0.33'
5
5
  end
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.32
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-06 00:00:00.000000000 Z
11
+ date: 2019-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler