use file for large edits

This commit is contained in:
j 2017-08-09 16:40:28 +02:00
parent 62831c5067
commit f07318bea7

21
ffmpeg.py Normal file → Executable file
View file

@ -5,8 +5,8 @@ import subprocess
import sys
def run(cmd):
print(' '.join('"%s"' % c for c in cmd))
#subprocess.call(cmd)
#print(' '.join('"%s"' % c for c in cmd))
subprocess.call(cmd)
edit_json = sys.argv[1]
@ -18,10 +18,12 @@ height = 270
aspect = 16/9
width = int(height * aspect)
n = 0
files = []
for clip in edit:
out = render + '/%06d.ts' % n
out = render + '/%s_%0.3f-%0.3f.ts' % (clip['oshash'], clip['in'], clip['out'])
files.append(out)
if os.path.exists(out):
continue
clip_aspect = clip['resolution'][0] / clip['resolution'][1]
if clip_aspect < aspect:
x = width
@ -37,7 +39,7 @@ for clip in edit:
vf += ',crop=w=%s:h=%s:x=0:y=%s' % (width, height, offset)
options = [
'-vf', vf,
'-aspect', aspect,
'-aspect', str(aspect),
'-c:v', 'libx264',
'-b:v', '8M',
'-r:v', '25',
@ -54,10 +56,11 @@ for clip in edit:
'-t', str(clip['out'] - clip['in']),
out
]
files.append(out)
run(cmd)
n += 1
files = '|'.join(files)
cmd = ['ffmpeg', '-y', '-i', 'concat:' + files, '-c', 'copy', output]
txt = output + '.txt'
with open(txt, 'w') as fd:
fd.write('file ' + '\nfile '.join(files))
cmd = ['ffmpeg', '-y', '-f', 'concat', '-safe', '0', '-i', txt, '-c', 'copy', output]
run(cmd)
os.unlink(txt)