wco_models 3.1.0.227 → 3.1.0.229
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 +4 -4
- data/app/controllers/wco/newsvideos_controller.rb +4 -103
- data/app/jobs/wco/newsvideo_generate_job.rb +14 -0
- data/app/models/wco/newspartial.rb +2 -1
- data/app/models/wco/newsvideo.rb +106 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 35f0a2494dffe699ad7a91e1b2f2a08732a52f7a8cee5807e0692743b72304cc
|
|
4
|
+
data.tar.gz: c189c18f602662123f112cca121258942c35708eaf2804cec37744d2ccc781e5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c4abf1dcd6c75dad28c97c6557afcfccce94e08b5374f20e187f0d6fe25fa2cb400bba3b0e37ee65793e3e2f659e4ef6231ccf77effaeeeeb87d0b690d4a0f85
|
|
7
|
+
data.tar.gz: 969bbd295573b4c14214d30f237418de3c20f75540f4a0eef4644f48779981a0f84934ae9f21788962406ce915b4b9d0bdea07355dc4004870d4f7eb17bf1d7b
|
|
@@ -32,110 +32,11 @@ class Wco::NewsvideosController < Wco::ApplicationController
|
|
|
32
32
|
@newsvideo = Wco::Newsvideo.unscoped.find params[:id]
|
|
33
33
|
authorize! :edit, @newsvideo
|
|
34
34
|
|
|
35
|
+
Rails.env.production? ?
|
|
36
|
+
Wco::NewsvideoIllustrationJob.perform_async(@newsvideo.id.to_s) :
|
|
37
|
+
Wco::NewsvideoIllustrationJob.perform_sync( @newsvideo.id.to_s)
|
|
35
38
|
|
|
36
|
-
|
|
37
|
-
# cmd = "cd #{Rails.root.join('tmp')} ; mkdir -p #{@newsvideo.id} ; cd #{@newsvideo.id} ; rm -f videolist.txt audiolist.txt ; "
|
|
38
|
-
# @newsvideo.newspartials.each_with_index do |part, idx|
|
|
39
|
-
# cmd = "#{cmd} echo \"file 'newspartial_#{idx}.mp4' \" >> videolist.txt ; "
|
|
40
|
-
# cmd = "#{cmd} echo \"file 'newspartial_#{idx}.wav' \" >> audiolist.txt ; "
|
|
41
|
-
# cmd = "#{cmd} ffmpeg -i newspartial_#{idx}.webm newspartial_#{idx}.mp4 ; "
|
|
42
|
-
# end
|
|
43
|
-
# puts! cmd, 'cmd'
|
|
44
|
-
# out = `#{cmd}`
|
|
45
|
-
# puts! out, 'out'
|
|
46
|
-
|
|
47
|
-
## get base files locally
|
|
48
|
-
# cmd = "cd #{Rails.root.join('tmp', @newsvideo.id)} ; "
|
|
49
|
-
# @newsvideo.newspartials.each_with_index do |part, idx|
|
|
50
|
-
# cmd = "#{cmd} wget -O newspartial_#{idx}.webm #{part.video.video.url} ; "
|
|
51
|
-
# cmd = "#{cmd} wget -O newspartial_#{idx}.wav #{part.audio.url} ; "
|
|
52
|
-
# end
|
|
53
|
-
# puts! cmd, 'cmd'
|
|
54
|
-
# out = `#{cmd}`
|
|
55
|
-
# puts! out, 'out'
|
|
56
|
-
|
|
57
|
-
## get overlays
|
|
58
|
-
# cmd = "cd #{Rails.root.join('tmp', @newsvideo.id)} ; "
|
|
59
|
-
# @newsvideo.newsoverlays.each_with_index do |overlay, idx|
|
|
60
|
-
# cmd = "#{cmd} wget -O overlay_#{idx}.mp4 #{overlay.video.video.url} ; "
|
|
61
|
-
# end
|
|
62
|
-
# puts! cmd, 'cmd'
|
|
63
|
-
# out = `#{cmd}`
|
|
64
|
-
# puts! out, 'out'
|
|
65
|
-
|
|
66
|
-
## video concat
|
|
67
|
-
# cmd = <<AOL
|
|
68
|
-
# cd #{Rails.root.join('tmp', @newsvideo.id)} ;
|
|
69
|
-
# rm -f video_concat.mp4 ;
|
|
70
|
-
# ffmpeg -f concat -safe 0 -i videolist.txt -c copy video_concat.mp4 ;
|
|
71
|
-
# AOL
|
|
72
|
-
# puts! cmd, 'cmd'
|
|
73
|
-
# out = `#{cmd}`
|
|
74
|
-
# puts! out, 'out'
|
|
75
|
-
|
|
76
|
-
## audio concat
|
|
77
|
-
# audio_filenames = (0...@newsvideo.newspartials.length).map { |i| "newspartial_#{i}.wav" }.join("|")
|
|
78
|
-
# cmd = <<AOL
|
|
79
|
-
# cd #{Rails.root.join('tmp', @newsvideo.id)} ;
|
|
80
|
-
# rm -f audio_concat.wav ;
|
|
81
|
-
# ffmpeg -f concat -safe 0 -i audiolist.txt -c copy audio_concat.wav ;
|
|
82
|
-
# AOL
|
|
83
|
-
# puts! cmd, 'cmd'
|
|
84
|
-
# out = `#{cmd}`
|
|
85
|
-
# puts! out, 'out'
|
|
86
|
-
|
|
87
|
-
## combine base
|
|
88
|
-
# cmd = <<AOL
|
|
89
|
-
# cd #{Rails.root.join('tmp', @newsvideo.id)} ;
|
|
90
|
-
# rm -f output.mp4 ;
|
|
91
|
-
# ffmpeg -i video_concat.mp4 -i audio_concat.wav -c:v copy -c:a aac combined_base.mp4 ;
|
|
92
|
-
# AOL
|
|
93
|
-
# puts! cmd, 'cmd'
|
|
94
|
-
# out = `#{cmd}`
|
|
95
|
-
# puts! out, 'out'
|
|
96
|
-
|
|
97
|
-
## combine overlays
|
|
98
|
-
# nn = @newsvideo.newsoverlays.map { |ol| ol.start_at_ms }
|
|
99
|
-
# puts! nn, 'nn'
|
|
100
|
-
# ffmpeg_cmd = [ "ffmpeg -i combined_base.mp4 \\ " ]
|
|
101
|
-
# nn.each_with_index do |ms, idx|
|
|
102
|
-
# ffmpeg_cmd.push " -i overlay_#{idx}.mp4 \\ "
|
|
103
|
-
# end
|
|
104
|
-
# ffmpeg_cmd.push "-filter_complex \" \\ "
|
|
105
|
-
# #
|
|
106
|
-
# nn.each_with_index do |ms, idx|
|
|
107
|
-
# ffmpeg_cmd.push " [#{idx+1}:v]setpts=PTS-STARTPTS+#{ms.to_f/1000}/TB[v#{idx+1}]; \\ "
|
|
108
|
-
# end
|
|
109
|
-
# #
|
|
110
|
-
# curr_s = "0:v"
|
|
111
|
-
# n = nil
|
|
112
|
-
# nn.each_with_index do |ms, idx|
|
|
113
|
-
# n = idx+1
|
|
114
|
-
# ffmpeg_cmd.push " [#{curr_s}][v#{n}]overlay=0:0:eof_action=pass[tmp#{n}]; \\ "
|
|
115
|
-
# curr_s = "tmp#{n}"
|
|
116
|
-
# end
|
|
117
|
-
# ffmpeg_cmd.push " \" -map \"[#{curr_s}]\" -map 0:a? -c:v libx264 -c:a copy combined_fin.mp4 "
|
|
118
|
-
# ffmpeg_cmd = ffmpeg_cmd.join("\n")
|
|
119
|
-
# puts "+++ ffmpeg_cmd:"
|
|
120
|
-
# puts ffmpeg_cmd
|
|
121
|
-
|
|
122
|
-
# combine overlays 2
|
|
123
|
-
# cmd = <<AOL
|
|
124
|
-
# cd #{Rails.root.join('tmp', @newsvideo.id)} ;
|
|
125
|
-
# rm -f combined_fin.mp4 ;
|
|
126
|
-
# #{ffmpeg_cmd} ;
|
|
127
|
-
# AOL
|
|
128
|
-
# puts! cmd, 'cmd'
|
|
129
|
-
# out = `#{cmd}`
|
|
130
|
-
# puts! out, 'out'
|
|
131
|
-
|
|
132
|
-
## upload the video.
|
|
133
|
-
@video = Wco::Video.new name: @newsvideo.title
|
|
134
|
-
video_path = Rails.root.join("tmp", @newsvideo.id, "combined_fin.mp4")
|
|
135
|
-
@video.video = File.open(video_path)
|
|
136
|
-
@video.save!
|
|
137
|
-
|
|
138
|
-
render json: { status: :ok }
|
|
39
|
+
render json: { status: :ok, message: 'Scheduled the generation' }
|
|
139
40
|
end
|
|
140
41
|
|
|
141
42
|
def generate_illustration
|
data/app/models/wco/newsvideo.rb
CHANGED
|
@@ -50,4 +50,110 @@ class Wco::Newsvideo
|
|
|
50
50
|
Wco::Newsoverlay.where( newsvideo_id: self.id )
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
+
def generate
|
|
54
|
+
@newsvideo = self
|
|
55
|
+
|
|
56
|
+
## put together config
|
|
57
|
+
cmd = "cd #{Rails.root.join('tmp')} ; mkdir -p #{@newsvideo.id} ; cd #{@newsvideo.id} ; rm -f videolist.txt audiolist.txt ; "
|
|
58
|
+
@newsvideo.newspartials.each_with_index do |part, idx|
|
|
59
|
+
cmd = "#{cmd} echo \"file 'newspartial_#{idx}.mp4' \" >> videolist.txt ; "
|
|
60
|
+
cmd = "#{cmd} echo \"file 'newspartial_#{idx}.wav' \" >> audiolist.txt ; "
|
|
61
|
+
cmd = "#{cmd} ffmpeg -i newspartial_#{idx}.webm newspartial_#{idx}.mp4 ; "
|
|
62
|
+
end
|
|
63
|
+
puts! cmd, 'cmd'
|
|
64
|
+
out = `#{cmd}`
|
|
65
|
+
puts! out, 'out'
|
|
66
|
+
|
|
67
|
+
## get base files locally
|
|
68
|
+
cmd = "cd #{Rails.root.join('tmp', @newsvideo.id)} ; "
|
|
69
|
+
@newsvideo.newspartials.each_with_index do |part, idx|
|
|
70
|
+
cmd = "#{cmd} wget -O newspartial_#{idx}.webm #{part.video.video.url} ; "
|
|
71
|
+
cmd = "#{cmd} wget -O newspartial_#{idx}.wav #{part.audio.url} ; "
|
|
72
|
+
end
|
|
73
|
+
puts! cmd, 'cmd'
|
|
74
|
+
out = `#{cmd}`
|
|
75
|
+
puts! out, 'out'
|
|
76
|
+
|
|
77
|
+
## get overlays
|
|
78
|
+
cmd = "cd #{Rails.root.join('tmp', @newsvideo.id)} ; "
|
|
79
|
+
@newsvideo.newsoverlays.each_with_index do |overlay, idx|
|
|
80
|
+
cmd = "#{cmd} wget -O overlay_#{idx}.mp4 #{overlay.video.video.url} ; "
|
|
81
|
+
end
|
|
82
|
+
puts! cmd, 'cmd'
|
|
83
|
+
out = `#{cmd}`
|
|
84
|
+
puts! out, 'out'
|
|
85
|
+
|
|
86
|
+
## video concat
|
|
87
|
+
cmd = <<AOL
|
|
88
|
+
cd #{Rails.root.join('tmp', @newsvideo.id)} ;
|
|
89
|
+
rm -f video_concat.mp4 ;
|
|
90
|
+
ffmpeg -f concat -safe 0 -i videolist.txt -c copy video_concat.mp4 ;
|
|
91
|
+
AOL
|
|
92
|
+
puts! cmd, 'cmd'
|
|
93
|
+
out = `#{cmd}`
|
|
94
|
+
puts! out, 'out'
|
|
95
|
+
|
|
96
|
+
## audio concat
|
|
97
|
+
audio_filenames = (0...@newsvideo.newspartials.length).map { |i| "newspartial_#{i}.wav" }.join("|")
|
|
98
|
+
cmd = <<AOL
|
|
99
|
+
cd #{Rails.root.join('tmp', @newsvideo.id)} ;
|
|
100
|
+
rm -f audio_concat.wav ;
|
|
101
|
+
ffmpeg -f concat -safe 0 -i audiolist.txt -c copy audio_concat.wav ;
|
|
102
|
+
AOL
|
|
103
|
+
puts! cmd, 'cmd'
|
|
104
|
+
out = `#{cmd}`
|
|
105
|
+
puts! out, 'out'
|
|
106
|
+
|
|
107
|
+
## combine base
|
|
108
|
+
cmd = <<AOL
|
|
109
|
+
cd #{Rails.root.join('tmp', @newsvideo.id)} ;
|
|
110
|
+
rm -f output.mp4 ;
|
|
111
|
+
ffmpeg -i video_concat.mp4 -i audio_concat.wav -c:v copy -c:a aac combined_base.mp4 ;
|
|
112
|
+
AOL
|
|
113
|
+
puts! cmd, 'cmd'
|
|
114
|
+
out = `#{cmd}`
|
|
115
|
+
puts! out, 'out'
|
|
116
|
+
|
|
117
|
+
## combine overlays
|
|
118
|
+
nn = @newsvideo.newsoverlays.map { |ol| ol.start_at_ms }
|
|
119
|
+
puts! nn, 'nn'
|
|
120
|
+
ffmpeg_cmd = [ "ffmpeg -i combined_base.mp4 \\ " ]
|
|
121
|
+
nn.each_with_index do |ms, idx|
|
|
122
|
+
ffmpeg_cmd.push " -i overlay_#{idx}.mp4 \\ "
|
|
123
|
+
end
|
|
124
|
+
ffmpeg_cmd.push "-filter_complex \" \\ "
|
|
125
|
+
#
|
|
126
|
+
nn.each_with_index do |ms, idx|
|
|
127
|
+
ffmpeg_cmd.push " [#{idx+1}:v]setpts=PTS-STARTPTS+#{ms.to_f/1000}/TB[v#{idx+1}]; \\ "
|
|
128
|
+
end
|
|
129
|
+
#
|
|
130
|
+
curr_s = "0:v"
|
|
131
|
+
n = nil
|
|
132
|
+
nn.each_with_index do |ms, idx|
|
|
133
|
+
n = idx+1
|
|
134
|
+
ffmpeg_cmd.push " [#{curr_s}][v#{n}]overlay=0:0:eof_action=pass[tmp#{n}]; \\ "
|
|
135
|
+
curr_s = "tmp#{n}"
|
|
136
|
+
end
|
|
137
|
+
ffmpeg_cmd.push " \" -map \"[#{curr_s}]\" -map 0:a? -c:v libx264 -c:a copy combined_fin.mp4 "
|
|
138
|
+
ffmpeg_cmd = ffmpeg_cmd.join("\n")
|
|
139
|
+
puts "+++ ffmpeg_cmd:"
|
|
140
|
+
puts ffmpeg_cmd
|
|
141
|
+
|
|
142
|
+
# combine overlays 2
|
|
143
|
+
cmd = <<AOL
|
|
144
|
+
cd #{Rails.root.join('tmp', @newsvideo.id)} ;
|
|
145
|
+
rm -f combined_fin.mp4 ;
|
|
146
|
+
#{ffmpeg_cmd} ;
|
|
147
|
+
AOL
|
|
148
|
+
puts! cmd, 'cmd'
|
|
149
|
+
out = `#{cmd}`
|
|
150
|
+
puts! out, 'out'
|
|
151
|
+
|
|
152
|
+
## upload the video.
|
|
153
|
+
@video = Wco::Video.new name: @newsvideo.title
|
|
154
|
+
video_path = Rails.root.join("tmp", @newsvideo.id, "combined_fin.mp4")
|
|
155
|
+
@video.video = File.open(video_path)
|
|
156
|
+
@video.save!
|
|
157
|
+
end
|
|
158
|
+
|
|
53
159
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: wco_models
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.1.0.
|
|
4
|
+
version: 3.1.0.229
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Victor Pudeyev
|
|
@@ -463,6 +463,7 @@ files:
|
|
|
463
463
|
- app/controllers/wco/videos_controller.rb
|
|
464
464
|
- app/helpers/wco/application_helper.rb
|
|
465
465
|
- app/jobs/wco/newspartial_video_job.rb
|
|
466
|
+
- app/jobs/wco/newsvideo_generate_job.rb
|
|
466
467
|
- app/jobs/wco/newsvideo_illustration_job.rb
|
|
467
468
|
- app/jobs/wco_hosting/certbot_job.rb
|
|
468
469
|
- app/mailers/wco_email/application_mailer.rb
|