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': {
'V1': [],
'V2': [],
},
'audio-back': {
'A1': [],
},
'audio-center': {
@ -225,7 +227,7 @@ def compose(clips, target=150, base=1024, voice_over=None):
blur = seq() * 3
if blur:
scene['back']['V1'][-1]['filter']['blur'] = blur
scene['back']['A1'].append({
scene['audio-back']['A1'].append({
'duration': clip['duration'],
'src': clip['original'],
})
@ -394,7 +396,7 @@ def render_all(options):
if ext == '.wav':
cmd += ['vn=1']
else:
if not timeline.endswith("back.kdenlive"):
#if not timeline.endswith("back.kdenlive"):
cmd += ['an=1']
cmd += ['vcodec=libx264', 'x264opts=keyint=1', 'crf=15']
subprocess.call(cmd)
@ -445,18 +447,34 @@ def render_all(options):
"-c", "copy",
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:
#print(" ".join([str(x) for x in cmd]))
subprocess.call(cmd)
ft = ox.avinfo(str(fragment_prefix / "front-5.1.mp4"))['duration']
bt = ox.avinfo(str(fragment_prefix / "back.mp4"))['duration']
if ft != bt:
print(ft, fragment_prefix / "front-5.1.mp4")
print(bt, fragment_prefix / "back.mp4")
for a, b in (
("back-audio.mp4", "back.mp4"),
("front-5.1.mp4", "back.mp4"),
):
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")
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
if os.path.exists(fn):