video2gif 0.0.7 → 0.0.9

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: 92d78189e8061dcc25298f5e8fb65e84c39688479f7f087761a16fbab16b5c60
4
- data.tar.gz: d50fcf7f759e6578beb1730c9a1f2de95b5518c5fdae9a36125405d888a85c03
3
+ metadata.gz: de00f9f371c9632397ca52a27968a790f7e68fc58580b5438dfe9a73600a072e
4
+ data.tar.gz: 159321148a290683426e35b76aa5a9f2ebe2cc1e78f122ebc07b2738e67f02c9
5
5
  SHA512:
6
- metadata.gz: 57774248542d5c75031ff1596094b3698ee13b48df7ca0a0715c314da676bfe62601396249bbc1d0b0116be97a83351a65a5f9ffded88deb26ac9779afb645c2
7
- data.tar.gz: 7661e6761b9ceb828bace679eb552f9ffdabf31fdd43b31a63e4ad480bed4514b5733b2a4958a868cd698cd96d7fd3d93da6d31da1fc31e008369a695f8fa64c
6
+ metadata.gz: 8a067a16a488490ac8d076cac3802b1f4d99428507b59f1abd72f414fdc90c7a3eea80f345a40aaa95c78faeff04016ebffe2908a15ca00b6fb5f7f365bed56d
7
+ data.tar.gz: 0fa948c4872e6ca1297e2a6c4c9b5dffdb89ff2ecd232b2c16bfea75bb085cbdc9779bceb353ef552cbc4741ed8a1c5559f7a3160b59578d5f46dd46a5ab16a1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- video2gif (0.0.4)
4
+ video2gif (0.0.9)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/lib/video2gif/cli.rb CHANGED
@@ -11,14 +11,14 @@ module Video2gif
11
11
  logger = Logger.new(STDOUT)
12
12
  options = Video2gif::Options.parse(ARGV)
13
13
 
14
- if options[:cropdetect]
14
+ if options[:autocrop]
15
15
  Open3.popen3(*Video2gif::FFMpeg.cropdetect_command(options, logger)) do |stdin, stdout, stderr, thread|
16
16
  stdin.close
17
17
  stdout.close
18
18
  stderr.each(chomp: true) do |line|
19
19
  logger.info(line) if options[:verbose] unless options[:quiet]
20
20
  if line.include?('Parsed_cropdetect')
21
- options[:cropdetect] = line.match('crop=([0-9]+\:[0-9]+\:[0-9]+\:[0-9]+)')
21
+ options[:autocrop] = line.match('crop=([0-9]+\:[0-9]+\:[0-9]+\:[0-9]+)')
22
22
  end
23
23
  end
24
24
  stderr.close
@@ -9,23 +9,22 @@ module Video2gif
9
9
  width = options[:width] # default is not to scale at all
10
10
 
11
11
  # create filter elements
12
- palettegen_fps_filter = "fps=2" # sample only a few frames a second
13
- paletteuse_fps_filter = "fps=#{fps}"
14
- crop_filter = options[:cropdetect] || 'crop=' + %W[
15
- w=#{ options[:wregion] || 'in_w' }
16
- h=#{ options[:hregion] || 'in_h' }
17
- x=#{ options[:xoffset] || 0 }
18
- y=#{ options[:yoffset] || 0 }
19
- ].join(':')
12
+ fps_filter = "fps=#{fps}"
13
+ crop_filter = options[:autocrop] || 'crop=' + %W[
14
+ w=#{ options[:wregion] || 'in_w' }
15
+ h=#{ options[:hregion] || 'in_h' }
16
+ x=#{ options[:xoffset] || 0 }
17
+ y=#{ options[:yoffset] || 0 }
18
+ ].join(':')
20
19
  scale_filter = "scale=#{width}:-1:flags=lanczos:sws_dither=none" if options[:width] unless options[:tonemap]
21
20
  tonemap_filters = if options[:tonemap] # TODO: detect input format
22
21
  %W[
23
- zscale=w=#{width}:h=-1
24
- zscale=t=linear:npl=100
22
+ zscale=dither=none:filter=lanczos:width=#{width}:height=-1
23
+ zscale=transfer=linear:npl=100
25
24
  format=yuv420p10le
26
- zscale=p=bt709
25
+ zscale=primaries=bt709
27
26
  tonemap=tonemap=#{options[:tonemap]}:desat=0
28
- zscale=t=bt709:m=bt709:r=tv
27
+ zscale=transfer=bt709:matrix=bt709:range=tv
29
28
  format=yuv420p
30
29
  ].join(',')
31
30
  end
@@ -40,8 +39,10 @@ module Video2gif
40
39
  gamma_b=#{ options[:gamma_b] || 1 }
41
40
  ].join(':')
42
41
  end
43
- palettegen_filter = "palettegen=#{max_colors}stats_mode=full"
44
- paletteuse_filter = 'paletteuse=dither=floyd_steinberg:diff_mode=rectangle'
42
+ split_filter = 'split [o1] [o2]'
43
+ palettegen_filter = "[o1] palettegen=#{max_colors}stats_mode=diff [p]"
44
+ fifo_filter = '[o2] fifo [o3]'
45
+ paletteuse_filter = '[o3] [p] paletteuse=dither=floyd_steinberg:diff_mode=rectangle'
45
46
  drawtext_filter = if options[:text]
46
47
  count_of_lines = options[:text].scan(/\\n/).count + 1
47
48
 
@@ -73,30 +74,13 @@ module Video2gif
73
74
 
74
75
  filter_complex = []
75
76
 
76
- # first, apply the same filters we'll use later in the same order
77
- # before applying the palettegen so that we accurately predict the
78
- # final palette
79
- filter_complex << palettegen_fps_filter
80
- filter_complex << crop_filter if crop_filter
81
- filter_complex << scale_filter if options[:width] unless options[:tonemap]
82
- filter_complex << tonemap_filters if options[:tonemap]
83
- filter_complex << eq_filter if options[:eq]
84
- filter_complex << drawtext_filter if options[:text]
85
-
86
- # then generate the palette (and label this filter stream)
87
- filter_complex << palettegen_filter + '[palette]'
88
-
89
- # then refer back to the first video input stream and the filter
90
- # complex stream to apply the generated palette to the video stream
91
- # along with the other filters (drawing text last so that it isn't
92
- # affected by scaling)
93
- filter_complex << '[0:v][palette]' + paletteuse_filter
94
- filter_complex << paletteuse_fps_filter
77
+ filter_complex << fps_filter
95
78
  filter_complex << crop_filter if crop_filter
96
79
  filter_complex << scale_filter if options[:width] unless options[:tonemap]
97
80
  filter_complex << tonemap_filters if options[:tonemap]
98
81
  filter_complex << eq_filter if options[:eq]
99
82
  filter_complex << drawtext_filter if options[:text]
83
+ filter_complex << split_filter << palettegen_filter << fifo_filter << paletteuse_filter
100
84
 
101
85
  filter_complex.join(',')
102
86
  end
@@ -104,11 +88,10 @@ module Video2gif
104
88
  def self.cropdetect_command(options, logger)
105
89
  command = ['ffmpeg']
106
90
  command << '-analyzeduration' << '2147483647' << '-probesize' << '2147483647'
107
- command << '-nostdin'
108
91
  command << '-ss' << options[:seek] if options[:seek]
109
92
  command << '-t' << options[:time] if options[:time]
110
93
  command << '-i' << options[:input_filename]
111
- command << '-filter_complex' << "cropdetect=limit=#{options[:cropdetect]}"
94
+ command << '-filter_complex' << "cropdetect=limit=#{options[:autocrop]}"
112
95
  command << '-f' << 'null'
113
96
  command << '-'
114
97
 
@@ -121,12 +104,10 @@ module Video2gif
121
104
  command = ['ffmpeg']
122
105
  command << '-y' # always overwrite
123
106
  command << '-analyzeduration' << '2147483647' << '-probesize' << '2147483647'
124
- command << '-nostdin'
125
107
  command << '-ss' << options[:seek] if options[:seek]
126
108
  command << '-t' << options[:time] if options[:time]
127
109
  command << '-i' << options[:input_filename]
128
110
  command << '-filter_complex' << filter_complex(options)
129
- command << '-gifflags' << '+transdiff' # enabled by default
130
111
  command << '-f' << 'gif'
131
112
  command << options[:output_filename]
132
113
 
@@ -81,11 +81,11 @@ module Video2gif
81
81
  options[:yoffset] = o
82
82
  end
83
83
 
84
- parser.on('-d [THRESHOLD]',
85
- '--crop-detect [THRESHOLD]',
84
+ parser.on('-a [THRESHOLD]',
85
+ '--autocrop [THRESHOLD]',
86
86
  'Attempt automatic cropping based on black region, scaled',
87
87
  'from 0 (nothing) to 255 (everything), default threshold 24') do |c|
88
- options[:cropdetect] = c || 24
88
+ options[:autocrop] = c || 24
89
89
  end
90
90
 
91
91
  parser.on('--contrast CONTRAST',
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Video2gif
4
- VERSION = '0.0.7'
4
+ VERSION = '0.0.9'
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.7
4
+ version: 0.0.9
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-04-20 00:00:00.000000000 Z
11
+ date: 2019-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler