easyvideo_utils 0.3.1 → 0.6.1

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: 6cf96bd7cae7c924f5bc6259a374b4f3869f5a99aa936f9bc965ade2678b3301
4
- data.tar.gz: 2794a519340d3142e0958dd35b46d9f62776978ea1ecd3835370afab929f260d
3
+ metadata.gz: e19d1563478361d3113bb48dbea9b6cdbaffbf902304c78a83019ff064988401
4
+ data.tar.gz: f8a7ec1b9c9795a160e1b1a92ea75a9084e4ecf1c0724a70b0b3c6786f7e8b0b
5
5
  SHA512:
6
- metadata.gz: e705fe92de0df9800359f0a39b0bec628c9b423a4e8ab0371a4d6bb65d45d01be14b0c1e719243a0d8df693e871db5209028a5009d70caf510dd668cb8a78de8
7
- data.tar.gz: 2bea5237a862fb1de00261d4c43a91dd7a1215e558f63eab8b2045d587c2c27f6e054a6d5ed4039bf0c6cb0357b723ceb1903dd88551d6bbadac5b0c5d365188
6
+ metadata.gz: '08ae49f875143e7fe3de8fc222fdca8cfffc9b7b3c060982f1e997935769ff364be040eaca5ef5d3a463091a8cc098af9e8690fee4a337d3891633819aa79b71'
7
+ data.tar.gz: 7d9de2554ecfe8cf8ca045d397055e9e6c04c3170fd107680c691bdc6079ac95265c23ca1f62f8339088a299c7353e9dcf40d26f3df4661f6180282d39e70af4
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -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`exiftool
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 720p
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 avi to 720p
218
+ # Resize e.g. to 320x240
193
219
  #
194
- def resize(scale='720', show: false)
195
- command = "ffmpeg -i #{@file_in} -vf scale=\"#{scale}:-1\" #{@file_out} -y"
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 are expressed in human time format e.g. '1m 4s', '2m 30'
284
+ # times can be expressed in human time format e.g. '1m 4s', '2m 30'
244
285
  #
245
- def trim(start_time, end_time, show: false)
286
+ def trim(start_time, duration, show: false)
246
287
 
247
- t1, t2 = [start_time, end_time].map do |s|
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 = "ffmpeg -i #{@file_in} -ss #{t1} -t #{t2} -async 1 " +
255
- "#{@file_out} -y"
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.3.1
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
- YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTkwNTA1MTUxODQwWhcN
15
- MjAwNTA0MTUxODQwWjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
- cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBg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du/2KtNihBpPEOeMmN
35
- iOODRzCT1NjcNTH5nzIOVNDgsjVdBcyabDtEoJ+ABRBRC3QbmGexUCnpCQVsGRJh
36
- aGOV1YBw3DOVQYevaOX+Vxuw
28
+ BgkqhkiG9w0BAQsFAAOCAYEAftlxc0/ZJhPOCyFJkLx0lUJb1opnF9sEftGRtNKo
29
+ 64wBxMFX//BKE+s60sn0PaY+60iEW3rTk8EtR5l4kDc7OXGW4uXwMZ+Kj1Xs9FEd
30
+ isJc63YBE8/hx4ptf2UVqqR6iTCvHwBXeOWl9H5RAGXd3KjI7blxLv0OBT+TApWW
31
+ 6Zpnp0xtoGQrhuQocd62MDjQxem/RWD+fxEZ0OmhJbIl7Lz6QYarpGLhl/2+AYLp
32
+ WJpZL/0aiozOjcFergjWdah2/xN8in8AKPzsAINXePhmDMEugzzQe7kn+M0LJ1uC
33
+ pnVm3ftRoL2etQEPVy+THspaa3JwoKmWFyJ7LOQ5TrInPnlS6na4qZEX7EZsxJ5q
34
+ B9Xqv2fCQVRHMIHjbJ8Ldu+22yPSsWzOPn2gMN5NJPOiUx38KXednagmtEb+VX0t
35
+ z3BcuiLNXpgNVf4IGK7eFvn3lmuLv4R3rZvuHQeWE12PaDq/WP2kcVMaJ7/2ujxI
36
+ JAnTxrqZVNfrRpKAGKs0QV7g
37
37
  -----END CERTIFICATE-----
38
- date: 2019-05-07 00:00:00.000000000 Z
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.4.0
66
+ version: 0.5.0
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: '0.4'
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.4.0
76
+ version: 0.5.0
77
77
  - - "~>"
78
78
  - !ruby/object:Gem::Version
79
- version: '0.4'
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.1
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