ffmprb 0.6.6 → 0.6.7

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: ecadecd6bd073a3c90519fb40212a178f3651adb
4
- data.tar.gz: d5f7b54d90b83f1411b04e08b33dac3cdc67f767
3
+ metadata.gz: 89d245761d8d4cc634a01b2df4b24285d8d12442
4
+ data.tar.gz: 9f837994c17a2b7537b1047b2cf3228b26786bc8
5
5
  SHA512:
6
- metadata.gz: 9921d1fdef89e73290d7c0b33a5adea2b85e2734fa1cf4438310535b3e0d25e3b81b9f13bfe49d7a2a50632dc669e52c88db181e4a480cf78bb067dbb113e21f
7
- data.tar.gz: 808e276f8647f11908efba894d3b92777d75f142e6487ffaea846dc4767041ee718f2e7dd6b1f5414d1045bed738813dc63e38763a1e10eb0cdeab8dbd35955a
6
+ metadata.gz: 925d6aaea191371123fe2bfa6df96ec30a2c33469f3804881c794400e8ab3681b08c9fecce3c2008702a3c9e183aa5c79fd4500569acf85a8aa7fb099fdd6659
7
+ data.tar.gz: 75ccb1c89e17601d9f3c5bf767dfb9b0a88810fd8f6e74316984391ebbf3dfa5c15acda73868135e8ec0eea1e53b7a38aea1dff09589f396bee96b58d0681823
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # ffmprb
2
+ [![Gem Version](https://badge.fury.io/rb/ffmprb.svg)](http://badge.fury.io/rb/ffmprb)
2
3
  ## your audio/video montage friend, based on [ffmpeg](https://ffmpeg.org)
3
4
 
4
5
  A DSL (Damn-Simple Language) and a micro-engine for ffmpeg and ffriends.
@@ -25,16 +26,15 @@ and saves you from the horrors of (the native ffmpeg equivalent)
25
26
  ```
26
27
  ffmpeg -y -i flick.mp4 -i track.wav -filter_complex "[0:v] copy [tmcpsp0:v]; [0:a] anull [tmcpsp0:a]; [tmcpsp0:v] trim=2:5, setpts=PTS-STARTPTS [cpsp0:v]; [tmcpsp0:a] atrim=2:5, asetpts=PTS-STARTPTS [cpsp0:a]; [cpsp0:v] crop=x=in_w*0.25:y=in_h*0.25:w=in_w*0.5:h=in_h*0.5 [sp0:v]; [cpsp0:a] anull [sp0:a]; [sp0:v] scale=iw*min(1280/iw\,720/ih):ih*min(1280/iw\,720/ih), pad=1280:720:(1280-iw*min(1280/iw\,720/ih))/2:(720-ih*min(1280/iw\,720/ih))/2, fps=fps=30 [rl0:v]; [sp0:a] anull [rl0:a]; color=black:d=1.0:s=1280x720:r=30 [bl0:v]; aevalsrc=0:d=1.0 [bl0:a]; [bl0:v] trim=0:1.0, setpts=PTS-STARTPTS [tm0b:v]; [bl0:a] atrim=0:1.0, asetpts=PTS-STARTPTS [tm0b:a]; color=white:d=1.0:s=1280x720:r=30 [rn70152323222540:v]; [tm0b:v] [rn70152323222540:v] alphamerge, fade=out:d=1.0:alpha=1 [xrn70152323222540:v]; [rl0:v] [xrn70152323222540:v] overlay=x=0:y=0:eof_action=pass [tn0:v]; [tm0b:a] afade=out:d=1.0 [rn70152323222540:a]; [rl0:a] afade=in:d=1.0 [xrn70152323222540:a]; [xrn70152323222540:a] [rn70152323222540:a] amix=2:duration=first [tn0:a]; [0:v] copy [tmldsp1:v]; [0:a] anull [tmldsp1:a]; [tmldsp1:v] trim=6, setpts=PTS-STARTPTS [ldsp1:v]; [tmldsp1:a] atrim=6, asetpts=PTS-STARTPTS [ldsp1:a]; [ldsp1:v] copy [sp1:v]; [ldsp1:a] volume='2':eval=frame [sp1:a]; [sp1:v] scale=iw*min(1280/iw\,720/ih):ih*min(1280/iw\,720/ih), pad=1280:720:(1280-iw*min(1280/iw\,720/ih))/2:(720-ih*min(1280/iw\,720/ih))/2, fps=fps=30 [rl1:v]; [sp1:a] anull [rl1:a]; color=black:d=3.0:s=1280x720:r=30 [bltn01:v]; aevalsrc=0:d=3.0 [bltn01:a]; [tn0:v] [bltn01:v] concat=2:v=1:a=0 [pdtn01:v]; [tn0:a] [bltn01:a] concat=2:v=0:a=1 [pdtn01:a]; [pdtn01:v] split [pdtn01a:v] [pdtn01b:v]; [pdtn01:a] asplit [pdtn01a:a] [pdtn01b:a]; [pdtn01a:v] trim=0:2, setpts=PTS-STARTPTS [tmtn01a:v]; [pdtn01a:a] atrim=0:2, asetpts=PTS-STARTPTS [tmtn01a:a]; [pdtn01b:v] trim=2:3.0, setpts=PTS-STARTPTS [tm1b:v]; [pdtn01b:a] atrim=2:3.0, asetpts=PTS-STARTPTS [tm1b:a]; color=white:d=1.0:s=1280x720:r=30 [rn70152323237760:v]; [tm1b:v] [rn70152323237760:v] alphamerge, fade=out:d=1.0:alpha=1 [xrn70152323237760:v]; [rl1:v] [xrn70152323237760:v] overlay=x=0:y=0:eof_action=pass [tn1:v]; [tm1b:a] afade=out:d=1.0 [rn70152323237760:a]; [rl1:a] afade=in:d=1.0 [xrn70152323237760:a]; [xrn70152323237760:a] [rn70152323237760:a] amix=2:duration=first [tn1:a]; color=black:d=11.0:s=1280x720:r=30 [bltn12:v]; aevalsrc=0:d=11.0 [bltn12:a]; [tn1:v] [bltn12:v] concat=2:v=1:a=0 [pdtn12:v]; [tn1:a] [bltn12:a] concat=2:v=0:a=1 [pdtn12:a]; [pdtn12:v] split [pdtn12a:v] [pdtn12b:v]; [pdtn12:a] asplit [pdtn12a:a] [pdtn12b:a]; [pdtn12a:v] trim=0:10, setpts=PTS-STARTPTS [tmtn12a:v]; [pdtn12a:a] atrim=0:10, asetpts=PTS-STARTPTS [tmtn12a:a]; color=black:d=1.0:s=1280x720:r=30 [bk2:v]; aevalsrc=0:d=1.0 [bk2:a]; [pdtn12b:v] trim=10:11.0, setpts=PTS-STARTPTS [tm2b:v]; [pdtn12b:a] atrim=10:11.0, asetpts=PTS-STARTPTS [tm2b:a]; color=white:d=1.0:s=1280x720:r=30 [rn70152323255640:v]; [tm2b:v] [rn70152323255640:v] alphamerge, fade=out:d=1.0:alpha=1 [xrn70152323255640:v]; [bk2:v] [xrn70152323255640:v] overlay=x=0:y=0:eof_action=pass [tn2:v]; [tm2b:a] afade=out:d=1.0 [rn70152323255640:a]; [bk2:a] afade=in:d=1.0 [xrn70152323255640:a]; [xrn70152323255640:a] [rn70152323255640:a] amix=2:duration=first [tn2:a]; [tmtn01a:v] [tmtn12a:v] [tn2:v] concat=3:v=1:a=0 [oo:v]; [tmtn01a:a] [tmtn12a:a] [tn2:a] concat=3:v=0:a=1 [oo:a]; [1:a] anull [ldol0:a]; [ldol0:a] volume='0.8':eval=frame [ol0:a]" -map "[oo:v]" -map "[oo:a]" /tmp/inter1a.flv -map "[ol0:a]" /tmp/inter1b.wav
27
28
  ```
28
- then some scripting around
29
29
  ```
30
30
  ffmpeg -y -i /tmp/inter1a.flv -filter_complex "silencedetect=d=2:n=-30dB" /tmp/inter2.flv
31
31
  ```
32
- and finally
33
32
  ```
34
33
  ffmpeg -y -i /tmp/inter2.flv -i /tmp/inter1b.wav -filter_complex "[0:v] copy [sp0:v]; [0:a] anull [sp0:a]; [sp0:v] scale=iw*min(1280/iw\,720/ih):ih*min(1280/iw\,720/ih), pad=1280:720:(1280-iw*min(1280/iw\,720/ih))/2:(720-ih*min(1280/iw\,720/ih))/2, fps=fps=30 [rl0:v]; [sp0:a] anull [rl0:a]; [rl0:v] concat=1:v=1:a=0 [oo:v]; [rl0:a] concat=1:v=0:a=1 [oo:a]; [1:a] anull [ldol0:a]; [ldol0:a] volume='if(between(t, 9.5, 10.5), (-0.8*t + 8.500000000000002)/1.0, if(between(t, 0.5, 9.5), 0.9, if(between(t, -0.5, 0.5), (0.8*t + 0.5)/1.0, if(between(t, 0.0, -0.5), 0.1, if(between(t, 0.0, 0.0), 0.1, 0.1)))))':eval=frame [ol0:a]; [oo:v] copy [oo0:v]; [oo:a] [ol0:a] amix=2:duration=first [oo0:a]" -map "[oo0:v]" -map "[oo0:a]" cine.flv
35
34
  ```
36
35
  Umm... That's the idea.
37
-
36
+ The docs, as well as any other part of this gem, are a work in progress.
37
+ So you're very welcome to look around the [specs](https://github.com/showbox-oss/ffmprb/tree/master/spec) for the current functionality coverage.
38
38
 
39
39
  ## Installation
40
40
 
data/lib/ffmprb/filter.rb CHANGED
@@ -4,6 +4,8 @@ module Ffmprb
4
4
 
5
5
  class << self
6
6
 
7
+ attr_accessor :silence_noise_max_db
8
+
7
9
  def alphamerge(inputs, output=nil)
8
10
  inout "alphamerge", inputs, output
9
11
  end
@@ -135,7 +137,7 @@ module Ffmprb
135
137
  end
136
138
 
137
139
  def silencedetect(input=nil, output=nil)
138
- inout "silencedetect=d=2:n=-30dB", input, output
140
+ inout "silencedetect=d=1:n=#{silence_noise_max_db}dB", input, output
139
141
  end
140
142
 
141
143
  def silent_source(duration, output=nil)
@@ -5,43 +5,50 @@ module Ffmprb
5
5
 
6
6
  class Process
7
7
 
8
- def self.intermediate_channel_extname(*media)
9
- if media == [:video]
10
- '.y4m'
11
- elsif media == [:audio]
12
- '.wav'
13
- elsif media.sort == [:audio, :video]
14
- '.flv'
15
- else
16
- raise Error, "I don't know how to channel [#{media.join ', '}]"
8
+ class << self
9
+
10
+ attr_accessor :duck_audio_hi, :duck_audio_lo
11
+ attr_accessor :duck_audio_silent_min_sec, :duck_audio_transition_sec
12
+
13
+ def intermediate_channel_extname(*media)
14
+ if media == [:video]
15
+ '.y4m'
16
+ elsif media == [:audio]
17
+ '.wav'
18
+ elsif media.sort == [:audio, :video]
19
+ '.flv'
20
+ else
21
+ raise Error, "I don't know how to channel [#{media.join ', '}]"
22
+ end
17
23
  end
18
- end
19
24
 
20
- def self.duck_audio(av_main_i, a_overlay_i, silence, av_main_o, video: {resolution: Ffmprb::QVGA, fps: 30})
21
- Ffmprb.process(av_main_i, a_overlay_i, silence, av_main_o) do |main_input, overlay_input, duck_data, main_output|
22
-
23
- in_main = input(main_input, **(video ? {} : {only: :audio}))
24
- in_over = input(overlay_input, only: :audio)
25
- prev_silent_at = 0
26
- output(main_output, **(video ? {resolution: video[:resolution], fps: video[:fps]} : {})) do
27
- roll in_main
28
- ducked_overlay_volume = {0.0 => 0.1}
29
- duck_data.each do |silent|
30
- next if silent.end_at && silent.start_at && (silent.end_at - silent.start_at) < 3
31
- ducked_overlay_volume.merge!(
32
- (silent.start_at - 0.5) => 0.1,
33
- (silent.start_at + 0.5) => 0.9
34
- ) if silent.start_at
35
- ducked_overlay_volume.merge!(
36
- (silent.end_at - 0.5) => 0.9,
37
- (silent.end_at + 0.5) => 0.1
38
- ) if silent.end_at
25
+ def duck_audio(av_main_i, a_overlay_i, silence, av_main_o, video: {resolution: Ffmprb::QVGA, fps: 30})
26
+ Ffmprb.process(av_main_i, a_overlay_i, silence, av_main_o) do |main_input, overlay_input, duck_data, main_output|
27
+
28
+ in_main = input(main_input, **(video ? {} : {only: :audio}))
29
+ in_over = input(overlay_input, only: :audio)
30
+ output(main_output, **(video ? {resolution: video[:resolution], fps: video[:fps]} : {})) do
31
+ roll in_main
32
+ ducked_overlay_volume = {0.0 => Process.duck_audio_lo}
33
+ duck_data.each do |silent|
34
+ next if silent.end_at && silent.start_at && (silent.end_at - silent.start_at) < Process.duck_audio_silent_min_sec
35
+
36
+ ducked_overlay_volume.merge!(
37
+ [silent.start_at - Process.duck_audio_transition_sec/2, 0.0].max => Process.duck_audio_lo,
38
+ (silent.start_at + Process.duck_audio_transition_sec/2) => Process.duck_audio_hi
39
+ ) if silent.start_at
40
+ ducked_overlay_volume.merge!(
41
+ [silent.end_at - Process.duck_audio_transition_sec/2, 0.0].max => Process.duck_audio_hi,
42
+ (silent.end_at + Process.duck_audio_transition_sec/2) => Process.duck_audio_lo
43
+ ) if silent.end_at
44
+ end
45
+ overlay in_over.volume ducked_overlay_volume
46
+ Ffmprb.logger.debug "Ducking audio with volumes: {#{ducked_overlay_volume.map{|t,v| "#{t}: #{v}"}.join ', '}}"
39
47
  end
40
- overlay in_over.volume ducked_overlay_volume
41
- Ffmprb.logger.debug "Ducking audio with volumes: {#{ducked_overlay_volume.map{|t,v| "#{t}: #{v}"}.join ', '}}"
42
- end
43
48
 
49
+ end
44
50
  end
51
+
45
52
  end
46
53
 
47
54
  def initialize(*args, &blk)
@@ -1,3 +1,3 @@
1
1
  module Ffmprb
2
- VERSION = "0.6.6"
2
+ VERSION = "0.6.7"
3
3
  end
data/lib/ffmprb.rb CHANGED
@@ -19,6 +19,12 @@ module Ffmprb
19
19
  class Error < StandardError
20
20
  end
21
21
 
22
+ Process.duck_audio_hi = 0.9
23
+ Process.duck_audio_lo = 0.1
24
+ Process.duck_audio_transition_sec = 1
25
+ Process.duck_audio_silent_min_sec = 3
26
+ Filter.silence_noise_max_db = -40
27
+
22
28
  Util::IoBuffer.blocks_max = 1024
23
29
  Util::IoBuffer.block_size = 64*1024
24
30
  Util::IoBuffer.timeout = 9
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.6.6
4
+ version: 0.6.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - showbox.com
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2015-07-20 00:00:00.000000000 Z
12
+ date: 2015-07-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mkfifo