video2gif 0.0.29 → 0.0.30
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/video2gif/ffmpeg.rb +35 -33
- data/lib/video2gif/options.rb +9 -5
- 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: 4e3d8fc9f7c1f1753c1aeb09c6760650055182e1b5d2f68d29d1453b14c6a63d
|
4
|
+
data.tar.gz: 9525b0c28289532b777d89b6443fa9873d2ab8c94d3bd01ebcc37c27628a3b33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc904a92ac20deb0bbc643c2cf9fe6919fbbbb9977e78dc08fc12e824acc61e25938ba6160527fd70ecff232d556b2b617f63a84ca61269fea5d3b3404cc000f
|
7
|
+
data.tar.gz: 510759bd40cdec24eb975b68ea48e942806fc54de7c52b3ab11e67f69e6294b506ff8f5270e1b667b79d6992457b9761802615c00f40b0b68aebe86a8a5b313d
|
data/Gemfile.lock
CHANGED
data/lib/video2gif/ffmpeg.rb
CHANGED
@@ -5,51 +5,43 @@ module Video2gif
|
|
5
5
|
module FFmpeg
|
6
6
|
CROP_REGEX = /crop=([0-9]+\:[0-9]+\:[0-9]+\:[0-9]+)/
|
7
7
|
|
8
|
+
# TODO: This whole method needs to be broken up significantly.
|
8
9
|
def self.filtergraph(options)
|
9
10
|
filtergraph = []
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
# If we want subtitles and *have* subtitles, we need some info to
|
13
|
+
# use them.
|
14
|
+
if options[:subtitles] && options[:probe_infos][:streams].any? { |s| s[:codec_type] == 'subtitle' }
|
14
15
|
video_info = options[:probe_infos][:streams].find { |s| s[:codec_type] == 'video' }
|
15
16
|
subtitle_info = options[:probe_infos][:streams].find_all { |s| s[:codec_type] == 'subtitle' }[options[:subtitle_index]]
|
17
|
+
end
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
end
|
19
|
+
# Bitmap formatted subtitles go first so that they get scaled
|
20
|
+
# correctly.
|
21
|
+
if options[:subtitles] &&
|
22
|
+
options[:probe_infos][:streams].any? { |s| s[:codec_type] == 'subtitle' } &&
|
23
|
+
Subtitles::KNOWN_BITMAP_FORMATS.include?(subtitle_info[:codec_name])
|
24
|
+
filtergraph << "[0:s:#{options[:subtitle_index]}]scale=" + %W[
|
25
|
+
flags=lanczos
|
26
|
+
sws_dither=none
|
27
|
+
width=#{video_info[:width]}
|
28
|
+
height=#{video_info[:height]}
|
29
|
+
].join(':') + '[subs]'
|
30
|
+
filtergraph << '[0:v][subs]overlay=format=auto'
|
30
31
|
end
|
31
32
|
|
32
33
|
# Set 'fps' filter first, drop unneeded frames instead of
|
33
34
|
# processing those.
|
34
35
|
filtergraph << "fps=#{ options[:fps] || 10 }"
|
35
36
|
|
36
|
-
#
|
37
|
-
|
38
|
-
|
39
|
-
#
|
40
|
-
if options[:
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
options[:xoffset] ||
|
45
|
-
options[:yoffset]
|
46
|
-
filtergraph << 'crop=' + [
|
47
|
-
"w=#{ options[:wregion] || 'in_w' }",
|
48
|
-
"h=#{ options[:hregion] || 'in_h' }",
|
49
|
-
"x=#{ options[:xoffset] || 0 }",
|
50
|
-
"y=#{ options[:yoffset] || 0 }",
|
51
|
-
].join(':')
|
52
|
-
end
|
37
|
+
# Apply automatic cropping discovered during the cropdetect run.
|
38
|
+
filtergraph << options[:autocrop] if options[:autocrop]
|
39
|
+
|
40
|
+
# Apply manual cropping, if any.
|
41
|
+
filtergraph << "crop=w=#{options[:wregion]}" if options[:wregion]
|
42
|
+
filtergraph << "crop=h=#{options[:hregion]}" if options[:hregion]
|
43
|
+
filtergraph << "crop=x=#{options[:xoffset]}" if options[:xoffset]
|
44
|
+
filtergraph << "crop=y=#{options[:yoffset]}" if options[:yoffset]
|
53
45
|
|
54
46
|
# Scale here before other filters to avoid unnecessary processing.
|
55
47
|
if options[:tonemap]
|
@@ -90,6 +82,16 @@ module Video2gif
|
|
90
82
|
filtergraph << "eq=gamma_g=#{options[:gamma_g]}" if options[:gamma_g]
|
91
83
|
filtergraph << "eq=gamma_b=#{options[:gamma_b]}" if options[:gamma_b]
|
92
84
|
|
85
|
+
# Embed text subtitles later so that they don't get processed by
|
86
|
+
# cropping, etc., which might accidentally crop them out.
|
87
|
+
if options[:subtitles] &&
|
88
|
+
options[:probe_infos][:streams].any? { |s| s[:codec_type] == 'subtitle' } &&
|
89
|
+
Subtitles::KNOWN_TEXT_FORMATS.include?(subtitle_info[:codec_name])
|
90
|
+
filtergraph << "setpts=PTS+#{Utils.duration_to_seconds(options[:seek])}/TB"
|
91
|
+
filtergraph << "subtitles='#{options[:input_filename]}':si=#{options[:subtitle_index]}"
|
92
|
+
filtergraph << 'setpts=PTS-STARTPTS'
|
93
|
+
end
|
94
|
+
|
93
95
|
# If there is text to superimpose, do it here before palette
|
94
96
|
# generation to ensure the color looks appropriate.
|
95
97
|
if options[:text]
|
data/lib/video2gif/options.rb
CHANGED
@@ -68,22 +68,26 @@ module Video2gif
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
parser.on('--crop-
|
71
|
+
parser.on('--crop-width SIZE',
|
72
|
+
'--crop-size-w SIZE',
|
72
73
|
'Pixel size of width to select from source video, before scaling') do |s|
|
73
74
|
options[:wregion] = s
|
74
75
|
end
|
75
76
|
|
76
|
-
parser.on('--crop-
|
77
|
+
parser.on('--crop-height SIZE',
|
78
|
+
'--crop-size-h SIZE',
|
77
79
|
'Pixel size of height to select from source video, before scaling') do |s|
|
78
80
|
options[:hregion] = s
|
79
81
|
end
|
80
82
|
|
81
|
-
parser.on('--crop-
|
83
|
+
parser.on('--crop-x OFFSET',
|
84
|
+
'--crop-offset-x OFFSET',
|
82
85
|
'Pixel offset from left to select from source video, before scaling') do |o|
|
83
86
|
options[:xoffset] = o
|
84
87
|
end
|
85
88
|
|
86
|
-
parser.on('--crop-
|
89
|
+
parser.on('--crop-y OFFSET',
|
90
|
+
'--crop-offset-y OFFSET',
|
87
91
|
'Pixel offset from top to select from source video, before scaling') do |o|
|
88
92
|
options[:yoffset] = o
|
89
93
|
end
|
@@ -257,7 +261,7 @@ module Video2gif
|
|
257
261
|
exit
|
258
262
|
end
|
259
263
|
|
260
|
-
options[:input_filename]
|
264
|
+
options[:input_filename] = args[0]
|
261
265
|
options[:output_filename] = if args[1]
|
262
266
|
args[1].end_with?('.gif') ? args[1] : args[1] + '.gif'
|
263
267
|
else
|
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.30
|
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-
|
11
|
+
date: 2019-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|