evideo 0.1.6 → 0.2.3
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 +7 -7
- data/evideo.gemspec +3 -3
- data/lib/evideo.rb +4 -7
- data/lib/evideo/hrvideo.rb +20 -1
- data/lib/evideo/hrvprocessa.rb +30 -28
- data/lib/evideo/version.rb +1 -1
- metadata +15 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0fe87ef3039e980666caeead4fd819fca47f1afd538e604b10b880b7935b6a8d
|
4
|
+
data.tar.gz: 66ca91c021e17d30222c027d0c7a7ae48965b6910cc21cc80bbde4f6de6275cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47548decc1ff1af5ac40ec347e495def27ac353bd93a2ca05297d26e53aeb6f96fb24178a837f25ad683c2cd2a9eff03c3e21e1040e265a9706b0afcf5185eb2
|
7
|
+
data.tar.gz: 9cc43cd70a17dddf46fcaa56c5cff8ec7d40d41d7ac460a95ac5b7874c5cfb01e2d28994fbb81057c988dfbcc57e9d5bfdee79f0ca176ab9ed1ad56f5cf60c14
|
data/Gemfile.lock
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
evideo (0.
|
5
|
-
thor
|
4
|
+
evideo (0.2.3)
|
5
|
+
thor
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
rake (
|
11
|
-
thor (0.
|
10
|
+
rake (13.0.1)
|
11
|
+
thor (1.0.1)
|
12
12
|
|
13
13
|
PLATFORMS
|
14
14
|
ruby
|
15
15
|
|
16
16
|
DEPENDENCIES
|
17
|
-
bundler
|
17
|
+
bundler
|
18
18
|
evideo!
|
19
|
-
rake
|
19
|
+
rake
|
20
20
|
|
21
21
|
BUNDLED WITH
|
22
|
-
1.
|
22
|
+
2.1.2
|
data/evideo.gemspec
CHANGED
@@ -31,8 +31,8 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
32
32
|
spec.require_paths = ['lib']
|
33
33
|
|
34
|
-
spec.add_development_dependency 'bundler'
|
35
|
-
spec.add_development_dependency 'rake'
|
34
|
+
spec.add_development_dependency 'bundler'
|
35
|
+
spec.add_development_dependency 'rake'
|
36
36
|
|
37
|
-
spec.add_dependency 'thor'
|
37
|
+
spec.add_dependency 'thor'
|
38
38
|
end
|
data/lib/evideo.rb
CHANGED
@@ -13,13 +13,10 @@ module Evideo
|
|
13
13
|
class_option :d, banner: 'DIR', type: :array,
|
14
14
|
default: ["/home/#{ID}/lust", "/media/#{ID}/hrv2"],
|
15
15
|
desc: 'Onde procurar videos'
|
16
|
-
class_option :i, banner: 'IN',
|
17
|
-
|
16
|
+
class_option :i, banner: 'IN', default: 'ftv', desc: 'Pasta origem'
|
17
|
+
class_option :o, banner: 'OUT', default: 'out', desc: 'Pasta destino'
|
18
18
|
desc 'conv', 'converte videos'
|
19
|
-
option :
|
20
|
-
desc: 'Pasta destino'
|
21
|
-
option :t, type: :boolean, default: false,
|
22
|
-
desc: 'Processa somente segundos para teste'
|
19
|
+
option :t, type: :boolean, default: false, desc: 'Processa somente segundos para teste'
|
23
20
|
# Processa videos
|
24
21
|
def conv
|
25
22
|
Dir.glob("#{fin}/*.???").sort.each do |f|
|
@@ -31,7 +28,7 @@ module Evideo
|
|
31
28
|
# Analisa videos
|
32
29
|
def test
|
33
30
|
Dir.glob("#{fin}/*.???").sort.each do |f|
|
34
|
-
HRVideo.new(f).testa(options)
|
31
|
+
HRVideo.new(f).testa(options, fout)
|
35
32
|
end
|
36
33
|
end
|
37
34
|
default_task :conv
|
data/lib/evideo/hrvideo.rb
CHANGED
@@ -13,6 +13,8 @@ module Evideo
|
|
13
13
|
attr_reader :duration
|
14
14
|
# @return [String] bitrate do ficheiro video
|
15
15
|
attr_reader :bitrate
|
16
|
+
# @return [String] frequencia audio do ficheiro video
|
17
|
+
attr_reader :audio
|
16
18
|
|
17
19
|
# Duration: 01:01:08.50, start: 0.000000, bitrate: 2228 kb/s
|
18
20
|
R1 = /duration:\s+(\d\d:\d\d:\d\d).*bitrate:\s+(\d+)\s+kb/i.freeze
|
@@ -21,6 +23,9 @@ module Evideo
|
|
21
23
|
R2 = /stream.*video:.*x\s*(\d+).*\s+(\d+\.*\d*)\s+fps/i.freeze
|
22
24
|
# display_aspect_ratio=16:9
|
23
25
|
R3 = /display_aspect_ratio\s*=\s*(\d+:\d+)$/i.freeze
|
26
|
+
# Stream #0:1(eng): Audio: aac (LC), 48000 Hz, stereo, fltp (default)
|
27
|
+
# Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 127 kb/s (default)
|
28
|
+
R4 = /stream.*audio:.*\s+(\d+)\s+hz/i.freeze
|
24
29
|
|
25
30
|
def initialize(fvideo)
|
26
31
|
@video = fvideo
|
@@ -28,7 +33,7 @@ module Evideo
|
|
28
33
|
@base = File.basename(fvideo, @ext).downcase
|
29
34
|
@duration = '00:00:00'
|
30
35
|
@bitrate = 0
|
31
|
-
@probe = `#{
|
36
|
+
@probe = `#{cmd_probe}` if File.exist?(fvideo)
|
32
37
|
return unless @probe
|
33
38
|
|
34
39
|
tr1 = @probe.scan(R1).flatten
|
@@ -52,6 +57,20 @@ module Evideo
|
|
52
57
|
@ratio = @probe.scan(R3).flatten[0]
|
53
58
|
end
|
54
59
|
|
60
|
+
# Parametrizar audio
|
61
|
+
def r4
|
62
|
+
return unless @probe
|
63
|
+
|
64
|
+
@audio = @probe.scan(R4).flatten[0].to_i
|
65
|
+
end
|
66
|
+
|
67
|
+
# @return [String] audio
|
68
|
+
def audio
|
69
|
+
r4 unless @audio
|
70
|
+
|
71
|
+
@audio
|
72
|
+
end
|
73
|
+
|
55
74
|
# @return [String] height
|
56
75
|
def height
|
57
76
|
r2 unless @height
|
data/lib/evideo/hrvprocessa.rb
CHANGED
@@ -14,13 +14,14 @@ module Evideo
|
|
14
14
|
|
15
15
|
# Testa validade video original
|
16
16
|
#
|
17
|
+
# @param [String] aot pasta destino dos videos absoluta
|
17
18
|
# @return [true, false] sim ou nao video esta ok
|
18
|
-
def ofok?
|
19
|
-
return false unless (bitrate < 3000 && ext == '.mp4') ||
|
20
|
-
Time.parse(duration) < Time.parse('00:01:00')
|
19
|
+
def ofok?(aot)
|
20
|
+
return false unless (bitrate < 3000 && ext == '.mp4') || Time.parse(duration) < Time.parse('00:01:00')
|
21
21
|
return false unless ratio == '16:9' && height > 480
|
22
|
+
return false unless audio == 0
|
22
23
|
|
23
|
-
puts "
|
24
|
+
puts "mv \"#{video} #{aot}/#{base}.mp4\" # #{show}"
|
24
25
|
true
|
25
26
|
end
|
26
27
|
|
@@ -30,8 +31,7 @@ module Evideo
|
|
30
31
|
# @return [true, false] sim ou nao video esta ok
|
31
32
|
def vfok?(file)
|
32
33
|
return false unless File.exist?(file.video) &&
|
33
|
-
file.bitrate < 3000
|
34
|
-
Time.parse(file.duration) > Time.parse(duration) - 60
|
34
|
+
file.bitrate < 3000 && Time.parse(file.duration) > Time.parse(duration) - 60
|
35
35
|
|
36
36
|
puts "rm \"#{video}\" # #{file.video} #{file.show}"
|
37
37
|
true
|
@@ -40,23 +40,15 @@ module Evideo
|
|
40
40
|
# Testa validade videos processados em todos locais contra video original
|
41
41
|
#
|
42
42
|
# @param [Array<String>] ary array locais onde procurar videos
|
43
|
-
# @param [String]
|
43
|
+
# @param [String] pot pasta destino dos videos
|
44
44
|
# @return [true, false] sim ou nao <local>/<video> esta ok
|
45
|
-
def vdok?(ary,
|
45
|
+
def vdok?(ary, pot)
|
46
46
|
if ary.empty? then false
|
47
|
-
elsif vfok?(HRVideo.new("#{ary.first}/#{
|
48
|
-
else vdok?(ary.drop(1),
|
47
|
+
elsif vfok?(HRVideo.new("#{ary.first}/#{pot}/#{base}.mp4")) then true
|
48
|
+
else vdok?(ary.drop(1), pot)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
# @return [String] opcoes gerais comando conversao
|
53
|
-
def geral
|
54
|
-
'-loglevel quiet -hide_banner' +
|
55
|
-
# para ignorar segundos no inicio
|
56
|
-
# ' -ss 15' \
|
57
|
-
''
|
58
|
-
end
|
59
|
-
|
60
52
|
# @return [String] aspect ratio comando conversao
|
61
53
|
def aspect
|
62
54
|
if ratio == '0:1' then height < 720 ? '' : ' -aspect 16:9'
|
@@ -73,15 +65,16 @@ module Evideo
|
|
73
65
|
end
|
74
66
|
|
75
67
|
# @return [String] comando analise
|
76
|
-
def
|
68
|
+
def cmd_probe
|
77
69
|
"ffprobe -hide_banner -show_streams \"#{video}\" 2>&1|grep -v title"
|
78
70
|
end
|
79
71
|
|
80
72
|
# Comando para processar videos
|
81
73
|
#
|
82
|
-
# @param [String] tempo do video
|
74
|
+
# @param [String] tempo do video processado
|
83
75
|
# @return [String] comando conversao
|
84
|
-
def
|
76
|
+
def cmd_mpeg(tempo)
|
77
|
+
puts "processar #{base}.mp4 -r #{[fps, 25].min} -b:v #{[bitrate, 2000].min}k" + dimension + aspect + tempo
|
85
78
|
"ffmpeg #{geral} -i \"#{video}\" -y -an " +
|
86
79
|
# framerate & bitrate
|
87
80
|
"-r #{[fps, 25].min} -b:v #{[bitrate, 2000].min}k" +
|
@@ -92,6 +85,14 @@ module Evideo
|
|
92
85
|
tempo
|
93
86
|
end
|
94
87
|
|
88
|
+
# @return [String] opcoes gerais comando conversao
|
89
|
+
def geral
|
90
|
+
'-loglevel quiet -hide_banner' +
|
91
|
+
# para ignorar segundos no inicio
|
92
|
+
# ' -ss 15' \
|
93
|
+
''
|
94
|
+
end
|
95
|
+
|
95
96
|
# Processa videos
|
96
97
|
#
|
97
98
|
# @param [Hash] opcoes parametrizacao
|
@@ -99,12 +100,12 @@ module Evideo
|
|
99
100
|
# @option opcoes [<String>] :i pasta origem dos videos
|
100
101
|
# @option opcoes [<String>] :o pasta destino dos videos
|
101
102
|
# @option opcoes [<Boolean>] :t processa somente segundos para teste
|
102
|
-
# @param [String]
|
103
|
-
def processa(opcoes,
|
104
|
-
return if ofok? || vdok?(opcoes[:d], opcoes[:o])
|
103
|
+
# @param [String] aot pasta destino dos videos absoluta
|
104
|
+
def processa(opcoes, aot)
|
105
|
+
return if ofok?(aot) || vdok?(opcoes[:d], opcoes[:o])
|
105
106
|
|
106
|
-
system
|
107
|
-
vfok?(HRVideo.new("#{
|
107
|
+
system cmd_mpeg(opcoes[:t] ? ' -t 20' : '') + " #{aot}/#{base}.mp4"
|
108
|
+
vfok?(HRVideo.new("#{aot}/#{base}.mp4"))
|
108
109
|
end
|
109
110
|
|
110
111
|
# Testa videos
|
@@ -114,8 +115,9 @@ module Evideo
|
|
114
115
|
# @option opcoes [<String>] :i pasta origem dos videos
|
115
116
|
# @option opcoes [<String>] :o pasta destino dos videos
|
116
117
|
# @option opcoes [<Boolean>] :t processa somente segundos para teste
|
117
|
-
|
118
|
-
|
118
|
+
# @param [String] aot pasta destino dos videos absoluta
|
119
|
+
def testa(opcoes, aot)
|
120
|
+
return if ofok?(aot) || vdok?(opcoes[:d], opcoes[:o])
|
119
121
|
|
120
122
|
puts "ls \"#{video}\" # #{show}"
|
121
123
|
end
|
data/lib/evideo/version.rb
CHANGED
metadata
CHANGED
@@ -1,57 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evideo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.3
|
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: 2020-
|
11
|
+
date: 2020-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: thor
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0
|
47
|
+
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0
|
54
|
+
version: '0'
|
55
55
|
description: Processa ficheiros video. Pode alterar bitrate, framerate, height, aspect
|
56
56
|
ratio e elimina metadata.
|
57
57
|
email:
|
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
98
|
- !ruby/object:Gem::Version
|
99
99
|
version: '0'
|
100
100
|
requirements: []
|
101
|
-
rubygems_version: 3.
|
101
|
+
rubygems_version: 3.1.2
|
102
102
|
signing_key:
|
103
103
|
specification_version: 4
|
104
104
|
summary: Processa ficheiros video.
|