vcs_ruby 1.1.5 → 1.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/lib/FFmpeg/ffmpeg.rb CHANGED
@@ -82,40 +82,18 @@ private
82
82
  return nil, false, false
83
83
  end
84
84
 
85
- def probe_meta_information
86
- check_cache
87
- parse_meta_info
88
- return true
89
- rescue Exception => e
90
- puts e
91
- return false
92
- end
93
-
94
85
  def check_cache
95
86
  unless @cache
96
87
  @cache = @ffprobe.execute("\"#{@video.full_path}\" -show_format -show_streams", "2>&1")
97
88
  end
98
89
  end
99
90
 
100
- def get_hash defines
101
- result = {}
102
- defines.lines.each do |line|
103
- kv = line.split("=")
104
- result[kv[0].strip] = kv[1].strip if kv.count == 2
105
- end
106
- result
107
- end
108
-
109
- def parse_meta_info
110
- parse_format
111
- parse_audio_streams
112
- parse_video_streams
113
- end
114
-
115
91
  def parse_format
116
92
  @cache.scan(/\[FORMAT\](.*?)\[\/FORMAT\]/m) do |format|
117
93
  @info = FFmpegMetaInfo.new(get_hash(format[0]))
94
+ return true
118
95
  end
96
+ false
119
97
  end
120
98
 
121
99
  def parse_audio_streams
@@ -126,6 +104,7 @@ private
126
104
  @audio_streams << FFmpegAudioStream.new(info)
127
105
  end
128
106
  end
107
+ true
129
108
  end
130
109
 
131
110
  def parse_video_streams
@@ -136,6 +115,7 @@ private
136
115
  @video_streams << FFmpegVideoStream.new(info)
137
116
  end
138
117
  end
118
+ true
139
119
  end
140
120
  end
141
121
  end
@@ -42,7 +42,11 @@ module VCSRuby
42
42
 
43
43
 
44
44
  def frame_rate
45
- Rational(@raw['r_frame_rate'])
45
+ if @raw['r_frame_rate']
46
+ @raw['r_frame_rate'].to_r
47
+ elsif @raw['avg_frame_rate']
48
+ @raw['avg_frame_rate'].to_r
49
+ end
46
50
  end
47
51
 
48
52
  def aspect_ratio
@@ -63,14 +63,6 @@ module VCSRuby
63
63
  def format_split line
64
64
  name = line.strip.split(' ', 2).first
65
65
  end
66
- def probe_meta_information
67
- check_cache
68
- parse_meta_info
69
- return true
70
- rescue Exception => e
71
- puts e
72
- return false
73
- end
74
66
 
75
67
  def check_cache
76
68
  unless @cache
@@ -78,24 +70,24 @@ module VCSRuby
78
70
  end
79
71
  end
80
72
 
81
- def get_hash defines
82
- result = {}
83
- defines.lines.each do |line|
84
- kv = line.split("=")
85
- result[kv[0].strip] = kv[1].strip if kv.count == 2
86
- end
87
- result
73
+ def parse_format
74
+ mplayer_hash = get_hash(@cache)
75
+ @info = MPlayerMetaInfo.new(mplayer_hash, File.size(@video.full_path))
76
+ return true
88
77
  end
89
78
 
90
- def parse_meta_info
79
+ def parse_audio_streams
80
+ @audio_streams = []
91
81
  mplayer_hash = get_hash(@cache)
92
- @info = MPlayerMetaInfo.new(mplayer_hash, File.size(@video.full_path))
82
+ @audio_streams << MPlayerAudioStream.new(mplayer_hash)
83
+ return true
84
+ end
93
85
 
94
- # Todo: Handling of multiple streams
86
+ def parse_video_streams
95
87
  @video_streams = []
88
+ mplayer_hash = get_hash(@cache)
96
89
  @video_streams << MPlayerVideoStream.new(mplayer_hash)
97
- @audio_streams = []
98
- @audio_streams << MPlayerAudioStream.new(mplayer_hash)
90
+ return true
99
91
  end
100
92
 
101
93
  def file_pattern n
@@ -9,7 +9,6 @@ module VCSRuby
9
9
 
10
10
  def initialize audio_stream
11
11
  @raw = audio_stream
12
-
13
12
  end
14
13
 
15
14
  def codec short = false
data/lib/capturer.rb CHANGED
@@ -43,5 +43,27 @@ module VCSRuby
43
43
  raise "Capturer '#{name}' does not support format: '#{format}'"
44
44
  end
45
45
  end
46
+
47
+ private
48
+ def probe_meta_information
49
+ check_cache
50
+ return parse_meta_info
51
+ rescue Exception => e
52
+ puts e
53
+ return false
54
+ end
55
+
56
+ def parse_meta_info
57
+ parse_format && parse_audio_streams && parse_video_streams
58
+ end
59
+
60
+ def get_hash defines
61
+ result = {}
62
+ defines.lines.each do |line|
63
+ kv = line.split("=")
64
+ result[kv[0].strip] = kv[1].strip if kv.count == 2
65
+ end
66
+ result
67
+ end
46
68
  end
47
69
  end
data/lib/contact_sheet.rb CHANGED
@@ -337,7 +337,7 @@ private
337
337
  convert << create_highlight(montage) if @highlight
338
338
  convert << montage.path
339
339
  convert.append
340
- if @signature
340
+ if @signature && @signature.length > 0
341
341
  convert.stack do |a|
342
342
  a.size "#{montage.width}x#{signature_height}"
343
343
  a.gravity 'Center'
data/lib/libAV/libav.rb CHANGED
@@ -84,90 +84,68 @@ private
84
84
  return nil, false, false
85
85
  end
86
86
 
87
- def probe_meta_information
88
- check_cache
89
- return parse_meta_info
90
- rescue Exception => e
91
- puts e
92
- return false
93
- end
94
-
95
87
  def check_cache
96
88
  unless @cache
97
89
  @cache = @avprobe.execute("\"#{@video.full_path}\" -show_format -show_streams", "2>&1")
98
90
  end
99
91
  end
100
92
 
101
- def get_hash defines
102
- result = {}
103
- defines.lines.each do |line|
104
- kv = line.split("=")
105
- result[kv[0].strip] = kv[1].strip if kv.count == 2
93
+ def extract_format regexp
94
+ @cache.scan() do |format|
95
+ @info = LibAVMetaInfo.new(get_hash(format[0]))
96
+ return true
106
97
  end
107
- result
108
- end
109
-
110
- def parse_meta_info
111
- parse_format && parse_audio_streams && parse_video_streams
98
+ false
112
99
  end
113
100
 
114
101
  def parse_format
115
- parsed = false
116
- @cache.scan(/\[FORMAT\](.*?)\[\/FORMAT\]/m) do |format|
117
- @info = LibAVMetaInfo.new(get_hash(format[0]))
118
- parsed = true
119
- end
102
+ parsed = extract_format(/\[FORMAT\](.*?)\[\/FORMAT\]/m)
120
103
  unless parsed
121
- @cache.scan(/\[format\](.*?)\n\n/m) do |format|
122
- @info = LibAVMetaInfo.new(get_hash(format[0]))
123
- parsed = true
124
- end
104
+ parsed = extract_format(/\[format\](.*?)\n\n/m)
125
105
  end
126
106
  return parsed
127
107
  end
128
108
 
129
- def parse_audio_streams
109
+ def extract_audio_streams regexp
130
110
  parsed = false
131
- @audio_streams = []
132
- @cache.scan(/\[STREAM\](.*?)\[\/STREAM\]/m) do |stream|
111
+ @cache.scan(regexp) do |stream|
133
112
  info = get_hash(stream[0])
134
113
  if info['codec_type'] == 'audio'
135
114
  @audio_streams << LibAVAudioStream.new(info)
136
115
  parsed = true
137
116
  end
138
117
  end
118
+ parsed
119
+ end
120
+
121
+ def parse_audio_streams
122
+ @audio_streams = []
123
+ parsed = extract_audio_streams(/\[STREAM\](.*?)\[\/STREAM\]/m)
139
124
  unless parsed
140
- @cache.scan(/\[streams.stream.\d\](.*?)\n\n/m) do |stream|
141
- info = get_hash(stream[0])
142
- if info['codec_type'] == 'audio'
143
- @audio_streams << LibAVAudioStream.new(info)
144
- parsed = true
145
- end
146
- end
125
+ extract_audio_streams(/\[streams.stream.\d\](.*?)\n\n/m)
147
126
  end
148
- return parsed
127
+ true
149
128
  end
150
129
 
151
- def parse_video_streams
130
+ def extract_video_streams regexp
152
131
  parsed = false
153
- @video_streams = []
154
- @cache.scan(/\[STREAM\](.*?)\[\/STREAM\]/m) do |stream|
132
+ @cache.scan(regexp) do |stream|
155
133
  info = get_hash(stream[0])
156
134
  if info['codec_type'] == 'video'
157
135
  @video_streams << LibAVVideoStream.new(info)
158
136
  parsed = true
159
137
  end
160
138
  end
139
+ parsed
140
+ end
141
+
142
+ def parse_video_streams
143
+ @video_streams = []
144
+ parsed = extract_video_streams(/\[STREAM\](.*?)\[\/STREAM\]/m)
161
145
  unless parsed
162
- @cache.scan(/\[streams.stream.\d\](.*?)\n\n/m) do |stream|
163
- info = get_hash(stream[0])
164
- if info['codec_type'] == 'video'
165
- @video_streams << LibAVVideoStream.new(info)
166
- parsed = true
167
- end
168
- end
146
+ parsed = extract_video_streams(/\[streams.stream.\d\](.*?)\n\n/m)
169
147
  end
170
- return parsed
148
+ true
171
149
  end
172
150
  end
173
151
  end
@@ -42,7 +42,11 @@ module VCSRuby
42
42
 
43
43
 
44
44
  def frame_rate
45
- Rational(@raw['r_frame_rate'])
45
+ if @raw['r_frame_rate']
46
+ @raw['r_frame_rate'].to_r
47
+ elsif @raw['avg_frame_rate']
48
+ @raw['avg_frame_rate'].to_r
49
+ end
46
50
  end
47
51
 
48
52
  def aspect_ratio
data/lib/version.info CHANGED
@@ -1 +1 @@
1
- 1.1.5
1
+ 1.1.6
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vcs_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.1.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-10-13 00:00:00.000000000 Z
12
+ date: 2016-10-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mini_magick