evideo 0.2.3 → 0.2.4
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/evideo.gemspec +2 -5
- data/lib/evideo.rb +5 -6
- data/lib/evideo/hrvideo.rb +10 -12
- data/lib/evideo/hrvprocessa.rb +29 -23
- 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: 1e28f124268b83c747ed748296d09491c6955cb1b679952e76d0c78c3926de76
|
4
|
+
data.tar.gz: e92e5ac092e29017ec65a4799de589109f4400723421360a46bbd35af8b6645e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7bb0acee95ef8a2307bdc1b525d82293fca925bc94cd8031dfa860affddeb40b6e52cca607f6315dacc343cf0b89ca79125112fe075d33a1cb7a1a36c1cfeb7b
|
7
|
+
data.tar.gz: a7803cb72e5ff2105c3939deb56960babafba44fce72f26e9001e0191ca27b549110c8e87b1f556e725d10a3461f5792ade603f33646753d34a337c0c16307b0
|
data/Gemfile.lock
CHANGED
data/evideo.gemspec
CHANGED
@@ -13,9 +13,7 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.license = 'MIT'
|
14
14
|
|
15
15
|
spec.summary = 'Processa ficheiros video.'
|
16
|
-
spec.description = spec.summary +
|
17
|
-
' Pode alterar bitrate, framerate, height,' \
|
18
|
-
' aspect ratio e elimina metadata.'
|
16
|
+
spec.description = spec.summary + ' Pode alterar bitrate, framerate, height, aspect ratio e elimina metadata.'
|
19
17
|
|
20
18
|
spec.metadata['homepage_uri'] = spec.homepage
|
21
19
|
spec.metadata['yard.run'] = 'yard'
|
@@ -24,8 +22,7 @@ Gem::Specification.new do |spec|
|
|
24
22
|
# The `git ls-files -z` loads the files in the RubyGem that have been
|
25
23
|
# added into git.
|
26
24
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
27
|
-
`git ls-files -z`.split("\x0")
|
28
|
-
.reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
29
26
|
end
|
30
27
|
spec.bindir = 'exe'
|
31
28
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
data/lib/evideo.rb
CHANGED
@@ -10,14 +10,13 @@ module Evideo
|
|
10
10
|
ID = `whoami`.chomp
|
11
11
|
# CLI para analisar/processar videos
|
12
12
|
class CLI < Thor
|
13
|
-
class_option :d, banner: 'DIR', type: :array,
|
14
|
-
default: ["/home/#{ID}/lust", "/media/#{ID}/hrv2"]
|
15
|
-
desc: 'Onde procurar videos'
|
13
|
+
class_option :d, banner: 'DIR', type: :array, desc: 'Onde procurar videos',
|
14
|
+
default: ["/home/#{ID}/lust", "/media/#{ID}/hrv2"]
|
16
15
|
class_option :i, banner: 'IN', default: 'ftv', desc: 'Pasta origem'
|
17
16
|
class_option :o, banner: 'OUT', default: 'out', desc: 'Pasta destino'
|
17
|
+
|
18
18
|
desc 'conv', 'converte videos'
|
19
19
|
option :t, type: :boolean, default: false, desc: 'Processa somente segundos para teste'
|
20
|
-
# Processa videos
|
21
20
|
def conv
|
22
21
|
Dir.glob("#{fin}/*.???").sort.each do |f|
|
23
22
|
HRVideo.new(f).processa(options, fout)
|
@@ -25,13 +24,13 @@ module Evideo
|
|
25
24
|
end
|
26
25
|
|
27
26
|
desc 'test', 'testa videos'
|
28
|
-
# Analisa videos
|
29
27
|
def test
|
30
28
|
Dir.glob("#{fin}/*.???").sort.each do |f|
|
31
29
|
HRVideo.new(f).testa(options, fout)
|
32
30
|
end
|
33
31
|
end
|
34
|
-
|
32
|
+
|
33
|
+
default_task :test
|
35
34
|
no_commands do
|
36
35
|
# @return [String] pasta absoluta origem dos videos
|
37
36
|
def fin
|
data/lib/evideo/hrvideo.rb
CHANGED
@@ -2,19 +2,17 @@
|
|
2
2
|
|
3
3
|
module Evideo
|
4
4
|
# permite analizar string output do comando sonda video
|
5
|
-
class HRVideo
|
5
|
+
class HRVideo
|
6
6
|
# @return [String] nome do ficheiro video
|
7
|
-
attr_reader :
|
7
|
+
attr_reader :nome
|
8
8
|
# @return [String] extensao do ficheiro video
|
9
9
|
attr_reader :ext
|
10
10
|
# @return [String] base do ficheiro video
|
11
11
|
attr_reader :base
|
12
12
|
# @return [String] duracao do ficheiro video
|
13
|
-
attr_reader :
|
13
|
+
attr_reader :tempo
|
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
|
18
16
|
|
19
17
|
# Duration: 01:01:08.50, start: 0.000000, bitrate: 2228 kb/s
|
20
18
|
R1 = /duration:\s+(\d\d:\d\d:\d\d).*bitrate:\s+(\d+)\s+kb/i.freeze
|
@@ -27,17 +25,17 @@ module Evideo
|
|
27
25
|
# Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 127 kb/s (default)
|
28
26
|
R4 = /stream.*audio:.*\s+(\d+)\s+hz/i.freeze
|
29
27
|
|
30
|
-
def initialize(
|
31
|
-
@
|
32
|
-
@ext = File.extname(
|
33
|
-
@base = File.basename(
|
34
|
-
@
|
28
|
+
def initialize(fil)
|
29
|
+
@nome = fil
|
30
|
+
@ext = File.extname(fil)
|
31
|
+
@base = File.basename(fil, @ext).downcase
|
32
|
+
@tempo = '00:00:00'
|
35
33
|
@bitrate = 0
|
36
|
-
@probe = `#{cmd_probe}` if File.exist?(
|
34
|
+
@probe = `#{cmd_probe}` if File.exist?(fil)
|
37
35
|
return unless @probe
|
38
36
|
|
39
37
|
tr1 = @probe.scan(R1).flatten
|
40
|
-
@
|
38
|
+
@tempo = tr1[0].to_s
|
41
39
|
@bitrate = tr1[1].to_i
|
42
40
|
end
|
43
41
|
|
data/lib/evideo/hrvprocessa.rb
CHANGED
@@ -4,36 +4,41 @@ require 'time'
|
|
4
4
|
|
5
5
|
module Evideo
|
6
6
|
# permite analizar/processar videos para arquivo
|
7
|
-
class HRVideo
|
7
|
+
class HRVideo
|
8
8
|
# @return [String] tempo: rate:
|
9
9
|
def show
|
10
|
-
return
|
10
|
+
return nome unless @probe
|
11
11
|
|
12
|
-
"tempo: #{
|
12
|
+
"tempo: #{tempo} rate: #{bitrate} ratio: #{ratio} height: #{height}"
|
13
13
|
end
|
14
14
|
|
15
15
|
# Testa validade video original
|
16
16
|
#
|
17
17
|
# @param [String] aot pasta destino dos videos absoluta
|
18
|
-
# @return [true, false] sim ou nao video esta ok
|
18
|
+
# @return [true, false] sim ou nao video original esta ok
|
19
19
|
def ofok?(aot)
|
20
|
-
return false unless
|
21
|
-
return false unless ratio == '16:9' && height > 480
|
22
|
-
return false unless audio == 0
|
20
|
+
return false unless processa_of?
|
23
21
|
|
24
|
-
puts "mv \"#{
|
22
|
+
puts "mv \"#{nome} #{aot}/#{base}.mp4\" # #{show}"
|
25
23
|
true
|
26
24
|
end
|
27
25
|
|
26
|
+
# @return [true, false] video original precisa ser processado?
|
27
|
+
def processa_of?
|
28
|
+
# prossecar somente videos grandes (>1 min) ou extensao errada ou bitrate >= 3000
|
29
|
+
((bitrate < 3000 && ext == '.mp4') || Time.parse(tempo) < Time.parse('00:01:00')) &&
|
30
|
+
# prossecar somente videos com ratio, height, audio errados
|
31
|
+
ratio == '16:9' && height > 480 && audio.zero?
|
32
|
+
end
|
33
|
+
|
28
34
|
# Testa validade video processado contra video original
|
29
35
|
#
|
30
|
-
# @param [String]
|
36
|
+
# @param [String] hrv video processado a testar validade
|
31
37
|
# @return [true, false] sim ou nao video esta ok
|
32
|
-
def vfok?(
|
33
|
-
return false unless File.exist?(
|
34
|
-
file.bitrate < 3000 && Time.parse(file.duration) > Time.parse(duration) - 60
|
38
|
+
def vfok?(hrv)
|
39
|
+
return false unless File.exist?(hrv.nome) && hrv.bitrate < 3000 && Time.parse(hrv.tempo) > Time.parse(tempo) - 60
|
35
40
|
|
36
|
-
puts "rm \"#{
|
41
|
+
puts "rm \"#{nome}\" # #{hrv.nome} #{hrv.show}"
|
37
42
|
true
|
38
43
|
end
|
39
44
|
|
@@ -52,7 +57,7 @@ module Evideo
|
|
52
57
|
# @return [String] aspect ratio comando conversao
|
53
58
|
def aspect
|
54
59
|
if ratio == '0:1' then height < 720 ? '' : ' -aspect 16:9'
|
55
|
-
else
|
60
|
+
else " -aspect #{ratio}"
|
56
61
|
end
|
57
62
|
end
|
58
63
|
|
@@ -66,7 +71,7 @@ module Evideo
|
|
66
71
|
|
67
72
|
# @return [String] comando analise
|
68
73
|
def cmd_probe
|
69
|
-
"ffprobe -hide_banner -show_streams \"#{
|
74
|
+
"ffprobe -hide_banner -show_streams \"#{nome}\" 2>&1|grep -v title"
|
70
75
|
end
|
71
76
|
|
72
77
|
# Comando para processar videos
|
@@ -74,17 +79,18 @@ module Evideo
|
|
74
79
|
# @param [String] tempo do video processado
|
75
80
|
# @return [String] comando conversao
|
76
81
|
def cmd_mpeg(tempo)
|
77
|
-
puts "processar #{base}.mp4
|
78
|
-
"ffmpeg #{geral} -i \"#{
|
79
|
-
|
80
|
-
"-r #{[fps, 25].min} -b:v #{[bitrate, 2000].min}k" +
|
81
|
-
dimension + aspect +
|
82
|
-
' -metadata title= -metadata artist= -metadata comment=' \
|
83
|
-
' -metadata major_brand= -metadata compatible_brands=' +
|
82
|
+
puts "processar #{base}.mp4 " + join_opcoes
|
83
|
+
"ffmpeg #{geral} -i \"#{nome}\" -y -an " + join_opcoes +
|
84
|
+
' -metadata title= -metadata artist= -metadata comment= -metadata major_brand= -metadata compatible_brands=' +
|
84
85
|
# para teste produz somente segundos
|
85
86
|
tempo
|
86
87
|
end
|
87
88
|
|
89
|
+
# @return [String] opcoes para trabalho framerate & bitrate & dimenssoes
|
90
|
+
def join_opcoes
|
91
|
+
"-r #{[fps, 25].min} -b:v #{[bitrate, 2000].min}k" + dimension + aspect
|
92
|
+
end
|
93
|
+
|
88
94
|
# @return [String] opcoes gerais comando conversao
|
89
95
|
def geral
|
90
96
|
'-loglevel quiet -hide_banner' +
|
@@ -119,7 +125,7 @@ module Evideo
|
|
119
125
|
def testa(opcoes, aot)
|
120
126
|
return if ofok?(aot) || vdok?(opcoes[:d], opcoes[:o])
|
121
127
|
|
122
|
-
puts "ls \"#{
|
128
|
+
puts "ls -lh \"#{nome}\" # #{show}"
|
123
129
|
end
|
124
130
|
end
|
125
131
|
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.2.
|
4
|
+
version: 0.2.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: 2020-
|
11
|
+
date: 2020-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|