more sound
This commit is contained in:
parent
21b6ef9cef
commit
ade3f53db2
2 changed files with 42 additions and 22 deletions
23
render.py
23
render.py
|
|
@ -14,7 +14,7 @@ import ox
|
||||||
|
|
||||||
from .pi import random
|
from .pi import random
|
||||||
from .render_kdenlive import KDEnliveProject, _CACHE, get_melt
|
from .render_kdenlive import KDEnliveProject, _CACHE, get_melt
|
||||||
from .utils import resolve_roman, write_if_new, format_duration
|
from .utils import resolve_roman, write_if_new, format_duration, needs_update
|
||||||
from .render_utils import *
|
from .render_utils import *
|
||||||
|
|
||||||
default_prefix = "/srv/p_for_power"
|
default_prefix = "/srv/p_for_power"
|
||||||
|
|
@ -153,7 +153,7 @@ def compose(clips, fragment, target=150, base=1024, voice_over=None, options=Non
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
volume_front = '-14'
|
volume_front = '-15'
|
||||||
if clip.get('volume') is not None:
|
if clip.get('volume') is not None:
|
||||||
volume_front = '%0.2f' % (float(volume_front) + clip['volume'])
|
volume_front = '%0.2f' % (float(volume_front) + clip['volume'])
|
||||||
|
|
||||||
|
|
@ -263,11 +263,11 @@ def compose(clips, fragment, target=150, base=1024, voice_over=None, options=Non
|
||||||
print('%07.3f-%07.3f %07.3f' % (sub_offset, sub_offset+vo["duration"], vo["duration"]), vo["src"].split('/')[-1])
|
print('%07.3f-%07.3f %07.3f' % (sub_offset, sub_offset+vo["duration"], vo["duration"]), vo["src"].split('/')[-1])
|
||||||
voice_overs.append(vo)
|
voice_overs.append(vo)
|
||||||
voc = vo.copy()
|
voc = vo.copy()
|
||||||
a, b = '5', '-1'
|
a, b = '4', '-2'
|
||||||
#if options.get('stereo_downmix'):
|
#if options.get('stereo_downmix'):
|
||||||
# a, b = '5', '-1'
|
# a, b = '5', '-1'
|
||||||
if vo_b:
|
if vo_b:
|
||||||
a, b = '3', '-3'
|
a, b = '2', '-4'
|
||||||
voc['filter'] = {'volume': a}
|
voc['filter'] = {'volume': a}
|
||||||
scene['audio-center']['A1'].append(voc)
|
scene['audio-center']['A1'].append(voc)
|
||||||
vo_low = vo.copy()
|
vo_low = vo.copy()
|
||||||
|
|
@ -553,10 +553,11 @@ def render_all(options):
|
||||||
ext = '.mp4'
|
ext = '.mp4'
|
||||||
if '/audio' in timeline:
|
if '/audio' in timeline:
|
||||||
ext = '.wav'
|
ext = '.wav'
|
||||||
|
out = '%s' % timeline.replace('.kdenlive', ext)
|
||||||
cmd = get_melt() + [
|
cmd = get_melt() + [
|
||||||
timeline,
|
timeline,
|
||||||
'-quiet',
|
'-quiet',
|
||||||
'-consumer', 'avformat:%s' % timeline.replace('.kdenlive', ext),
|
'-consumer', 'avformat:%s' % out,
|
||||||
]
|
]
|
||||||
if ext == '.wav':
|
if ext == '.wav':
|
||||||
cmd += ['vn=1']
|
cmd += ['vn=1']
|
||||||
|
|
@ -566,6 +567,7 @@ def render_all(options):
|
||||||
cmd += ['vcodec=h264_qsv', 'pix_fmt=nv12', 'rc=icq', 'global_quality=17']
|
cmd += ['vcodec=h264_qsv', 'pix_fmt=nv12', 'rc=icq', 'global_quality=17']
|
||||||
elif options.get("only_keyframes"):
|
elif options.get("only_keyframes"):
|
||||||
cmd += ['vcodec=libx264', 'x264opts=keyint=1', 'crf=15']
|
cmd += ['vcodec=libx264', 'x264opts=keyint=1', 'crf=15']
|
||||||
|
if needs_update(timeline, out):
|
||||||
subprocess.call(cmd)
|
subprocess.call(cmd)
|
||||||
if ext == '.wav' and timeline.endswith('audio.kdenlive'):
|
if ext == '.wav' and timeline.endswith('audio.kdenlive'):
|
||||||
cmd = [
|
cmd = [
|
||||||
|
|
@ -575,8 +577,12 @@ def render_all(options):
|
||||||
timeline.replace('.kdenlive', ext),
|
timeline.replace('.kdenlive', ext),
|
||||||
timeline.replace('.kdenlive', '.mp4')
|
timeline.replace('.kdenlive', '.mp4')
|
||||||
]
|
]
|
||||||
|
wav = timeline.replace('.kdenlive', ext)
|
||||||
|
mp4 = timeline.replace('.kdenlive', '.mp4')
|
||||||
|
if needs_update(wav, mp4):
|
||||||
subprocess.call(cmd)
|
subprocess.call(cmd)
|
||||||
os.unlink(timeline.replace('.kdenlive', ext))
|
if not options.get("keep_parts"):
|
||||||
|
os.unlink(wav)
|
||||||
|
|
||||||
cmds = []
|
cmds = []
|
||||||
fragment_prefix = Path(fragment_prefix)
|
fragment_prefix = Path(fragment_prefix)
|
||||||
|
|
@ -667,6 +673,7 @@ def render_all(options):
|
||||||
"vocals.wav",
|
"vocals.wav",
|
||||||
"foley.wav"
|
"foley.wav"
|
||||||
]
|
]
|
||||||
|
if not options.get("keep_parts"):
|
||||||
for fn in cleanup:
|
for fn in cleanup:
|
||||||
fn = fragment_prefix / fn
|
fn = fragment_prefix / fn
|
||||||
if os.path.exists(fn):
|
if os.path.exists(fn):
|
||||||
|
|
@ -698,12 +705,15 @@ def render_all(options):
|
||||||
cmd += ['vcodec=h264_qsv', 'pix_fmt=nv12', 'rc=icq', 'global_quality=17']
|
cmd += ['vcodec=h264_qsv', 'pix_fmt=nv12', 'rc=icq', 'global_quality=17']
|
||||||
elif options.get("only_keyframes"):
|
elif options.get("only_keyframes"):
|
||||||
cmd += ['vcodec=libx264', 'x264opts=keyint=1', 'crf=15']
|
cmd += ['vcodec=libx264', 'x264opts=keyint=1', 'crf=15']
|
||||||
|
if needs_update(timelines[0], out):
|
||||||
cmds.append(cmd)
|
cmds.append(cmd)
|
||||||
|
|
||||||
for src, out1, out2 in (
|
for src, out1, out2 in (
|
||||||
("audio-front.wav", "fl.wav", "fr.wav"),
|
("audio-front.wav", "fl.wav", "fr.wav"),
|
||||||
("audio-center.wav", "fc.wav", "lfe.wav"),
|
("audio-center.wav", "fc.wav", "lfe.wav"),
|
||||||
("audio-rear.wav", "bl.wav", "br.wav"),
|
("audio-rear.wav", "bl.wav", "br.wav"),
|
||||||
):
|
):
|
||||||
|
if needs_update(src, out1):
|
||||||
cmds.append([
|
cmds.append([
|
||||||
"ffmpeg", "-y",
|
"ffmpeg", "-y",
|
||||||
"-nostats", "-loglevel", "error",
|
"-nostats", "-loglevel", "error",
|
||||||
|
|
@ -713,6 +723,7 @@ def render_all(options):
|
||||||
"-map", "[left]", base_prefix / out1,
|
"-map", "[left]", base_prefix / out1,
|
||||||
"-map", "[right]", base_prefix / out2,
|
"-map", "[right]", base_prefix / out2,
|
||||||
])
|
])
|
||||||
|
|
||||||
cmds.append([
|
cmds.append([
|
||||||
"ffmpeg", "-y",
|
"ffmpeg", "-y",
|
||||||
"-nostats", "-loglevel", "error",
|
"-nostats", "-loglevel", "error",
|
||||||
|
|
|
||||||
9
utils.py
9
utils.py
|
|
@ -42,6 +42,15 @@ def remove_deselected_files():
|
||||||
if changed:
|
if changed:
|
||||||
i.save()
|
i.save()
|
||||||
|
|
||||||
|
def needs_update(src, out):
|
||||||
|
mtime_src = os.lstat(src).st_mtime
|
||||||
|
mtime_out = os.lstat(out).st_mtime
|
||||||
|
#print("compare", src, out)
|
||||||
|
#print("ts", mtime_src, mtime_out, mtime_src > mtime_out)
|
||||||
|
if not os.path.exists(out) or mtime_src > mtime_out:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def write_if_new(path, data, mode=''):
|
def write_if_new(path, data, mode=''):
|
||||||
read_mode = 'r' + mode
|
read_mode = 'r' + mode
|
||||||
write_mode = 'w' + mode
|
write_mode = 'w' + mode
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue