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

View file

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