v2av 0.1.0 → 0.1.1
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
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/v2av.rb +30 -52
- metadata +6 -6
- metadata.gz.sig +1 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b2be660527bd3b117a12cdaef65b842a23e467b795facacade9d792f3016a73
|
4
|
+
data.tar.gz: a552c7c44d277998db08af36a12e0499b0dae0b672d44860f94afc6ba92b2b33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2102a4681362a5e5715b1f513b1eb463366e7e62ff1702e16038d74c8ed5c87f32c80406e11e27b508039ff1491a53e8bc0999f051dbfd8eb05d9c44cc538d02
|
7
|
+
data.tar.gz: 47ab02903e7e8b83bbbf95ca244a644d88a87a5a7406bc429f4fbba2398fff01eb1a63c3e2ced7a799f11f9c77dbbca27029ab09bd1187cba023eb4faaa0e2a3
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/v2av.rb
CHANGED
@@ -73,22 +73,38 @@ class V2av
|
|
73
73
|
using ColouredText
|
74
74
|
using TimeHelper
|
75
75
|
include WavTool
|
76
|
+
|
77
|
+
attr_accessor :steps, :duration
|
76
78
|
|
77
79
|
def initialize(src, srt, working_dir: '/tmp/v2av', debug: false,
|
78
80
|
pollyspeech: {access_key: nil, secret_key: nil, voice_id: 'Amy',
|
79
81
|
cache_filepath: '/tmp/v2av/pollyspeech/cache'})
|
80
82
|
|
81
|
-
@working_dir, @debug = working_dir, debug
|
83
|
+
@source, @working_dir, @debug = src, working_dir, debug
|
82
84
|
|
83
85
|
@steps = srt.lines.map do |x|
|
84
|
-
raw_time, desc =
|
86
|
+
raw_time, desc = x.chomp.split(/ +/,2)
|
85
87
|
OpenStruct.new({time: raw_time.to_i, desc: desc})
|
86
88
|
end
|
89
|
+
|
90
|
+
s = `exiftool #{src}`
|
91
|
+
puts 's: ' + s.inspect if @debug
|
92
|
+
#a = s[/Duration.*(\d{1,2}:\d{2}:\d{2})/,1].split(':').map(&:to_i)
|
93
|
+
#@duration = Subunit.new(units={minutes:60, hours:60, seconds: 0}, a).to_i
|
94
|
+
@duration = s[/Duration.*: (\d+)/,1].to_i
|
95
|
+
puts ('@duration: ' + @duration.inspect).debug if @debug
|
96
|
+
|
97
|
+
@steps[0..-2].each.with_index do |x, i|
|
98
|
+
x.duration = @steps[i+1].time - x.time
|
99
|
+
end
|
100
|
+
|
101
|
+
@steps.last.duration = @duration - @steps.last.time
|
87
102
|
|
88
103
|
@pollyspeech = PollySpeech.new(pollyspeech) if pollyspeech[:access_key]
|
104
|
+
|
89
105
|
end
|
90
106
|
|
91
|
-
def build()
|
107
|
+
def build(destination)
|
92
108
|
|
93
109
|
if block_given? then
|
94
110
|
|
@@ -96,19 +112,16 @@ class V2av
|
|
96
112
|
|
97
113
|
else
|
98
114
|
|
99
|
-
dir = File.dirname(source)
|
100
|
-
file = File.basename(source)
|
101
|
-
|
102
|
-
tidy!
|
103
|
-
|
104
|
-
vid2 = File.join(dir, file.sub(/\.mp4$/,'b\0'))
|
105
|
-
trim_video source, vid2
|
115
|
+
dir = File.dirname(@source)
|
116
|
+
file = File.basename(@source)
|
106
117
|
|
107
|
-
|
118
|
+
vid2 = File.join(@working_dir, file.sub(/\.mp4$/,'b\0'))
|
119
|
+
trim_video @source, vid2
|
120
|
+
|
121
|
+
vid3 = File.join(@working_dir, file.sub(/\.mp4$/,'c.avi'))
|
108
122
|
|
109
123
|
generate_audio
|
110
124
|
add_audio_track File.join(@working_dir, 'audio.wav'), vid2, vid3
|
111
|
-
|
112
125
|
|
113
126
|
vid4 = File.join(dir, file.sub(/\.avi$/,'d\0'))
|
114
127
|
resize_video vid3, vid4
|
@@ -132,6 +145,7 @@ class V2av
|
|
132
145
|
yield(audio_file, video_file, target_video)
|
133
146
|
else
|
134
147
|
`ffmpeg -i #{video_file} -i #{audio_file} -codec copy -shortest #{target_video} -y`
|
148
|
+
#"ffmpeg -i #{video_file} -i #{audio_file} -codec copy -shortest #{target_video} -y"
|
135
149
|
end
|
136
150
|
|
137
151
|
end
|
@@ -212,47 +226,12 @@ class V2av
|
|
212
226
|
`ffmpeg -i #{source} -vf scale="720:-1" #{destination} -y`
|
213
227
|
end
|
214
228
|
|
215
|
-
|
216
|
-
|
217
|
-
verbose_level = 0
|
218
|
-
|
219
|
-
@steps.each do |x|
|
220
|
-
|
221
|
-
x.desc.gsub!(/\s*\([^\)]+\)\s*/,'')
|
222
|
-
x.desc.sub!(/ in "\w+"$/,'')
|
223
|
-
x.desc.sub!(/"User account for [^"]+"/,'the User account icon.')
|
224
|
-
|
225
|
-
if x.desc =~ /User left click/ and verbose_level == 0 then
|
226
|
-
|
227
|
-
x.desc.sub!(/User left click/, 'Using the mouse, left click')
|
228
|
-
verbose_level = 1
|
229
|
-
|
230
|
-
elsif x.desc =~ /User left click/ and verbose_level == 1
|
231
|
-
|
232
|
-
x.desc.sub!(/User left click/, 'Left click')
|
233
|
-
verbose_level = 2
|
234
|
-
|
235
|
-
elsif x.desc =~ /User left click/ and verbose_level == 2
|
236
|
-
|
237
|
-
x.desc.sub!(/User left click/, 'Click')
|
238
|
-
verbose_level = 3
|
239
|
-
|
240
|
-
elsif x.desc =~ /User left click/ and verbose_level == 3
|
241
|
-
|
242
|
-
x.desc.sub!(/User left click on/, 'Select')
|
243
|
-
|
244
|
-
else
|
245
|
-
verbose_level = 0
|
246
|
-
end
|
247
|
-
|
248
|
-
end
|
249
|
-
|
250
|
-
end
|
251
|
-
|
229
|
+
|
252
230
|
def to_srt(offset=-(@steps.first.time - 1))
|
253
231
|
|
254
232
|
lines = to_subtitles(offset).strip.lines.map.with_index do |x, i|
|
255
233
|
|
234
|
+
puts ('x: ' + x.inspect).debug if @debug
|
256
235
|
raw_times, subtitle = x.split(/ /,2)
|
257
236
|
puts ('raw_times: ' + raw_times.inspect).debug if @debug
|
258
237
|
start_time, end_time = raw_times.split('-',2)
|
@@ -300,7 +279,8 @@ class V2av
|
|
300
279
|
|
301
280
|
def trim_video(video, newvideo)
|
302
281
|
|
303
|
-
start = @steps.first.time - 4
|
282
|
+
start = @steps.first.time > 4 ? @steps.first.time - 4 : @steps.first.time
|
283
|
+
|
304
284
|
t1, t2 = [start, @steps.last.time - 2 ].map do |step|
|
305
285
|
"%02d:%02d:%02d" % (step.to_hms.reverse + [0,0]).take(3).reverse
|
306
286
|
end
|
@@ -311,5 +291,3 @@ class V2av
|
|
311
291
|
|
312
292
|
end
|
313
293
|
|
314
|
-
v2 = V2av.new('video.mp4', 's.srt', working_dir: '/tmp/v2av')
|
315
|
-
v2.build('video2.mp4')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: v2av
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
iJVbOvYHXer/n2nZUT7Y3p/QDtueJZnnK3YK+ATp5fv8qdUhyMKlbzNLK4n6cZAm
|
36
36
|
DdWGleqfN3lBh5+Kul0GL3kB
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2019-05-
|
38
|
+
date: 2019-05-03 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: subunit
|
@@ -43,20 +43,20 @@ dependencies:
|
|
43
43
|
requirements:
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 0.
|
46
|
+
version: 0.4.0
|
47
47
|
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: '0.
|
49
|
+
version: '0.4'
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
54
|
- - ">="
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: 0.
|
56
|
+
version: 0.4.0
|
57
57
|
- - "~>"
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: '0.
|
59
|
+
version: '0.4'
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: ruby-ogginfo
|
62
62
|
requirement: !ruby/object:Gem::Requirement
|
metadata.gz.sig
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
=V��(3zX��I;W�����$KB��(*\Mf&&�:R�x�KA(���Ղ=��kt�@�j�����u
|
1
|
+
��Lؑ8��b/y�����v0��fn�����>���/�ۺ�U��3ՈQ*P%g��x�F]��G):1y;�Ɨ�pሦ��lL��#�������Z!}&`G�3|� ��z���Rnp�'����/�P�T���;k)?F֪�@i�r\OE6f��}���ę]�&o�q��[j@��F!�[�6H.���H���$����KM%�|Տb�v��aoJ�AJa�{Gud�ΠU&Do�SV��2G�=�R���<�+����jY�+Q�a�+�:��5�TD��Q.d��'��1:v��v�N��L�l��p��$/GV�M�E�I�����7�JMM��,Ķ�I��9��
|