melt bug with a/v timeline not resulting in correct length. render a and v and join after that

This commit is contained in:
j 2023-11-09 01:11:51 +01:00
parent 069eec802d
commit 67eaf22ae9

View file

@ -56,6 +56,8 @@ def compose(clips, target=150, base=1024, voice_over=None):
'back': { 'back': {
'V1': [], 'V1': [],
'V2': [], 'V2': [],
},
'audio-back': {
'A1': [], 'A1': [],
}, },
'audio-center': { 'audio-center': {
@ -225,7 +227,7 @@ def compose(clips, target=150, base=1024, voice_over=None):
blur = seq() * 3 blur = seq() * 3
if blur: if blur:
scene['back']['V1'][-1]['filter']['blur'] = blur scene['back']['V1'][-1]['filter']['blur'] = blur
scene['back']['A1'].append({ scene['audio-back']['A1'].append({
'duration': clip['duration'], 'duration': clip['duration'],
'src': clip['original'], 'src': clip['original'],
}) })
@ -394,8 +396,8 @@ def render_all(options):
if ext == '.wav': if ext == '.wav':
cmd += ['vn=1'] cmd += ['vn=1']
else: else:
if not timeline.endswith("back.kdenlive"): #if not timeline.endswith("back.kdenlive"):
cmd += ['an=1'] cmd += ['an=1']
cmd += ['vcodec=libx264', 'x264opts=keyint=1', 'crf=15'] cmd += ['vcodec=libx264', 'x264opts=keyint=1', 'crf=15']
subprocess.call(cmd) subprocess.call(cmd)
if ext == '.wav' and timeline.endswith('audio.kdenlive'): if ext == '.wav' and timeline.endswith('audio.kdenlive'):
@ -445,18 +447,34 @@ def render_all(options):
"-c", "copy", "-c", "copy",
fragment_prefix / "front-5.1.mp4", fragment_prefix / "front-5.1.mp4",
]) ])
cmds.append([
"ffmpeg", "-y",
"-nostats", "-loglevel", "error",
"-i", fragment_prefix / "back.mp4",
"-i", fragment_prefix / "audio-back.wav",
"-c:v", "copy",
fragment_prefix / "back-audio.mp4",
])
for cmd in cmds: for cmd in cmds:
#print(" ".join([str(x) for x in cmd])) #print(" ".join([str(x) for x in cmd]))
subprocess.call(cmd) subprocess.call(cmd)
ft = ox.avinfo(str(fragment_prefix / "front-5.1.mp4"))['duration']
bt = ox.avinfo(str(fragment_prefix / "back.mp4"))['duration'] for a, b in (
if ft != bt: ("back-audio.mp4", "back.mp4"),
print(ft, fragment_prefix / "front-5.1.mp4") ("front-5.1.mp4", "back.mp4"),
print(bt, fragment_prefix / "back.mp4") ):
sys.exit(-1) duration_a = ox.avinfo(str(fragment_prefix / a))['duration']
duration_b = ox.avinfo(str(fragment_prefix / b))['duration']
if duration_a != duration_b:
print('!!', duration_a, fragment_prefix / a)
print('!!', duration_b, fragment_prefix / b)
sys.exit(-1)
shutil.move(fragment_prefix / "back-audio.mp4", fragment_prefix / "back.mp4")
shutil.move(fragment_prefix / "front-5.1.mp4", fragment_prefix / "front.mp4") shutil.move(fragment_prefix / "front-5.1.mp4", fragment_prefix / "front.mp4")
for fn in ( for fn in (
"audio-5.1.mp4", "fl.wav", "fr.wav", "fc.wav", "lfe.wav", "bl.wav", "br.wav", "audio-5.1.mp4",
"audio-back-wav", "back-audio.mp4",
"fl.wav", "fr.wav", "fc.wav", "lfe.wav", "bl.wav", "br.wav",
): ):
fn = fragment_prefix / fn fn = fragment_prefix / fn
if os.path.exists(fn): if os.path.exists(fn):