Curb your enthusiasm moster

This commit is contained in:
jmaa 2018-06-13 16:06:30 +02:00
parent 51be032dbc
commit f21e43f147
2 changed files with 6 additions and 5 deletions

View File

@ -28,7 +28,7 @@ local function video_silences (video_filename, decibel, duration)
assert(type(duration) == 'number') assert(type(duration) == 'number')
-- --
local log_filename = os.tmpname() local log_filename = os.tmpname()
os.execute(('ffmpeg -i "%s" -af silencedetect=n=%sdB:d=%s -f null - 1> /dev/null 2> %s'):format(video_filename, decibel, duration, log_filename)) os.execute(('ffmpeg -loglevel panic -y -i "%s" -af silencedetect=n=%sdB:d=%s -f null - 1> /dev/null 2> %s'):format(video_filename, decibel, duration, log_filename))
local f = io.open(log_filename) local f = io.open(log_filename)
local silences = {} local silences = {}
for line in f:lines() do for line in f:lines() do
@ -70,11 +70,11 @@ local function paste_audio_onto_video (video_filename, audio_filename, timestamp
-- Generate silence -- Generate silence
local silence_filename = TMP_FOLDER..'silence.mp3' local silence_filename = TMP_FOLDER..'silence.mp3'
os.execute(('ffmpeg -y -f lavfi -i anullsrc=channel_layout=5.1:sample_rate=48000 -t %s %s &> /dev/null'):format(timestamp, silence_filename)) os.execute(('ffmpeg -loglevel panic -y -f lavfi -i anullsrc=channel_layout=5.1:sample_rate=48000 -t %s %s &> /dev/null'):format(timestamp, silence_filename))
-- Paste audio onto video -- Paste audio onto video
local output_filename = TMP_FOLDER..'output.webm' local output_filename = TMP_FOLDER..'output.webm'
local cmd = (('ffmpeg -y -i "%s" -i "concat:%s|%s" -filter_complex "[0:a:0][1:a:0]amerge=inputs=2[a]" -map 0:v:0 -map "[a]" -c:v copy -c:a libvorbis -ac 2 -shortest %s &> /dev/null'):format(video_filename, silence_filename, audio_filename, output_filename)) local cmd = (('ffmpeg -loglevel panic -y -i "%s" -i "concat:%s|%s" -filter_complex "[0:a:0][1:a:0]amerge=inputs=2[a]" -map 0:v:0 -map "[a]" -c:v copy -c:a libvorbis -ac 2 -shortest %s &> /dev/null'):format(video_filename, silence_filename, audio_filename, output_filename))
os.execute(cmd) os.execute(cmd)
return output_filename return output_filename

View File

@ -38,7 +38,8 @@ end
local function copy_remotely (origin_server, origin_path, target_server, target_path) local function copy_remotely (origin_server, origin_path, target_server, target_path)
local origin = origin_server and origin_server ~= 'localhost' and origin_server..':'..origin_path or origin_path local origin = origin_server and origin_server ~= 'localhost' and origin_server..':'..origin_path or origin_path
local target = target_server and target_server ~= 'localhost' and target_server..':'..target_path or target_path local target = target_server and target_server ~= 'localhost' and target_server..':'..target_path or target_path
os.execute('scp '..origin..' '..target..' > /dev/null') local status = os.execute('scp '..origin..' '..target..' &> /dev/null')
assert(status == 0)
end end
local function save_file_to_dcav (filename) local function save_file_to_dcav (filename)
@ -230,7 +231,7 @@ local function paste_topic_onto_image (target, topic, x, y, w, h, bg_color, font
-- Convert svg to png -- Convert svg to png
if url:match '%.svg$' then if url:match '%.svg$' then
local filename_2 = CONFIG.IMGGEN_PATH_OUTPUT..'topic_'..topic.topic..'.'..'png' local filename_2 = CONFIG.IMGGEN_PATH_OUTPUT..'topic_'..topic.topic..'.'..'png'
os.execute('convert -density "1200" -resize 400x400 "'..filename..'" "'..filename_2..'"') os.execute('convert -density "1200" -resize 400x400 "'..filename..'" "'..filename_2..'" &> /dev/null')
filename = filename_2 filename = filename_2
end end
-- --