checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
---
2
2
SHA256:
3
- metadata.gz: cbacc62b58b0bfda756ed9ab6dd805d7ed2f83f53ad4b9a473380c333a03fa36
4
- data.tar.gz: cdac5c566f42e62025b9f1eca06c633d676725e7c47bdaf56efd30eb35ec32fa
3
+ metadata.gz: b4f3dc6fd106de062e6fe2a03dacbf50d69cff96fbbeeb3043f69fc90df5c9d5
4
+ data.tar.gz: bf3fc236630746840ac5679d11079d26862cee34f3b87cac669c57e846bac095
5
5
SHA512:
6
- metadata.gz: 1a70f3e4b577446166522283413fedeaa0c4e080628ffe8ec050ce544be7df72ccd30a90a0c33338e5b7b4e5e256dba7db0eb67c86f3d931b42e0142ba61a10d
7
- data.tar.gz: 76bf6aa4ee171e44d58ef4c9a5401361a7a186b550c03f4a58beda77fc7d8cbc163a0eb7d21312ca95fc157376757e993a562698ad407023e3ca402bd99e250b
6
+ metadata.gz: a9523d0dc0f3d496af26cfce9f348cd354d817171e825a23171547f14265dc85119174e3a355179ae3aa485a6c0207e771c5c68b7363fda9a544c801dfb51cdc
7
+ data.tar.gz: 2b86b8e354e57a1663fc75acd1d476a05d0ccde8e482a01f6b53d75f39629392a3d8b47604ebe968fafa96f826bc51d4655caca4928d5417c00e010835aec30d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
PATH
2
2
remote: .
3
3
specs:
4
- evideo (0.1.4)
4
+ evideo (0.1.5)
5
5
thor (~> 0.1)
6
6
7
7
GEM
data/lib/evideo.rb CHANGED
@@ -18,22 +18,33 @@ module Evideo
18
18
desc 'conv', 'converte videos'
19
19
option :o, banner: 'OUT', default: 'out',
20
20
desc: 'Pasta destino'
21
+ option :t, type: :boolean, default: false,
22
+ desc: 'Processa somente segundos para teste'
21
23
# Processa videos
22
24
def conv
23
- dar = options[:d]
24
- Dir.glob("#{dar.first}/#{options[:i]}/*.???").sort.each do |f|
25
+ Dir.glob("#{fin}/*.???").sort.each do |f|
26
+ HRVideo.new(f).processa(options, fout)
25
- HRVideo.new(f).processa(dar, options[:o], dar.first)
26
27
end
27
28
end
28
29
29
30
desc 'test', 'testa videos'
30
31
# Analisa videos
31
32
def test
32
- dar = options[:d]
33
- Dir.glob("#{dar.first}/#{options[:i]}/*.???").sort.each do |f|
33
+ Dir.glob("#{fin}/*.???").sort.each do |f|
34
+ HRVideo.new(f).testa(options)
34
- HRVideo.new(f).testa(dar, options[:o])
35
35
end
36
36
end
37
37
default_task :conv
38
+ no_commands do
39
+ # @return [String] pasta absoluta origem dos videos
40
+ def fin
41
+ "#{options[:d].first}/#{options[:i]}"
42
+ end
43
+
44
+ # @return [String] pasta absoluta destino dos videos
45
+ def fout
46
+ "#{options[:d].first}/#{options[:o]}"
47
+ end
48
+ end
38
49
end
39
50
end
data/lib/evideo/hrvprocessa.rb CHANGED
@@ -9,7 +9,7 @@ module Evideo
9
9
def show
10
10
return video unless @probe
11
11
12
- "tempo: #{duration} rate: #{bitrate}"
12
+ "tempo: #{duration} rate: #{bitrate} ratio: #{ratio} height: #{height}"
13
13
end
14
14
15
15
# Testa validade video original
@@ -18,6 +18,7 @@ module Evideo
18
18
def ofok?
19
19
return false unless (bitrate < 3000 && ext == '.mp4') ||
20
20
Time.parse(duration) < Time.parse('00:01:00')
21
+ return false unless ratio == '16:9' && height > 480
21
22
22
23
puts "rm \"#{video}\" # #{show}"
23
24
true
@@ -58,16 +59,16 @@ module Evideo
58
59
59
60
# @return [String] aspect ratio comando conversao
60
61
def aspect
61
- if ratio == '0:1' then bitrate < 720 ? '' : ' -aspect 16:9'
62
+ if ratio == '0:1' then height < 720 ? '' : ' -aspect 16:9'
62
63
else " -aspect #{ratio}"
63
64
end
64
65
end
65
66
66
67
# @return [String] video dimensions comando conversao
67
68
def dimension
68
- if bitrate < 480 then ' -s hd480'
69
- elsif bitrate <= 720 then ' -s hd720'
70
- else ' -s hd1080'
69
+ if height < 480 then ' -s hd480'
70
+ elsif height <= 720 then ' -s hd720'
71
+ else ' -s hd1080'
71
72
end
72
73
end
73
74
@@ -76,8 +77,11 @@ module Evideo
76
77
"ffprobe -hide_banner -show_streams \"#{video}\" 2>&1|grep -v title"
77
78
end
78
79
80
+ # Comando para processar videos
81
+ #
82
+ # @param [String] tempo do video processato
79
83
# @return [String] comando conversao
80
- def mpeg
84
+ def mpeg(tempo)
81
85
"ffmpeg #{geral} -i \"#{video}\" -y -an " +
82
86
# framerate & bitrate
83
87
"-r #{[fps, 25].min} -b:v #{[bitrate, 2000].min}k" +
@@ -85,28 +89,33 @@ module Evideo
85
89
' -metadata title= -metadata artist= -metadata comment=' \
86
90
' -metadata major_brand= -metadata compatible_brands=' +
87
91
# para teste produz somente segundos
88
- # ' -t 20' \
92
+ tempo
89
- ''
90
93
end
91
94
92
95
# Processa videos
93
96
#
94
- # @param [Array<String>] dar locais onde procurar videos
95
- # @param [String] out pasta destino dos videos
96
- # @param [String] din pasta origem dos videos
97
- def processa(dar, out, din)
98
- return if ofok? || vdok?(dar, out)
99
-
100
- system mpeg + " #{din}/#{out}/#{base}.mp4"
101
- vfok?(HRVideo.new("#{din}/#{out}/#{base}.mp4"))
97
+ # @param [Hash] opcoes parametrizacao
98
+ # @option opcoes [Array<String>] :d locais onde procurar videos
99
+ # @option opcoes [<String>] :i pasta origem dos videos
100
+ # @option opcoes [<String>] :o pasta destino dos videos
101
+ # @option opcoes [<Boolean>] :t processa somente segundos para teste
102
+ # @param [String] out pasta destino dos videos absoluta
103
+ def processa(opcoes, out)
104
+ return if ofok? || vdok?(opcoes[:d], opcoes[:o])
105
+
106
+ system mpeg(opcoes[:t] ? ' -t 20' : '') + " #{out}/#{base}.mp4"
107
+ vfok?(HRVideo.new("#{out}/#{base}.mp4"))
102
108
end
103
109
104
110
# Testa videos
105
111
#
106
- # @param [Array<String>] dar locais onde procurar videos
107
- # @param [String] out pasta destino dos videos
108
- def testa(dar, out)
109
- return if ofok? || vdok?(dar, out)
112
+ # @param [Hash] opcoes parametrizacao
113
+ # @option opcoes [Array<String>] :d locais onde procurar videos
114
+ # @option opcoes [<String>] :i pasta origem dos videos
115
+ # @option opcoes [<String>] :o pasta destino dos videos
116
+ # @option opcoes [<Boolean>] :t processa somente segundos para teste
117
+ def testa(opcoes)
118
+ return if ofok? || vdok?(opcoes[:d], opcoes[:o])
110
119
111
120
puts "ls \"#{video}\" # #{show}"
112
121
end
data/lib/evideo/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
# frozen_string_literal: true
2
2
3
3
module Evideo
4
- VERSION = '0.1.4'
4
+ VERSION = '0.1.5'
5
5
end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
--- !ruby/object:Gem::Specification
2
2
name: evideo
3
3
version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
platform: ruby
6
6
authors:
7
7
- Hernâni Rodrigues Vaz
8
8
autorequire:
9
9
bindir: exe
10
10
cert_chain: []
11
- date: 2019-12-03 00:00:00.000000000 Z
11
+ date: 2019-12-05 00:00:00.000000000 Z
12
12
dependencies:
13
13
- !ruby/object:Gem::Dependency
14
14
name: bundler