evideo 0.1.3 → 0.1.4
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/lib/evideo.rb +4 -3
- data/lib/evideo/hrvideo.rb +6 -6
- data/lib/evideo/hrvprocessa.rb +44 -41
- data/lib/evideo/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: cbacc62b58b0bfda756ed9ab6dd805d7ed2f83f53ad4b9a473380c333a03fa36
|
4
|
+
data.tar.gz: cdac5c566f42e62025b9f1eca06c633d676725e7c47bdaf56efd30eb35ec32fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a70f3e4b577446166522283413fedeaa0c4e080628ffe8ec050ce544be7df72ccd30a90a0c33338e5b7b4e5e256dba7db0eb67c86f3d931b42e0142ba61a10d
|
7
|
+
data.tar.gz: 76bf6aa4ee171e44d58ef4c9a5401361a7a186b550c03f4a58beda77fc7d8cbc163a0eb7d21312ca95fc157376757e993a562698ad407023e3ca402bd99e250b
|
data/Gemfile.lock
CHANGED
data/lib/evideo.rb
CHANGED
@@ -22,15 +22,16 @@ module Evideo
|
|
22
22
|
def conv
|
23
23
|
dar = options[:d]
|
24
24
|
Dir.glob("#{dar.first}/#{options[:i]}/*.???").sort.each do |f|
|
25
|
-
HRVideo.new(f).processa(dar,
|
25
|
+
HRVideo.new(f).processa(dar, options[:o], dar.first)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
desc 'test', 'testa videos'
|
30
30
|
# Analisa videos
|
31
31
|
def test
|
32
|
-
|
33
|
-
|
32
|
+
dar = options[:d]
|
33
|
+
Dir.glob("#{dar.first}/#{options[:i]}/*.???").sort.each do |f|
|
34
|
+
HRVideo.new(f).testa(dar, options[:o])
|
34
35
|
end
|
35
36
|
end
|
36
37
|
default_task :conv
|
data/lib/evideo/hrvideo.rb
CHANGED
@@ -31,18 +31,18 @@ module Evideo
|
|
31
31
|
@probe = `#{probe}` if File.exist?(fvideo)
|
32
32
|
return unless @probe
|
33
33
|
|
34
|
-
|
35
|
-
@duration =
|
36
|
-
@bitrate =
|
34
|
+
tr1 = @probe.scan(R1).flatten
|
35
|
+
@duration = tr1[0]
|
36
|
+
@bitrate = tr1[1].to_i
|
37
37
|
end
|
38
38
|
|
39
39
|
# Parametrizar height e frame rate
|
40
40
|
def r2
|
41
41
|
return unless @probe
|
42
42
|
|
43
|
-
|
44
|
-
@height =
|
45
|
-
@fps =
|
43
|
+
tr2 = @probe.scan(R2).flatten
|
44
|
+
@height = tr2[0].to_i
|
45
|
+
@fps = tr2[1].to_f
|
46
46
|
end
|
47
47
|
|
48
48
|
# Parametrizar aspect ratio
|
data/lib/evideo/hrvprocessa.rb
CHANGED
@@ -5,24 +5,38 @@ require 'time'
|
|
5
5
|
module Evideo
|
6
6
|
# permite analizar/processar videos para arquivo
|
7
7
|
class HRVideo < String
|
8
|
-
#
|
8
|
+
# @return [String] tempo: rate:
|
9
|
+
def show
|
10
|
+
return video unless @probe
|
11
|
+
|
12
|
+
"tempo: #{duration} rate: #{bitrate}"
|
13
|
+
end
|
14
|
+
|
15
|
+
# Testa validade video original
|
9
16
|
#
|
10
|
-
# @param [String] file video a testar validade
|
11
17
|
# @return [true, false] sim ou nao video esta ok
|
12
|
-
def
|
13
|
-
return false unless
|
18
|
+
def ofok?
|
19
|
+
return false unless (bitrate < 3000 && ext == '.mp4') ||
|
20
|
+
Time.parse(duration) < Time.parse('00:01:00')
|
21
|
+
|
22
|
+
puts "rm \"#{video}\" # #{show}"
|
23
|
+
true
|
24
|
+
end
|
14
25
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
26
|
+
# Testa validade video processado contra video original
|
27
|
+
#
|
28
|
+
# @param [String] file video processado a testar validade
|
29
|
+
# @return [true, false] sim ou nao video esta ok
|
30
|
+
def vfok?(file)
|
31
|
+
return false unless File.exist?(file.video) &&
|
32
|
+
file.bitrate < 3000 &&
|
33
|
+
Time.parse(file.duration) > Time.parse(duration) - 60
|
20
34
|
|
21
|
-
puts "rm #{video} # #{file.
|
35
|
+
puts "rm \"#{video}\" # #{file.video} #{file.show}"
|
22
36
|
true
|
23
37
|
end
|
24
38
|
|
25
|
-
# Testa validade
|
39
|
+
# Testa validade videos processados em todos locais contra video original
|
26
40
|
#
|
27
41
|
# @param [Array<String>] ary array locais onde procurar videos
|
28
42
|
# @param [String] out pasta destino dos videos
|
@@ -42,17 +56,8 @@ module Evideo
|
|
42
56
|
''
|
43
57
|
end
|
44
58
|
|
45
|
-
# @return [String] metadata comando conversao
|
46
|
-
def metadata
|
47
|
-
' -metadata title= -metadata artist= -metadata comment=' \
|
48
|
-
' -metadata major_brand= -metadata compatible_brands=' +
|
49
|
-
# para teste produz somente segundos
|
50
|
-
# ' -t 20' \
|
51
|
-
''
|
52
|
-
end
|
53
|
-
|
54
59
|
# @return [String] aspect ratio comando conversao
|
55
|
-
def
|
60
|
+
def aspect
|
56
61
|
if ratio == '0:1' then bitrate < 720 ? '' : ' -aspect 16:9'
|
57
62
|
else " -aspect #{ratio}"
|
58
63
|
end
|
@@ -73,39 +78,37 @@ module Evideo
|
|
73
78
|
|
74
79
|
# @return [String] comando conversao
|
75
80
|
def mpeg
|
76
|
-
"ffmpeg #{geral} -i #{video} -y -an " +
|
81
|
+
"ffmpeg #{geral} -i \"#{video}\" -y -an " +
|
77
82
|
# framerate & bitrate
|
78
83
|
"-r #{[fps, 25].min} -b:v #{[bitrate, 2000].min}k" +
|
79
|
-
dimension +
|
84
|
+
dimension + aspect +
|
85
|
+
' -metadata title= -metadata artist= -metadata comment=' \
|
86
|
+
' -metadata major_brand= -metadata compatible_brands=' +
|
87
|
+
# para teste produz somente segundos
|
88
|
+
# ' -t 20' \
|
89
|
+
''
|
80
90
|
end
|
81
91
|
|
82
|
-
# Processa
|
92
|
+
# Processa videos
|
83
93
|
#
|
84
94
|
# @param [Array<String>] dar locais onde procurar videos
|
85
|
-
# @param [String] din pasta origem dos videos
|
86
95
|
# @param [String] out pasta destino dos videos
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
vdok?(dar, out)
|
96
|
+
# @param [String] din pasta origem dos videos
|
97
|
+
def processa(dar, out, din)
|
98
|
+
return if ofok? || vdok?(dar, out)
|
91
99
|
|
92
100
|
system mpeg + " #{din}/#{out}/#{base}.mp4"
|
93
101
|
vfok?(HRVideo.new("#{din}/#{out}/#{base}.mp4"))
|
94
102
|
end
|
95
103
|
|
96
|
-
#
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
# @return [String] video: tempo: rate: y: framerate: ratio:
|
104
|
-
def testa
|
105
|
-
return video unless @probe
|
104
|
+
# Testa videos
|
105
|
+
#
|
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)
|
106
110
|
|
107
|
-
"#{
|
108
|
-
"y: #{height} framerate: #{fps} ratio: #{ratio}"
|
111
|
+
puts "ls \"#{video}\" # #{show}"
|
109
112
|
end
|
110
113
|
end
|
111
114
|
end
|
data/lib/evideo/version.rb
CHANGED
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
|
+
version: 0.1.4
|
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-
|
11
|
+
date: 2019-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|