evideo 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d52282fceffa14ff50d2b6d0807b1f04757c19b512ad15779f6d34ab27c5443e
4
- data.tar.gz: 7cdb3ce10ea1c11e7228f2f871e7618c05a6e1a9c7046b5bc4b1d67488103ea5
3
+ metadata.gz: cbacc62b58b0bfda756ed9ab6dd805d7ed2f83f53ad4b9a473380c333a03fa36
4
+ data.tar.gz: cdac5c566f42e62025b9f1eca06c633d676725e7c47bdaf56efd30eb35ec32fa
5
5
  SHA512:
6
- metadata.gz: 353c32cf6373ea45831f8595fef15b264fd304c30f8676dc53437b45c3e25bbf89f6f6fc5c27a9cb24b42369f2737b7d84b259e7212ee46a0b3455364a6a5a48
7
- data.tar.gz: 5f1bdc4f3bb6609360b60b4148fb55e8d9ac84fdec80f7dd59b212d90d72345d8ca7b651ab26f261506498cf1f1ebe0d1f9f314c33695c49658000542ce264e1
6
+ metadata.gz: 1a70f3e4b577446166522283413fedeaa0c4e080628ffe8ec050ce544be7df72ccd30a90a0c33338e5b7b4e5e256dba7db0eb67c86f3d931b42e0142ba61a10d
7
+ data.tar.gz: 76bf6aa4ee171e44d58ef4c9a5401361a7a186b550c03f4a58beda77fc7d8cbc163a0eb7d21312ca95fc157376757e993a562698ad407023e3ca402bd99e250b
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- evideo (0.1.3)
4
+ evideo (0.1.4)
5
5
  thor (~> 0.1)
6
6
 
7
7
  GEM
@@ -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, dar.first, options[:o])
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
- Dir.glob("#{options[:d].first}/#{options[:i]}/*.???").sort.each do |f|
33
- p HRVideo.new(f).testa
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
@@ -31,18 +31,18 @@ module Evideo
31
31
  @probe = `#{probe}` if File.exist?(fvideo)
32
32
  return unless @probe
33
33
 
34
- r1 = @probe.scan(R1).flatten
35
- @duration = r1[0]
36
- @bitrate = r1[1].to_i
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
- r2 = @probe.scan(R2).flatten
44
- @height = r2[0].to_i
45
- @fps = r2[1].to_f
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
@@ -5,24 +5,38 @@ require 'time'
5
5
  module Evideo
6
6
  # permite analizar/processar videos para arquivo
7
7
  class HRVideo < String
8
- # Testa validade video
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 vfok?(file)
13
- return false unless File.exist?(file.video)
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
- # tempo video processado < tempo original -60 segundos ou
16
- # bitrate video processado > bitrate video origunal
17
- return false unless Time.parse(file.duration) >
18
- Time.parse(duration) - 60 &&
19
- file.bitrate < 3000
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.rm_show}"
35
+ puts "rm \"#{video}\" # #{file.video} #{file.show}"
22
36
  true
23
37
  end
24
38
 
25
- # Testa validade <locais>/<video>
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 aspect_ratio
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 + aspect_ratio + metadata
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 video
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
- def processa(dar, din, out)
88
- return if (bitrate < 3000 && ext == '.mp4') ||
89
- Time.parse(duration) < Time.parse('00:01:00') ||
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
- # @return [String] video: tempo: rate:
97
- def rm_show
98
- return video unless @probe
99
-
100
- "#{video} tempo: #{duration} rate: #{bitrate} "
101
- end
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
- "#{base}#{ext} tempo: #{duration} rate: #{bitrate} " \
108
- "y: #{height} framerate: #{fps} ratio: #{ratio}"
111
+ puts "ls \"#{video}\" # #{show}"
109
112
  end
110
113
  end
111
114
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Evideo
4
- VERSION = '0.1.3'
4
+ VERSION = '0.1.4'
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.3
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-02 00:00:00.000000000 Z
11
+ date: 2019-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler