eikon 0.1.9 → 0.1.11

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: 86196d2fa09e2981f82ab26fed3d7fa7fdfc444584575f0ebd90dd62fed21d73
4
- data.tar.gz: 4548eae26d0cb328cbd5d468aaa534ad13fd995c02d8bd359b80e0db6cd21614
3
+ metadata.gz: 2f7954d7b98c1d1589778c648f2ccdb1f3bd3a7bfb2b5b96a78b67309c22c13b
4
+ data.tar.gz: 70691d16384c391b125fcb7be1ebc0ffef570efcd428e56a3f1e401ad6aedf96
5
5
  SHA512:
6
- metadata.gz: d6d182537ed158831d9be37296ac8ddaf3337bf13c855ed8ad05c74eb8ba3cb92f08e82caaa31f1381c573f0e52f8f1fce769b5b29c7382aeb995ca0d9e9bc6d
7
- data.tar.gz: c9bdaf70abeaa9d64c13661d7a0637ca5a7dd2f028fe96817832120f7d020cb85f21e2cde52bdc8209e1fe0f659e2c07416edee3e99aabaf70f34d82ea13b680
6
+ metadata.gz: d9471e14568ca78e34930f6ec33c1464caf66766d0231558737d9645624ad6cf07b1e358b80bf6f4634507477afaed0bb10d218e505b2cd4d791a8019762c085
7
+ data.tar.gz: 88bbdec7d3e3dd8f937360b609b11451dd69ab2f0f2050623112877e2b0ab8aea6d66b3cf1778065a2a5569f883f959c98ad9c7cb65d2b4ca195b56e024bb544
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)
data/lib/eikon/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # typed: true
2
2
 
3
3
  module Eikon
4
- VERSION = "0.1.9".freeze
4
+ VERSION = "0.1.11".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)
@@ -40,35 +41,36 @@ module Eikon
40
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
- if number_of_frames.positive?
44
+ if number_of_frames > 2
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
+ # NOTE: This has to be a fraction, not a whole number, but also, never 0
49
+ fps = (number_of_frames - 2) / total_time # We subtract two because we're taking the start and end
46
50
  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")
51
+ line.run(file_name: @file_name, folder_name: "#{output_folder_path}/#{file_name}_%05d.png")
48
52
  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)
53
+ line = Terrapin::CommandLine.new("ffmpeg", "-i :file_name -filter:v \"select='gt(scene,0.4)',showinfo\" -vsync 0 :output_directory/:output_file_name")
54
+ line.run(file_name: @file_name, output_directory: output_folder_path, output_file_name: "#{file_name}_%05d.png")
70
55
  end
71
56
 
57
+ # Screenshot the second second and second to last second
58
+ # ffmpeg -ss 01:23:45 -i input -frames:v 1 -q:v 2 output.jpg
59
+ last_time = "#{time_parts[0]}:#{time_parts[1]}:#{(time_parts[2].to_f - 1).abs.floor}"
60
+ ffmpeg_command = "-ss 00:00:02 -i :file_name " +
61
+ "-ss :last_time -i :file_name " +
62
+ "-map 0:v -vframes 1 :output_directory/:output_file_name_start " +
63
+ "-map 1:v -vframes 1 :output_directory/:output_file_name_end"
64
+ line = Terrapin::CommandLine.new("ffmpeg", ffmpeg_command)
65
+ line.run(
66
+ file_name: @file_name,
67
+ last_time: last_time,
68
+ output_directory: output_folder_path,
69
+ output_file_name_start: "#{file_name}_%05d.png",
70
+ output_file_name_end: "#{file_name}_%05d.png"
71
+ )
72
+ remove_blank_shots(output_folder_path)
73
+
72
74
  output_folder_path
73
75
  end
74
76
 
data/lib/eikon.rb CHANGED
@@ -8,6 +8,7 @@ require "vips"
8
8
  require "sorbet-runtime"
9
9
 
10
10
  module Eikon
11
+ # T::Configuration.default_checked_level = :never
11
12
  extend T::Sig
12
13
 
13
14
  class Error < StandardError; end
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.9
4
+ version: 0.1.11
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-21 00:00:00.000000000 Z
11
+ date: 2024-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-vips