-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmerger-converter.rb
executable file
·61 lines (52 loc) · 1.75 KB
/
merger-converter.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env ruby
require '../converter.rb'
def extract(dir, conference)
name = conference[:file]
primary = File.join INPUT_DIRECTORY, dir, 'primary.mov'
secondary = File.join INPUT_DIRECTORY, dir, 'secondary.mov'
audio = File.join PASS1_DIRECTORY, "#{name}.wav"
video = File.join PASS1_DIRECTORY, "#{name}.webm"
video_primary = File.join PASS1_DIRECTORY, "#{name}-primary.webm"
video_secondary = File.join PASS1_DIRECTORY, "#{name}-secondary.webm"
from = conference[:from]
to = conference[:to]
to = Time.parse(to) - Time.parse(from) if from and to
args = Args.new
# Input
args << ['-ss', from] if from
args << ['-t', to] if to
args << ['-i', primary]
# Output audio
args << %w(-vn) \
<< FFMPEG[:audio][:wav] << audio
# Output video
args << %W(-an -vf scale=-1:#{RESOLUTION}) \
<< FFMPEG[:video][RESOLUTION] << video_primary
ffmpeg args if File.exists?(primary) and !File.exists?(audio, video_primary)
args = Args.new
# Input
args << ['-ss', from] if from
args << ['-t', to] if to
args << ['-i', secondary] \
<< %w(-an) \
<< %W(-vf crop=1440:1080:240:0,scale=-1:#{RESOLUTION}) \
<< FFMPEG[:video][RESOLUTION] \
<< video_secondary
ffmpeg args if File.exists?(secondary) and !File.exists?(video_secondary)
params = <<-EOF
nullsrc=size=1920x720 [base];
[0:v] setpts=PTS-STARTPTS, scale=-1:#{RESOLUTION} [left];
[1:v] setpts=PTS-STARTPTS, scale=-1:#{RESOLUTION} [right];
[base][left] overlay=shortest=1 [tmp1];
[tmp1][right] overlay=shortest=1:x=960
EOF
args = Args.new
args << ['-i', video_primary] \
<< ['-i', video_secondary] \
<< '-filter_complex' << params \
<< '-an' \
<< FFMPEG[:video][RESOLUTION] \
<< video
ffmpeg args if File.exists?(video_primary, video_secondary) and !File.exists?(video)
end
process if __FILE__ == $0