#!/usr/bin/python3 from glob import glob import os import shutil import subprocess for xml in glob('output/*.xml'): mp4 = xml.replace('.xml', '.mp4') pre = mp4 + '.pre.mp4' video = mp4 + '.v.mp4' audio = mp4 + '.wav' if not os.path.exists(mp4) or os.path.getmtime(xml) > os.path.getmtime(mp4): subprocess.call([ 'qmelt', xml, '-consumer', 'avformat:' + video, 'vcodec=libx264' ]) subprocess.call([ 'qmelt', xml, '-consumer', 'avformat:' + audio, ]) subprocess.call([ 'ffmpeg', '-y', '-i', video, '-i', audio, '-c:v', 'copy', '-map', '0:v', '-map', '1:a', '-strict', '-2', pre ]) os.unlink(video) os.unlink(audio) shutil.move(pre, mp4)