eikon 0.1.8 → 0.1.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e06bcf4e7b27eccddc0670f442aa27dc1c04a10ad551238cfc2df5942a5009fb
4
- data.tar.gz: 297f266c5e14409e1a854d913de74bd589dee54ac9906aebe88975fd9cd98361
3
+ metadata.gz: 3953b63ceee83d454dbd4713f71df4d9a0951a93a4237a17fcba4c6d3acd87fb
4
+ data.tar.gz: 6dc06db31ae3ca79620a027e51444b5a41dfff619415fec10ba6d9eb51504c9e
5
5
  SHA512:
6
- metadata.gz: a4c33c259b94085a63548fc309a26c7ce8a6e3ae5ca5dfbe19ca4b229b145762a3e17945905cef1cb287faf43dba2869625b41df73013645fc713b9a56a99c06
7
- data.tar.gz: 3382ae9ed965b8e6a4dcfcbb1216ff503e2a06f9c40de4e7bf77f7194a13fbf0b2e211a4b5ac973969c5317454b3a0f091485959cd49982a0f6c09dccdda562b
6
+ metadata.gz: e58a8eeecd90dd10dfd8f1f466dc3e15065bca99e94fdba5f8d85fde6495d0efaa3cabe10b6a237c2095df73a5f9a446639dd59fa244660df9987ca9ecca6305
7
+ data.tar.gz: 854cc94f57d7249256db6ae866a46ffffdb97da483429353667ad71a0c5410586c1d22ab7180dfbf52074e037f42f9c3c0cc11e25fef25955e3343c7950cc0fa
data/Gemfile CHANGED
@@ -19,3 +19,4 @@ group :development do
19
19
  end
20
20
 
21
21
  gem "terrapin"
22
+
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- eikon (0.1.5)
4
+ eikon (0.1.10)
5
5
  ruby-vips (~> 2.1)
6
6
  sorbet-runtime (>= 0.5.9204)
7
7
  terrapin (~> 0.6.0)
@@ -107,6 +107,7 @@ GEM
107
107
  rubocop-packaging (~> 0.5)
108
108
  rubocop-performance (~> 1.11)
109
109
  rubocop-rails (~> 2.0)
110
+ ruby-prof (1.6.3)
110
111
  ruby-progressbar (1.11.0)
111
112
  ruby-vips (2.1.4)
112
113
  ffi (~> 1.12)
@@ -166,6 +167,7 @@ DEPENDENCIES
166
167
  rubocop (~> 1.27)
167
168
  rubocop-rails
168
169
  rubocop-rails_config
170
+ ruby-prof (~> 1.6)
169
171
  ruby-vips
170
172
  sorbet-static-and-runtime
171
173
  tapioca
data/lib/eikon/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # typed: true
2
2
 
3
3
  module Eikon
4
- VERSION = "0.1.8".freeze
4
+ VERSION = "0.1.10".freeze
5
5
  end
@@ -15,6 +15,7 @@ module Eikon
15
15
  @file_name = T.let(file_name, String)
16
16
  end
17
17
 
18
+ # Note, this isn't guranteed to give the number of frames since we remove blank images
18
19
  sig { params(number_of_frames: Integer).returns(String) }
19
20
  def split_video_into_images(number_of_frames = 0)
20
21
  file_name = get_file_name(@file_name)
@@ -35,40 +36,40 @@ module Eikon
35
36
 
36
37
  # Turn the time into total seconds (with two points of precision)
37
38
  time_parts = time.split(":")
38
- total_time = Integer(time_parts[0]) * 60 * 60 # Hours
39
- total_time += Integer(time_parts[1]) * 60 # Minutes
40
- total_time += Float(time_parts[2]) # Seconds
39
+ total_time = time_parts[0].to_i * 60 * 60 # Hours
40
+ total_time += time_parts[1].to_i * 60 # Minutes
41
+ total_time += time_parts[2].to_f # Seconds
41
42
 
42
43
  # Figure out the number of frames per minute given the number of frames we want, default to every ten seconds out of sixty
43
44
  if number_of_frames.positive?
45
+ number_of_frames = number_of_frames - 2
46
+ number_of_frames = 0 if number_of_frames.negative?
44
47
 
45
- fps = number_of_frames / total_time
48
+ fps = (number_of_frames - 2) / total_time # We subtract two because we're taking the start and end
46
49
  line = Terrapin::CommandLine.new("ffmpeg", "-i :file_name -vf fps=#{fps} :folder_name")
47
- line.run(file_name: @file_name, folder_name: "#{output_folder_path}/#{file_name}_%d.png")
50
+ line.run(file_name: @file_name, folder_name: "#{output_folder_path}/#{file_name}_%05d.png")
48
51
  else
49
- # Scene detect the video
50
- line = Terrapin::CommandLine.new("ffmpeg", "-i :file_name -filter:v \"select='gt(scene,0.4)',showinfo\" -vsync 0 :output_directory/%05d.png")
51
- line.run(file_name: @file_name, output_directory: output_folder_path)
52
-
53
- # Screenshot the second second and second to last second
54
- # ffmpeg -ss 01:23:45 -i input -frames:v 1 -q:v 2 output.jpg
55
- last_time = "#{time_parts[0]}:#{time_parts[1]}:#{(time_parts[2].to_f - 1).abs.floor}"
56
- ffmpeg_command = "-ss 00:00:02 -i :file_name " +
57
- "-ss :last_time -i :file_name " +
58
- "-map 0:v -vframes 1 :output_directory/:output_file_name_start " +
59
- "-map 1:v -vframes 1 :output_directory/:output_file_name_end"
60
- line = Terrapin::CommandLine.new("ffmpeg", ffmpeg_command)
61
- line.run(
62
- file_name: @file_name,
63
- last_time: last_time,
64
- output_directory: output_folder_path,
65
- output_file_name_start: "#{SecureRandom.uuid}.png",
66
- output_file_name_end: "#{SecureRandom.uuid}.png"
67
- )
68
-
69
- remove_blank_shots(output_folder_path)
52
+ line = Terrapin::CommandLine.new("ffmpeg", "-i :file_name -filter:v \"select='gt(scene,0.4)',showinfo\" -vsync 0 :output_directory/:output_file_name")
53
+ line.run(file_name: @file_name, output_directory: output_folder_path, output_file_name: "#{file_name}_%05d.png")
70
54
  end
71
55
 
56
+ # Screenshot the second second and second to last second
57
+ # ffmpeg -ss 01:23:45 -i input -frames:v 1 -q:v 2 output.jpg
58
+ last_time = "#{time_parts[0]}:#{time_parts[1]}:#{(time_parts[2].to_f - 1).abs.floor}"
59
+ ffmpeg_command = "-ss 00:00:02 -i :file_name " +
60
+ "-ss :last_time -i :file_name " +
61
+ "-map 0:v -vframes 1 :output_directory/:output_file_name_start " +
62
+ "-map 1:v -vframes 1 :output_directory/:output_file_name_end"
63
+ line = Terrapin::CommandLine.new("ffmpeg", ffmpeg_command)
64
+ line.run(
65
+ file_name: @file_name,
66
+ last_time: last_time,
67
+ output_directory: output_folder_path,
68
+ output_file_name_start: "#{file_name}_%05d.png",
69
+ output_file_name_end: "#{file_name}_%05d.png"
70
+ )
71
+ remove_blank_shots(output_folder_path)
72
+
72
73
  output_folder_path
73
74
  end
74
75
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eikon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Guess
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-01 00:00:00.000000000 Z
11
+ date: 2023-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-vips