encode one
This commit is contained in:
parent
ac15b66419
commit
10314d1c3d
1 changed files with 15 additions and 4 deletions
19
encode.py
19
encode.py
|
@ -4,6 +4,7 @@ import os
|
|||
import json
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
def get_videoduration(video):
|
||||
cmd = [
|
||||
|
@ -32,9 +33,7 @@ def is_new(xml, mp4):
|
|||
)
|
||||
return vtime < xtime
|
||||
|
||||
for xml in sorted(glob('output/*/*.xml')):
|
||||
if xml.endswith('.audio.xml'):
|
||||
continue
|
||||
def encode(xml, force=False):
|
||||
audio_xml = xml.replace('.xml', '.audio.xml')
|
||||
mp4 = xml.replace('.xml', '.mp4')
|
||||
mp4_480p = mp4.replace('.mp4', '.480p.mp4')
|
||||
|
@ -42,7 +41,7 @@ for xml in sorted(glob('output/*/*.xml')):
|
|||
pre_480p = mp4_480p + '.pre.mp4'
|
||||
video = mp4 + '.v.mp4'
|
||||
audio = mp4 + '.wav'
|
||||
if is_new(xml, mp4):
|
||||
if force or is_new(xml, mp4):
|
||||
subprocess.call([
|
||||
'qmelt', xml, '-consumer', 'avformat:' + video, 'vcodec=libx264', 'strict=-2'
|
||||
])
|
||||
|
@ -73,3 +72,15 @@ for xml in sorted(glob('output/*/*.xml')):
|
|||
]
|
||||
subprocess.call(cmd)
|
||||
shutil.move(pre_480p, mp4_480p)
|
||||
|
||||
def encode_all():
|
||||
for xml in sorted(glob('output/*/*.xml')):
|
||||
if xml.endswith('.audio.xml') or xml.endswith('.vocals.xml'):
|
||||
continue
|
||||
encode(xml)
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) == 2:
|
||||
encode(sys.argv[1], True)
|
||||
else:
|
||||
encode_all()
|
||||
|
|
Loading…
Reference in a new issue