video_conv 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/video_converter/version.rb +2 -2
- data/lib/video_converter.rb +26 -26
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42af0e74253ab7f2408f5f100c029426c6d41d83fa1698dd2c65403e4486d9e8
|
4
|
+
data.tar.gz: 064f07c6d31f2fec3072e090a71414a50e98ebf883ad722380fe139364fc94e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36f32db10f200fb19fc778aa0ec678476b66544953ba38754e66489e7902a5b9b25a6dbef39ed50d96ba1712bf34311b6e79ff118709fda8babd9ef508cbc382
|
7
|
+
data.tar.gz: c9ed466220efa9f6090f2d8b97cd65f4d23812a7bd8a64ed4ebe5ac5d63656a32bc3a61d22d75bb782d655aea8faddd4d04f4faf35cc126454a8d37175091937
|
data/lib/video_converter.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
require 'streamio-ffmpeg'
|
3
|
-
require '
|
3
|
+
require 'concurrent'
|
4
4
|
|
5
5
|
module VideoConverter
|
6
6
|
class Converter
|
@@ -18,48 +18,48 @@ module VideoConverter
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def rename_and_convert_files(dir, source_ext, target_ext)
|
21
|
+
convert_files_in_batch(get_source_files_recursive(dir, source_ext), source_ext, target_ext)
|
22
|
+
end
|
23
|
+
|
24
|
+
def get_source_files_recursive(dir, source_ext)
|
21
25
|
source_files = []
|
22
26
|
Dir.foreach(dir) do |file|
|
23
27
|
next if file == '.' || file == '..'
|
24
28
|
|
25
29
|
current_path = File.join(dir, file)
|
26
30
|
if File.directory?(current_path)
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
source_files << current_path
|
31
|
-
end
|
31
|
+
source_files.concat(get_source_files_recursive(current_path, source_ext)) # Recursively call for subdirectories
|
32
|
+
elsif file.end_with?(source_ext)
|
33
|
+
source_files << current_path
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
35
|
-
source_files
|
36
|
-
convert_files_in_batch(file_batch, source_ext, target_ext)
|
37
|
-
sleep(conversion_delay)
|
38
|
-
end
|
37
|
+
source_files
|
39
38
|
end
|
40
39
|
|
41
40
|
def convert_files_in_batch(files, source_ext, target_ext)
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
41
|
+
executor = Concurrent::ThreadPoolExecutor.new(
|
42
|
+
min_threads: 1,
|
43
|
+
max_threads: max_concurrency,
|
44
|
+
max_queue: files.size,
|
45
|
+
fallback_policy: :caller_runs
|
46
|
+
)
|
46
47
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
puts "Skipped conversion (already exists): #{file}"
|
57
|
-
end
|
48
|
+
files.each do |file|
|
49
|
+
executor.post do
|
50
|
+
new_filename = file.gsub(source_ext, target_ext)
|
51
|
+
if !File.exist?(new_filename)
|
52
|
+
convert_file(file, new_filename)
|
53
|
+
puts "Converted: #{file} -> #{new_filename}"
|
54
|
+
FileUtils.rm(file) # Remove the original file after conversion
|
55
|
+
else
|
56
|
+
puts "Skipped conversion (already exists): #{file}"
|
58
57
|
end
|
59
58
|
end
|
60
59
|
end
|
61
60
|
|
62
|
-
|
61
|
+
executor.shutdown
|
62
|
+
executor.wait_for_termination
|
63
63
|
end
|
64
64
|
|
65
65
|
def convert_single_file(source_file, target_file = nil, target_format = nil)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: video_conv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Webster
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: streamio-ffmpeg
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: concurrent-ruby
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.2'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.2'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rspec
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|