use file for large edits
This commit is contained in:
parent
62831c5067
commit
f07318bea7
1 changed files with 12 additions and 9 deletions
21
ffmpeg.py
Normal file → Executable file
21
ffmpeg.py
Normal file → Executable file
|
@ -5,8 +5,8 @@ import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
def run(cmd):
|
def run(cmd):
|
||||||
print(' '.join('"%s"' % c for c in cmd))
|
#print(' '.join('"%s"' % c for c in cmd))
|
||||||
#subprocess.call(cmd)
|
subprocess.call(cmd)
|
||||||
|
|
||||||
|
|
||||||
edit_json = sys.argv[1]
|
edit_json = sys.argv[1]
|
||||||
|
@ -18,10 +18,12 @@ height = 270
|
||||||
aspect = 16/9
|
aspect = 16/9
|
||||||
width = int(height * aspect)
|
width = int(height * aspect)
|
||||||
|
|
||||||
n = 0
|
|
||||||
files = []
|
files = []
|
||||||
for clip in edit:
|
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]
|
clip_aspect = clip['resolution'][0] / clip['resolution'][1]
|
||||||
if clip_aspect < aspect:
|
if clip_aspect < aspect:
|
||||||
x = width
|
x = width
|
||||||
|
@ -37,7 +39,7 @@ for clip in edit:
|
||||||
vf += ',crop=w=%s:h=%s:x=0:y=%s' % (width, height, offset)
|
vf += ',crop=w=%s:h=%s:x=0:y=%s' % (width, height, offset)
|
||||||
options = [
|
options = [
|
||||||
'-vf', vf,
|
'-vf', vf,
|
||||||
'-aspect', aspect,
|
'-aspect', str(aspect),
|
||||||
'-c:v', 'libx264',
|
'-c:v', 'libx264',
|
||||||
'-b:v', '8M',
|
'-b:v', '8M',
|
||||||
'-r:v', '25',
|
'-r:v', '25',
|
||||||
|
@ -54,10 +56,11 @@ for clip in edit:
|
||||||
'-t', str(clip['out'] - clip['in']),
|
'-t', str(clip['out'] - clip['in']),
|
||||||
out
|
out
|
||||||
]
|
]
|
||||||
files.append(out)
|
|
||||||
run(cmd)
|
run(cmd)
|
||||||
n += 1
|
|
||||||
|
|
||||||
files = '|'.join(files)
|
txt = output + '.txt'
|
||||||
cmd = ['ffmpeg', '-y', '-i', 'concat:' + files, '-c', 'copy', output]
|
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)
|
run(cmd)
|
||||||
|
os.unlink(txt)
|
||||||
|
|
Loading…
Reference in a new issue