is new rendering

This commit is contained in:
j 2017-10-09 09:03:17 +00:00
parent 1c235dfd2a
commit 4bb1c6c835
2 changed files with 61 additions and 27 deletions

View File

@ -7,6 +7,8 @@ import shutil
import subprocess
import sys
cleanup = True
def get_videoduration(video):
cmd = [
'ffprobe',
@ -52,6 +54,12 @@ def encode(xml, force=False, prefix='.'):
public_mp4 = os.path.join(prefix, 'public', mp4.split('/')[-1][0].lower() + mp4.split('/')[-2] + '.1080p.mp4')
public_mp4_480p = public_mp4.replace('.1080p.mp4', '.480p.mp4')
gongs = 'performance' in prefix
gongs_wav = mp4.replace('.mp4', '.gongs.wav')
gongs_left = mp4.replace('.mp4', '.gongs.right.wav')
gongs_right = mp4.replace('.mp4', '.gongs.left.wav')
force = True
if force or is_new(xml, public_mp4):
print(public_mp4)
@ -61,7 +69,9 @@ def encode(xml, force=False, prefix='.'):
'vcodec=libx264',
'acodec=pcm_s16le'
]
subprocess.call(cmd)
if is_new(xml, video):
subprocess.call(cmd)
duration = get_videoduration(video)
cmd = [
'ffmpeg', '-y', '-i', video,
@ -69,24 +79,41 @@ def encode(xml, force=False, prefix='.'):
'-map_channel', '0.1.1', right,
]
subprocess.call(cmd)
if gongs:
cmd = [
'ffmpeg', '-y', '-i', gongs_wav,
'-map_channel', '0.0.0', gongs_left,
'-map_channel', '0.0.1', gongs_right,
]
subprocess.call(cmd)
cmd = [
'qmelt', vocals_xml, '-consumer',
'avformat:' + vocals,
'acodec=pcm_s16le',
'ac=1'
]
subprocess.call(cmd)
if is_new(xml, vocals):
subprocess.call(cmd)
#for wav in (left, right, vocals):
# cmd = ['normalize-audio', wav]
# subprocess.call(cmd)
front_left = left
front_right = left
front_center = vocals
lfe = silence
back_left = vocals
back_right = vocals
if gongs:
back_left = gongs_left
back_right = gongs_right
cmd = [
'ffmpeg', '-y',
'-i', left, # FL
'-i', right, # FR
'-i', vocals, # FC
'-i', silence, # LFE
'-i', vocals, # BL
'-i', vocals, # BR
'-i', front_left, # FL
'-i', front_right, # FR
'-i', front_center, # FC
'-i', lfe, # LFE
'-i', back_left, # BL
'-i', back_right, # BR
'-filter_complex',
'[0:0][1:0][2:0][3:0][4:0][5:0] amerge=inputs=6[aout]',
'-map', "[aout]",
@ -95,9 +122,13 @@ def encode(xml, force=False, prefix='.'):
amix
]
subprocess.call(cmd)
os.unlink(left)
os.unlink(right)
os.unlink(vocals)
if cleanup:
os.unlink(left)
os.unlink(right)
os.unlink(vocals)
if gongs:
os.unlink(gongs_left)
os.unlink(gongs_right)
cmd = [
'ffmpeg', '-y',
@ -111,23 +142,25 @@ def encode(xml, force=False, prefix='.'):
mp4
]
subprocess.call(cmd)
os.unlink(video)
os.unlink(amix)
cmd = [
'ffmpeg', '-y',
'-i', mp4,
'-c:a', 'copy',
'-vf', 'scale=854:480',
'-c:v', 'libx264',
'-preset', 'medium',
'-b:v', '750k',
'-profile:v', 'high',
'-movflags', '+faststart',
mp4_480p
]
subprocess.call(cmd)
if cleanup:
os.unlink(video)
os.unlink(amix)
if is_new(mp4, public_mp4_480p):
cmd = [
'ffmpeg', '-y',
'-i', mp4,
'-c:a', 'copy',
'-vf', 'scale=854:480',
'-c:v', 'libx264',
'-preset', 'medium',
'-b:v', '750k',
'-profile:v', 'high',
'-movflags', '+faststart',
mp4_480p
]
subprocess.call(cmd)
shutil.move(mp4_480p, public_mp4_480p)
shutil.move(mp4, public_mp4)
shutil.move(mp4_480p, public_mp4_480p)
cmd = [
'./subtitles.py',
'--prefix', prefix,

View File

@ -230,6 +230,7 @@ if version == 'performance':
# mix gongs + music
mtractor = mix_audio_tracks(gongs, music, 0.15)
else:
# mix drones + music
mtractor = mix_audio_tracks(drones, music, 0.3)