easyvideo_utils 0.3.1 → 0.6.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/easyvideo_utils.rb +76 -18
- metadata +49 -29
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e19d1563478361d3113bb48dbea9b6cdbaffbf902304c78a83019ff064988401
|
4
|
+
data.tar.gz: f8a7ec1b9c9795a160e1b1a92ea75a9084e4ecf1c0724a70b0b3c6786f7e8b0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08ae49f875143e7fe3de8fc222fdca8cfffc9b7b3c060982f1e997935769ff364be040eaca5ef5d3a463091a8cc098af9e8690fee4a337d3891633819aa79b71'
|
7
|
+
data.tar.gz: 7d9de2554ecfe8cf8ca045d397055e9e6c04c3170fd107680c691bdc6079ac95265c23ca1f62f8339088a299c7353e9dcf40d26f3df4661f6180282d39e70af4
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/easyvideo_utils.rb
CHANGED
@@ -4,11 +4,23 @@
|
|
4
4
|
|
5
5
|
require 'c32'
|
6
6
|
require 'subunit'
|
7
|
-
|
7
|
+
require 'easyimg_utils'
|
8
8
|
|
9
9
|
# requirements:
|
10
|
-
# `apt-get install mplayer ffmpeg vorbis-tools`
|
10
|
+
# `apt-get install mplayer ffmpeg vorbis-tools exiftool libav-tools`
|
11
|
+
|
12
|
+
# note: Although this gem tries to be full-proof it's dependent upon the
|
13
|
+
# command-line tools to do the heavy lifting, as a result is prone
|
14
|
+
# to nuisance factors.
|
15
|
+
# tip: instead of using transcode, try specifing the target encoding based on
|
16
|
+
# the extension type when using multiple
|
17
|
+
# operations e.g. EasyVideoUtils.new('vid2.avi', 'vid3.mp4').resize
|
11
18
|
|
19
|
+
# installing youtube-dl:
|
20
|
+
#
|
21
|
+
# `sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/bin/youtube-dl`
|
22
|
+
#
|
23
|
+
# `sudo chmod a+rx /usr/bin/youtube-dl`
|
12
24
|
|
13
25
|
module CommandHelper
|
14
26
|
using ColouredText
|
@@ -42,17 +54,21 @@ class EasyVideoUtils
|
|
42
54
|
* create_poster # Video created from audio file + static image
|
43
55
|
* create_slideshow # Combines images to create a video. Defaults to 5 seconds per image
|
44
56
|
* extract_images # Extracts images at 1 FPS by default
|
57
|
+
* info
|
58
|
+
* grab_image # grabs a single image at 1 second in by default
|
45
59
|
* play # plays the video using mplayer
|
46
60
|
* preview # plays the video using ffplay
|
47
61
|
* record # alias for capture
|
48
62
|
* remove_audio # removes the audio track from a video
|
49
63
|
* remove_video # removes the video track from a video. Output file would be an mp3.
|
50
|
-
* resize # resize to
|
64
|
+
* resize # resize to 320x240
|
51
65
|
* scale # alias for resize
|
66
|
+
* screencast # lightweight screenshot recorder -> animated gif -> mp4. see also capture
|
52
67
|
* slowdown # slows a viedo down. Defaults to x2 (half-speed)
|
53
68
|
* speedup # speed a video up. Defaults to x2 (twice as fast)
|
54
|
-
* transcode # converts 1 video format to another e.g. avi-> mp4
|
69
|
+
* transcode # converts 1 video format to another e.g. avi-> mp4 or gif -> mp4
|
55
70
|
* trim # trims the beginning and ending of a video in hms format e.g. 1m 3s
|
71
|
+
* youtube_dl # downloads in mp4 format
|
56
72
|
".strip.lines.map {|x| x[/(?<=\* ).*/]}.sort
|
57
73
|
|
58
74
|
|
@@ -165,6 +181,16 @@ class EasyVideoUtils
|
|
165
181
|
command = "ffmpeg -i #{@file_in} -r #{rate} -f image2 image-%2d#{ext}"
|
166
182
|
run command, show
|
167
183
|
end
|
184
|
+
|
185
|
+
def info(show: false)
|
186
|
+
command = "avprobe #{@file_in}"
|
187
|
+
run command, show
|
188
|
+
end
|
189
|
+
|
190
|
+
def grab_image(start_time=1, show: false)
|
191
|
+
command = "avconv -i #{@file_in} -ss #{start_time.to_s} -frames:v 1 #{@file_out} -y"
|
192
|
+
run command, show
|
193
|
+
end
|
168
194
|
|
169
195
|
def play(show: false)
|
170
196
|
command = "mplayer #{@file_out}"
|
@@ -189,14 +215,27 @@ class EasyVideoUtils
|
|
189
215
|
run command, show
|
190
216
|
end
|
191
217
|
|
192
|
-
# Resize
|
218
|
+
# Resize e.g. to 320x240
|
193
219
|
#
|
194
|
-
def resize(scale='
|
195
|
-
command = "
|
220
|
+
def resize(scale='320x240', show: false)
|
221
|
+
command = "avconv -i #{@file_in} -s #{scale} #{@file_out} -y"
|
196
222
|
run command, show
|
197
223
|
end
|
224
|
+
|
198
225
|
|
199
226
|
alias scale resize
|
227
|
+
|
228
|
+
# starts recoring after 2 seconds for a duration of 6 seconds
|
229
|
+
#
|
230
|
+
def screencast(duration: 6, scale: 0.75, window: true)
|
231
|
+
|
232
|
+
gif_file = @file_out.sub(/\w+$/,'gif')
|
233
|
+
|
234
|
+
EasyImgUtils.new(out: gif_file)\
|
235
|
+
.screencast(duration: duration, scale: scale, window: window)
|
236
|
+
EasyVideoUtils.new(gif_file, @file_out).transcode
|
237
|
+
|
238
|
+
end
|
200
239
|
|
201
240
|
# slow down a video
|
202
241
|
#
|
@@ -226,12 +265,14 @@ class EasyVideoUtils
|
|
226
265
|
"#{@file_out} -y"
|
227
266
|
run command, show
|
228
267
|
|
229
|
-
end
|
268
|
+
end
|
230
269
|
|
231
270
|
# Transcodes avi -> mp4
|
232
271
|
#
|
233
272
|
def transcode(show: false)
|
234
273
|
|
274
|
+
return gif_to_mp4() if File.extname(@file_in) == '.gif'
|
275
|
+
|
235
276
|
command = "ffmpeg -i #{@file_in} #{@file_out} -y"
|
236
277
|
run command, show
|
237
278
|
|
@@ -240,25 +281,42 @@ class EasyVideoUtils
|
|
240
281
|
alias convert transcode
|
241
282
|
|
242
283
|
# Trim the start and end of the video
|
243
|
-
# times
|
284
|
+
# times can be expressed in human time format e.g. '1m 4s', '2m 30'
|
244
285
|
#
|
245
|
-
def trim(start_time,
|
286
|
+
def trim(start_time, duration, show: false)
|
246
287
|
|
247
|
-
t1
|
248
|
-
|
249
|
-
"%02d:%02d:%02d" % (s.sub(/m/,'\00s').split(/\D/).reverse + [0,0])\
|
250
|
-
.take(3).reverse
|
251
|
-
|
252
|
-
end
|
288
|
+
t1 = "%02d:%02d:%02d" % (start_time.to_s.sub(/m/,'\00s').split(/\D/)\
|
289
|
+
.reverse + [0,0]).take(3).reverse
|
253
290
|
|
254
|
-
command = "
|
255
|
-
|
291
|
+
command = "avconv -i #{@file_in} -ss #{t1} -t #{duration.to_s} " +
|
292
|
+
"-codec copy #{@file_out}"
|
256
293
|
run command, show
|
257
294
|
|
258
295
|
end
|
296
|
+
|
297
|
+
# Download a video from YouTube
|
298
|
+
#
|
299
|
+
def youtube_dl(show: false)
|
300
|
+
|
301
|
+
command = "youtube-dl -f 'bestvideo[ext=mp4]+" +
|
302
|
+
"bestaudio[ext=m4a]/best[ext=mp4]/best' #{@file_in}"
|
303
|
+
command += ' -o ' + @file_out if @file_out
|
304
|
+
run command, show
|
305
|
+
|
306
|
+
end
|
259
307
|
|
260
308
|
private
|
261
309
|
|
310
|
+
# see https://unix.stackexchange.com/questions/40638/how-to-do-i-convert-an-animated-gif-to-an-mp4-or-mv4-on-the-command-line
|
311
|
+
#
|
312
|
+
def gif_to_mp4(show: false)
|
313
|
+
|
314
|
+
command = "ffmpeg -i %s -movflags faststart -pix_fmt yuv420p \
|
315
|
+
-vf \"scale=trunc(iw/2)*2:trunc(ih/2)*2\" %s" % [@file_in, @file_out]
|
316
|
+
run command, show
|
317
|
+
|
318
|
+
end
|
319
|
+
|
262
320
|
def run(command, show=false)
|
263
321
|
|
264
322
|
if show then
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easyvideo_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -11,31 +11,31 @@ cert_chain:
|
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
13
|
MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjAwNTEzMTIzMDM2WhcN
|
15
|
+
MjEwNTEzMTIzMDM2WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
16
|
+
cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDDyHA0
|
17
|
+
X8ojHR8TfyeKPCmAK1LapqO5mTWZMh5HB8dne+jRFGDRDDkCQ7EISNLRJp8+fZOA
|
18
|
+
kcEjuc/SyQP5Rn6gzMKGpAvhKlZYt4Mj87aA6GbeAbhLRLY7ulj8q8zty6IzXsNV
|
19
|
+
ZVeR3C+1VZTwCV+0aXh075RG8Y1aLlLCER+PyNZgu+L2LdMCGaSA5qOEeufKok5Q
|
20
|
+
7/XDi/3PoZtsMiy9ZVkAPMJWzxA2rKG744VdMYr61VbXw/KS07Q2GTNvcgWPY6bT
|
21
|
+
Owq3gJsN8YMtwURWACaD/iW5nqfAylWTkJoAxlYlP+AuE39OyK3lu/V2aN9Hh+8r
|
22
|
+
Em6Hy3LH8kspFXFaCgETjE8jED5f2lg+8Ln5aNxQt95EoI+pjhcD2dOP+yqjw7Lb
|
23
|
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37
37
|
-----END CERTIFICATE-----
|
38
|
-
date:
|
38
|
+
date: 2020-07-13 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: c32
|
@@ -63,20 +63,40 @@ dependencies:
|
|
63
63
|
requirements:
|
64
64
|
- - ">="
|
65
65
|
- !ruby/object:Gem::Version
|
66
|
-
version: 0.
|
66
|
+
version: 0.5.0
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '0.
|
69
|
+
version: '0.5'
|
70
70
|
type: :runtime
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
74
|
- - ">="
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: 0.
|
76
|
+
version: 0.5.0
|
77
77
|
- - "~>"
|
78
78
|
- !ruby/object:Gem::Version
|
79
|
-
version: '0.
|
79
|
+
version: '0.5'
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: easyimg_utils
|
82
|
+
requirement: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - "~>"
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0.6'
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.6.1
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.6'
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: 0.6.1
|
80
100
|
description:
|
81
101
|
email: james@jamesrobertson.eu
|
82
102
|
executables: []
|
@@ -103,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
123
|
- !ruby/object:Gem::Version
|
104
124
|
version: '0'
|
105
125
|
requirements: []
|
106
|
-
rubygems_version: 3.0.
|
126
|
+
rubygems_version: 3.0.3
|
107
127
|
signing_key:
|
108
128
|
specification_version: 4
|
109
129
|
summary: A wrapper for ffmpeg to make basic video editing easier.
|
metadata.gz.sig
CHANGED
Binary file
|