ffmprb 0.9.0 → 0.9.1

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
  SHA1:
3
- metadata.gz: 161070550653011018121ce41eed46e7c762bfb5
4
- data.tar.gz: 75ab98311631bdcf5492d6ec9cb186d81139737f
3
+ metadata.gz: 18d2b33a88ea0bfef44157b50426e7a5fbd587e2
4
+ data.tar.gz: 38db083fd7d0b4c33f23516c10efaff35cc922ad
5
5
  SHA512:
6
- metadata.gz: 6a0cf9ba9bf75eebad6401578df7161acf208f3b1a926caa8b6007f29723be21690b5fbb6a5b53f5d046d26b1978358bfe08f15f72c1a9ed39a8327dff31ad1a
7
- data.tar.gz: 0339770c72cddda4ff50cfd98b56366573f90d110fa6c30e421d16d6bcabbf5a6d11014fbaeaca468594160bbc00da0495d984033491b26fd044ac77f00e421a
6
+ metadata.gz: 02a1c4faeaddf87e9e24ff957c812adae99d10988224445904b37435a96a184177e00ec70042227e6c68316b80a999a1c4672671036179eb42bcc2a005299c8e
7
+ data.tar.gz: 57f3a51c4604a7d9136ce25283d9794a6aa95ad893452ed3b0550184df1002e9ceed23e9b043b216bbe16e0bc1d6b62b2b9f99a3415da90fe924c1e665559bf6
data/lib/defaults.rb CHANGED
@@ -8,7 +8,7 @@ module Ffmprb
8
8
  Process.duck_audio_transition_out_start = -0.6
9
9
  Process.duck_audio_volume_hi = 0.9
10
10
  Process.duck_audio_volume_lo = 0.1
11
- Process.timeout = 15
11
+ Process.timeout = 30
12
12
 
13
13
  Process.output_video_resolution = CGA
14
14
  Process.output_video_fps = 30
@@ -16,12 +16,12 @@ module Ffmprb
16
16
 
17
17
  Util.ffmpeg_cmd = %w[ffmpeg -y]
18
18
  Util.ffprobe_cmd = ['ffprobe']
19
- Util.cmd_timeout = 6
19
+ Util.cmd_timeout = 30
20
20
 
21
21
  Util::ThreadedIoBuffer.blocks_max = 1024
22
22
  Util::ThreadedIoBuffer.block_size = 64*1024
23
23
  Util::ThreadedIoBuffer.timeout = 9
24
24
 
25
- Util::Thread.timeout = 12
25
+ Util::Thread.timeout = 15
26
26
 
27
27
  end
data/lib/ffmprb/file.rb CHANGED
@@ -66,7 +66,7 @@ module Ffmprb
66
66
  return fifo_file unless block_given?
67
67
 
68
68
  begin
69
- yield
69
+ yield fifo_file
70
70
  ensure
71
71
  fifo_file.remove
72
72
  end
@@ -17,10 +17,11 @@ module Ffmprb
17
17
 
18
18
  end
19
19
 
20
- # TODO unique labeling does not justify idx, will be refactored
21
- def initialize(io, idx, video:, audio:)
20
+ attr_reader :process
21
+
22
+ def initialize(io, process, video:, audio:)
22
23
  @io = resolve(io)
23
- @idx = idx
24
+ @process = process
24
25
  @channels = {
25
26
  video: video && @io.channel?(:video) && OpenStruct.new(video),
26
27
  audio: audio && @io.channel?(:audio) && OpenStruct.new(audio)
@@ -39,6 +40,8 @@ module Ffmprb
39
40
  fail Error, "Supporting just full_screen for now, sorry." unless @reels.all?(&:full_screen?)
40
41
  return @filters if @filters
41
42
 
43
+ idx = process.output_index(self)
44
+
42
45
  @filters = []
43
46
 
44
47
  # Concatting
@@ -52,7 +55,7 @@ module Ffmprb
52
55
 
53
56
  # NOTE mapping input to this lbl
54
57
 
55
- lbl = "o#{@idx}rl#{i}"
58
+ lbl = "o#{idx}rl#{i}"
56
59
 
57
60
  # NOTE Image-Padding to match the target resolution
58
61
  # TODO full screen only at the moment (see exception above)
@@ -130,11 +133,11 @@ module Ffmprb
130
133
 
131
134
  # NOTE snip the end of the previous segment and combine with this reel
132
135
 
133
- lbl_end1 = "o#{@idx}tm#{i}b"
134
- lbl_reel = "o#{@idx}tn#{i}"
136
+ lbl_end1 = "o#{idx}tm#{i}b"
137
+ lbl_reel = "o#{idx}tn#{i}"
135
138
 
136
139
  if !lbl # no reel
137
- lbl_aux = "o#{@idx}bk#{i}"
140
+ lbl_aux = "o#{idx}bk#{i}"
138
141
  @filters.concat(
139
142
  Filter.blank_source transition_length, channel(:video).resolution, channel(:video).fps, "#{lbl_aux}:v"
140
143
  ) if channel?(:video)
@@ -168,7 +171,7 @@ module Ffmprb
168
171
 
169
172
  segments.compact!
170
173
 
171
- lbl_out = "o#{@idx}o"
174
+ lbl_out = "o#{idx}o"
172
175
 
173
176
  @filters.concat(
174
177
  Filter.concat_v segments.map{|s| "#{s}:v"}, "#{lbl_out}:v"
@@ -188,9 +191,9 @@ module Ffmprb
188
191
 
189
192
  # Audio overlaying
190
193
 
191
- lbl_nxt = "o#{@idx}o#{i}"
194
+ lbl_nxt = "o#{idx}o#{i}"
192
195
 
193
- lbl_over = "o#{@idx}l#{i}"
196
+ lbl_over = "o#{idx}l#{i}"
194
197
  @filters.concat( # NOTE audio only, see above
195
198
  over_reel.reel.filters_for lbl_over, video: false, audio: channel(:audio)
196
199
  )
@@ -235,7 +238,7 @@ module Ffmprb
235
238
  Ffmprb.logger.debug "Re-routed the main audio output (#{main_av_inter_o.path}->...->#{main_av_o.path}) through the process of audio ducking"
236
239
 
237
240
  over_a_i, over_a_o = File.threaded_buffered_fifo(Process.intermediate_channel_extname :audio)
238
- lbl_over = "o#{@idx}l#{i}"
241
+ lbl_over = "o#{idx}l#{i}"
239
242
  @filters.concat(
240
243
  over_reel.reel.filters_for lbl_over, video: false, audio: channel(:audio)
241
244
  )
@@ -245,12 +248,17 @@ module Ffmprb
245
248
  inter_i, inter_o = File.threaded_buffered_fifo(main_av_inter_o.extname)
246
249
  Ffmprb.logger.debug "Allocated fifos to buffer media (#{inter_i.path}>#{inter_o.path}) while finding silence"
247
250
 
251
+ ignore_broken_pipe_was = process.ignore_broken_pipe
252
+ process.ignore_broken_pipe = true # NOTE audio ducking process may break the overlay pipe
253
+
248
254
  Util::Thread.new "audio ducking" do
249
255
  silence = Ffmprb.find_silence(main_av_inter_o, inter_i)
250
256
 
251
257
  Ffmprb.logger.debug "Audio ducking with silence: [#{silence.map{|s| "#{s.start_at}-#{s.end_at}"}.join ', '}]"
252
258
 
253
- Process.duck_audio inter_o, over_a_o, silence, main_av_o, video: channel(:video), audio: channel(:audio)
259
+ Process.duck_audio inter_o, over_a_o, silence, main_av_o,
260
+ process_options: {ignore_broken_pipe: ignore_broken_pipe_was, timeout: process.timeout},
261
+ video: channel(:video), audio: channel(:audio)
254
262
  end
255
263
  end
256
264
 
@@ -44,10 +44,11 @@ module Ffmprb
44
44
  volume_lo: duck_audio_volume_lo,
45
45
  volume_hi: duck_audio_volume_hi,
46
46
  silent_min: duck_audio_silent_min,
47
+ process_options: {},
47
48
  video:, # NOTE Temporarily, video should not be here
48
49
  audio:
49
50
  )
50
- Ffmprb.process do
51
+ Ffmprb.process **process_options do
51
52
 
52
53
  in_main = input(av_main_i)
53
54
  in_over = input(a_overlay_i)
@@ -80,13 +81,14 @@ module Ffmprb
80
81
 
81
82
  end
82
83
 
83
- attr_reader :timeout
84
+ attr_accessor :timeout
85
+ attr_accessor :ignore_broken_pipe
84
86
 
85
87
  def initialize(*args, **opts)
86
88
  @inputs, @outputs = [], []
87
- @timeout = opts.delete(:timeout) || self.class.timeout
89
+ self.timeout = opts.delete(:timeout) || self.class.timeout
88
90
 
89
- @ignore_broken_pipe = opts.delete(:ignore_broken_pipe) # XXX SPEC ME
91
+ self.ignore_broken_pipe = opts.delete(:ignore_broken_pipe)
90
92
  fail Error, "Unknown options: #{opts}" unless opts.empty?
91
93
  end
92
94
 
@@ -107,7 +109,7 @@ module Ffmprb
107
109
  end
108
110
 
109
111
  def output(io, video: true, audio: true, &blk)
110
- Output.new(io, @outputs.size,
112
+ Output.new(io, self,
111
113
  video: channel_params(video, self.class.output_video_options),
112
114
  audio: channel_params(audio, self.class.output_audio_options)
113
115
  ).tap do |out|
@@ -116,6 +118,10 @@ module Ffmprb
116
118
  end
117
119
  end
118
120
 
121
+ def output_index(output)
122
+ @outputs.index output
123
+ end
124
+
119
125
  # NOTE the one and the only entry-point processing function which spawns threads etc
120
126
  def run(limit: nil) # TODO (async: false)
121
127
  # NOTE this is both for the future async: option and according to
@@ -1,3 +1,3 @@
1
1
  module Ffmprb
2
- VERSION = '0.9.0'
2
+ VERSION = '0.9.1'
3
3
  end
data/lib/ffmprb.rb CHANGED
@@ -16,10 +16,10 @@ module Ffmprb
16
16
  class << self
17
17
 
18
18
  # TODO limit:
19
- def process(*args, &blk)
19
+ def process(*args, **opts, &blk)
20
20
  fail Error, "process: nothing ;( gimme a block!" unless blk
21
21
 
22
- process = Process.new
22
+ process = Process.new(**opts)
23
23
 
24
24
  logger.debug "Starting process with #{args} in #{blk.source_location}"
25
25
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffmprb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - showbox.com