ffmprb 0.12.1 → 0.12.3

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.
@@ -1,3 +1,5 @@
1
+ require 'tempfile'
2
+
1
3
  module Ffmprb
2
4
 
3
5
  class Process
@@ -134,6 +136,7 @@ module Ffmprb
134
136
  end
135
137
  end
136
138
 
139
+ # TODO ...or... "output label"! (implement intermediate "outputs" through this)
137
140
  def input_label(input)
138
141
  @inputs.index input
139
142
  end
@@ -160,11 +163,12 @@ module Ffmprb
160
163
  thr = Util::Thread.new main: !parent do
161
164
  proc_vis_node Thread.current
162
165
  # NOTE yes, an exception can occur anytime, and we'll just die, it's ok, see above
163
- cmd = command
164
- opts = {limit: limit, timeout: timeout}
165
- opts[:ignore_broken_pipes] = ignore_broken_pipes unless ignore_broken_pipes.nil?
166
- Util.ffmpeg(*cmd, **opts).tap do |res|
167
- Util::Thread.join_children! limit, timeout: timeout
166
+ command do |cmd|
167
+ opts = {limit: limit, timeout: timeout}
168
+ opts[:ignore_broken_pipes] = ignore_broken_pipes unless ignore_broken_pipes.nil?
169
+ Util.ffmpeg(*cmd, **opts).tap do |res|
170
+ Util::Thread.join_children! limit, timeout: timeout
171
+ end
168
172
  end
169
173
  proc_vis_node Thread.current, :remove
170
174
  end
@@ -174,23 +178,28 @@ module Ffmprb
174
178
  private
175
179
 
176
180
  def command
177
- input_args + filter_args + output_args
181
+ fail "Miserably" unless
182
+ block_given?
183
+ Tempfile.create do |tmp_file|
184
+ yield input_args(tmp_file) + filter_args(tmp_file) + output_args(tmp_file)
185
+ end
178
186
  end
179
187
 
180
- def input_args
181
- filter_args # NOTE must run first
188
+ def input_args(script_file=nil)
189
+ filter_args script_file # NOTE must run first
182
190
  @input_args ||= @inputs.map(&:args).reduce(:+)
183
191
  end
184
192
 
185
- # NOTE must run first
186
- def filter_args
193
+ # NOTE must run first (which is excusable just because it's private)
194
+ def filter_args(script_file=nil)
187
195
  @filter_args ||= Filter.complex_args(
188
- @outputs.map(&:filters).reduce :+
196
+ *@outputs.map(&:filters).reduce(:+),
197
+ script_file: script_file
189
198
  )
190
199
  end
191
200
 
192
- def output_args
193
- filter_args # NOTE must run first
201
+ def output_args(script_file=nil)
202
+ filter_args script_file # NOTE must run first
194
203
  @output_args ||= @outputs.map(&:args).reduce(:+)
195
204
  end
196
205
 
@@ -59,7 +59,8 @@ module Ffmprb
59
59
  @parent.child_lives self
60
60
  Ffmprb.logger.warn "Not the main: false thread run by a #{self.class.name} thread" if main
61
61
  else
62
- Ffmprb.logger.warn "Not the main: true thread run by a not #{self.class.name} thread" unless main
62
+ Ffmprb.logger.warn "Not the main: true thread run by a not #{self.class.name} thread" unless
63
+ main
63
64
  end
64
65
  sync_q.enq :ok
65
66
  Ffmprb.logger.debug{"#{name} thread launched"}
@@ -99,7 +100,8 @@ module Ffmprb
99
100
  @children_mon.synchronize do
100
101
  Ffmprb.logger.debug{"releasing #{thr.name} thread"}
101
102
  @dead_children_q.enq thr
102
- fail "System Error" unless @live_children.delete thr
103
+ fail "System Error" unless
104
+ @live_children.delete thr
103
105
  end
104
106
  proc_vis_edge self, thr, :remove
105
107
  end
@@ -112,7 +114,8 @@ module Ffmprb
112
114
  @dead_children_q.deq
113
115
  end
114
116
  Ffmprb.logger.debug "joining the late #{thr.name} thread"
115
- fail "System Error" unless thr.join(timeout) # NOTE should not block
117
+ fail "System Error" unless
118
+ thr.join(timeout) # NOTE should not block
116
119
  end
117
120
  end
118
121
  end
data/lib/ffmprb/util.rb CHANGED
@@ -24,12 +24,14 @@ module Ffmprb
24
24
  def ffmpeg(*args, limit: nil, timeout: cmd_timeout, ignore_broken_pipes: true)
25
25
  args = %w[-loglevel debug] + args if
26
26
  Ffmprb.ffmpeg_debug
27
- sh *ffmpeg_cmd, *args,
28
- output: :stderr,
29
- limit: limit,
30
- timeout: timeout,
31
- ignore_broken_pipes: ignore_broken_pipes,
32
- broken_pipe_error_re: FFMPEG_BROKEN_PIPE_ERROR_RE
27
+ sh(
28
+ *ffmpeg_cmd, *args,
29
+ output: :stderr,
30
+ limit: limit,
31
+ timeout: timeout,
32
+ ignore_broken_pipes: ignore_broken_pipes,
33
+ broken_pipe_error_re: FFMPEG_BROKEN_PIPE_ERROR_RE
34
+ )
33
35
  end
34
36
 
35
37
  def sh(*cmd, input: nil, output: :stdout, limit: nil, timeout: cmd_timeout, ignore_broken_pipes: false, broken_pipe_error_re: nil)
@@ -1,6 +1,6 @@
1
1
  module Ffmprb
2
2
 
3
- VERSION = '0.12.1'
3
+ VERSION = '0.12.3'
4
4
 
5
5
  GEM_GITHUB_URL = 'https://github.com/costa/ffmprb'
6
6
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffmprb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.1
4
+ version: 0.12.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Costa Shapiro
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-01-02 00:00:00.000000000 Z
11
+ date: 2023-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mkfifo
@@ -189,6 +189,7 @@ files:
189
189
  - exp/youtubby/README.md
190
190
  - exp/youtubby/bin/up-deps
191
191
  - exp/youtubby/docker-compose.yml
192
+ - exp/youtubby/exp/gop-raw-cut-rcc-join-you-HD60.rb
192
193
  - exp/youtubby/exp/gop-raw-cut-you-HD60
193
194
  - exp/youtubby/exp/gop-raw-cut-you-HD60.rb
194
195
  - exp/youtubby/exp/media-upload
@@ -246,7 +247,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
246
247
  requirements:
247
248
  - - ">="
248
249
  - !ruby/object:Gem::Version
249
- version: '0'
250
+ version: '2.6'
250
251
  required_rubygems_version: !ruby/object:Gem::Requirement
251
252
  requirements:
252
253
  - - ">="