This commit is contained in:
j 2017-03-02 22:10:14 +01:00
parent e09dd01f9d
commit cd2fe0cf8a

View file

@ -1,9 +1,25 @@
#!/usr/bin/python3 #!/usr/bin/python3
from glob import glob from glob import glob
import os import os
import json
import shutil import shutil
import subprocess import subprocess
def get_videoduration(video):
cmd = [
'ffprobe',
'-show_format',
'-show_chapters',
'-show_streams',
'-print_format', 'json',
'-i', video
]
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stdin = p.communicate()
data = json.loads(stdout.decode())
duration = float([s for s in data['streams'] if 'width' in s][0]['duration']) - 10/60
return '%0.3f' % duration
for xml in sorted(glob('output/*/*.xml')): for xml in sorted(glob('output/*/*.xml')):
if xml.endswith('.audio.xml'): if xml.endswith('.audio.xml'):
continue continue
@ -35,4 +51,15 @@ for xml in sorted(glob('output/*/*.xml')):
os.unlink(audio) os.unlink(audio)
shutil.move(pre, mp4) shutil.move(pre, mp4)
''' '''
shutil.move(video, mp4) duration = get_videoduration(video)
cmd = [
'ffmpeg', '-y',
'-i', video,
'-c:a', 'copy',
'-c:v', 'copy',
'-t', duration,
pre
]
subprocess.call(cmd)
os.unlink(video)
shutil.move(pre, mp4)