Last active
February 25, 2021 09:02
-
-
Save abautu/b2563a8e529a2d6e1cec5a5f6f11319b to your computer and use it in GitHub Desktop.
Bigbluebutton patch for issue #2483 (using files instead of pipes for video segments).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -urN recordandplayback/edl/audio.rb recordandplayback/edl/audio.rb | |
--- recordandplayback/edl/audio.rb 2020-09-25 19:56:21.000000000 +0300 | |
+++ recordandplayback/edl/audio.rb 2021-01-09 23:57:55.864891875 +0200 | |
@@ -22,9 +22,9 @@ | |
module Audio | |
FFMPEG_AEVALSRC = "aevalsrc=s=48000:c=stereo:exprs=0|0" | |
FFMPEG_AFORMAT = "aformat=sample_fmts=s16:sample_rates=48000:channel_layouts=stereo" | |
- FFMPEG_WF_CODEC = 'flac' | |
- FFMPEG_WF_ARGS = ['-c:a', FFMPEG_WF_CODEC, '-f', 'flac'] | |
- WF_EXT = 'flac' | |
+ FFMPEG_WF_CODEC = 'libvorbis' | |
+ FFMPEG_WF_ARGS = ['-c:a', FFMPEG_WF_CODEC, '-q:a', '2', '-f', 'ogg'] | |
+ WF_EXT = 'ogg' | |
def self.dump(edl) | |
BigBlueButton.logger.debug "EDL Dump:" | |
diff -urN recordandplayback/edl/video.rb recordandplayback/edl/video.rb | |
--- recordandplayback/edl/video.rb 2020-09-25 19:56:21.000000000 +0300 | |
+++ recordandplayback/edl/video.rb 2021-02-22 06:11:57.210900111 +0200 | |
@@ -23,10 +23,10 @@ | |
module BigBlueButton | |
module EDL | |
module Video | |
- FFMPEG_WF_CODEC = 'mpeg2video' | |
+ FFMPEG_WF_CODEC = 'libx264' | |
FFMPEG_WF_FRAMERATE = 24 | |
- FFMPEG_WF_ARGS = ['-an', '-codec', FFMPEG_WF_CODEC.to_s, '-q:v', '2', '-g', (FFMPEG_WF_FRAMERATE * 10).to_s, '-pix_fmt', 'yuv420p', '-r', FFMPEG_WF_FRAMERATE.to_s, '-f', 'mpegts'] | |
- WF_EXT = 'ts' | |
+ FFMPEG_WF_ARGS = ['-an', '-codec', FFMPEG_WF_CODEC.to_s, '-preset', 'superfast', '-crf', '28', '-g', (FFMPEG_WF_FRAMERATE * 10).to_s, '-pix_fmt', 'yuv420p', '-r', FFMPEG_WF_FRAMERATE.to_s, '-bsf:v', 'h264_mp4toannexb'] | |
+ WF_EXT = 'mp4' | |
def self.dump(edl) | |
BigBlueButton.logger.debug "EDL Dump:" | |
@@ -254,14 +254,25 @@ | |
BigBlueButton.logger.info "Compositing cuts" | |
render = "#{output_basename}.#{WF_EXT}" | |
+ concat = [] | |
for i in 0...(edl.length - 1) | |
if edl[i][:timestamp] == edl[i][:next_timestamp] | |
warn 'Skipping 0-length edl entry' | |
next | |
end | |
- composite_cut(render, edl[i], layout, videoinfo) | |
+ segment = "#{output_basename}_#{i}.#{WF_EXT}" | |
+ composite_cut(segment, edl[i], layout, videoinfo) | |
+ concat += ["file #{segment}"] | |
end | |
+ concat_file = "#{output_basename}.txt" | |
+ File.write(concat_file, concat.join("\n")) | |
+ | |
+ ffmpeg_cmd = [*FFMPEG] | |
+ ffmpeg_cmd += ['-safe', '0', '-f', 'concat', '-i', concat_file , '-c', 'copy', render] | |
+ exitstatus = BigBlueButton.exec_ret(*ffmpeg_cmd) | |
+ raise "ffmpeg failed, exit code #{exitstatus}" if exitstatus != 0 | |
+ | |
return render | |
end | |
@@ -542,12 +553,10 @@ | |
ffmpeg_filter << ",trim=end=#{ms_to_s(duration)}" | |
ffmpeg_cmd = [*FFMPEG] | |
- ffmpeg_cmd += ['-filter_complex', ffmpeg_filter, *FFMPEG_WF_ARGS, '-'] | |
+ ffmpeg_cmd += ['-filter_complex', ffmpeg_filter, *FFMPEG_WF_ARGS, output] | |
- File.open(output, 'a') do |outio| | |
- exitstatus = BigBlueButton.exec_redirect_ret(outio, *ffmpeg_cmd) | |
- raise "ffmpeg failed, exit code #{exitstatus}" if exitstatus != 0 | |
- end | |
+ exitstatus = BigBlueButton.exec_ret(*ffmpeg_cmd) | |
+ raise "ffmpeg failed, exit code #{exitstatus}" if exitstatus != 0 | |
return output | |
end | |
diff -urN recordandplayback/edl.rb recordandplayback/edl.rb | |
--- recordandplayback/edl.rb 2020-09-25 19:56:21.000000000 +0300 | |
+++ recordandplayback/edl.rb 2021-02-24 13:36:26.996992433 +0200 | |
@@ -70,6 +70,7 @@ | |
exitstatus = BigBlueButton.exec_ret(*cmd) | |
raise "postprocess failed, exit code #{exitstatus}" if exitstatus != 0 | |
end | |
+ FileUtils.rm(lastoutput) | |
lastoutput = ppoutput | |
end | |
end | |
diff -urN recordandplayback/generators/audio_processor.rb recordandplayback/generators/audio_processor.rb | |
--- recordandplayback/generators/audio_processor.rb 2020-09-25 19:56:21.000000000 +0300 | |
+++ recordandplayback/generators/audio_processor.rb 2021-01-10 00:12:10.467177144 +0200 | |
@@ -60,13 +60,13 @@ | |
ogg_format = { | |
:extension => 'ogg', | |
- :parameters => [ [ '-c:a', 'libvorbis', '-q:a', '2', '-f', 'ogg' ] ] | |
+ :parameters => [ [ '-c:a', 'copy', '-f', 'ogg' ] ] | |
} | |
BigBlueButton::EDL.encode(@audio_file, nil, ogg_format, file_basename) | |
webm_format = { | |
:extension => 'webm', | |
- :parameters => [ [ '-c:a', 'libvorbis', '-q:a', '2', '-f', 'webm' ] ], | |
+ :parameters => [ [ '-c:a', 'copy', '-f', 'webm' ] ], | |
:postprocess => [ [ 'mkclean', '--quiet', ':input', ':output' ] ] | |
} | |
BigBlueButton::EDL.encode(@audio_file, nil, webm_format, file_basename) | |
diff -urN recordandplayback/generators/video.rb recordandplayback/generators/video.rb | |
--- recordandplayback/generators/video.rb 2020-12-22 00:30:44.847685272 +0200 | |
+++ recordandplayback/generators/video.rb 2021-01-09 23:57:55.872891808 +0200 | |
@@ -55,8 +55,8 @@ | |
# These settings are appropriate for 640x480 medium quality, and should be tweaked for other resolutions | |
# See https://developers.google.com/media/vp9/settings/vod/ | |
# Increase -threads to max of 4 or increase -speed to max of 4 to speed up processing | |
- %w[-c:v libvpx-vp9 -b:v 750K -minrate 375K -maxrate 1088K -crf 33 -quality good -speed 1 -g 240 -tile-columns 1 -threads 2 | |
- -c:a libopus -b:a 48K | |
+ %w[-c:v libvpx-vp9 -crf 28 -deadline realtime -cpu-used 8 -g 240 -tile-columns 1 -threads 2 | |
+ -c:a copy | |
-f webm] | |
# Google recommends doing a 2-pass encode for better quality, but it's a lot slower. If you want to do this, | |
# comment the lines above, and uncomment the lines below. | |
@@ -76,7 +76,7 @@ | |
# Increase -threads (or remove it, to use all cpu cores) to speed up processing | |
# You can also change the preset: try 'fast' or 'faster' | |
# To change quality, adjust the -crf value. Lower numbers are higher quality. | |
- %w[-c:v libx264 -crf 23 -threads 2 -preset medium -g 240 | |
+ %w[-c:v copy | |
-c:a aac -b:a 64K | |
-f mp4 -movflags faststart] | |
], | |
@@ -121,8 +121,8 @@ | |
# These settings are appropriate for 1280x720 medium quality, and should be tweaked for other resolutions | |
# See https://developers.google.com/media/vp9/settings/vod/ | |
# Increase -threads to max of 8 or increase -speed to max of 4 to speed up processing | |
- %w[-c:v libvpx-vp9 -b:v 1024K -minrate 512K -maxrate 1485K -crf 32 -quality good -speed 2 -g 240 -tile-columns 2 -threads 2 | |
- -c:a libopus -b:a 48K | |
+ %w[-c:v libvpx-vp9 -crf 28 -deadline realtime -cpu-used 8 -g 240 -tile-columns 2 -threads 2 | |
+ -c:a copy | |
-f webm] | |
# Google recommends doing a 2-pass encode for better quality, but it's a lot slower. If you want to do this, | |
# comment the lines above, and uncomment the lines below. | |
@@ -142,7 +142,7 @@ | |
# Increase -threads (or remove it, to use all cpu cores) to speed up processing | |
# You can also change the preset: try 'fast' or 'faster' | |
# To change quality, adjust the -crf value. Lower numbers are higher quality. | |
- %w[-c:v libx264 -crf 23 -threads 2 -preset medium -g 240 | |
+ %w[-c:v copy | |
-c:a aac -b:a 64K | |
-f mp4 -movflags faststart] | |
], |
LiohMoeller
commented
Feb 25, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment