render all fragments
This commit is contained in:
parent
a5957fc3b2
commit
d113c5d79e
4 changed files with 99 additions and 36 deletions
|
|
@ -5,7 +5,7 @@ import subprocess
|
|||
from django.core.management.base import BaseCommand
|
||||
from django.conf import settings
|
||||
|
||||
from ...render import compose, render
|
||||
from ...render import render_all
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
|
@ -13,38 +13,9 @@ class Command(BaseCommand):
|
|||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument('--prefix', action='store', dest='prefix', default="/srv/t_for_time", help='prefix to build clips in')
|
||||
parser.add_argument('--duration', action='store', dest='duration', default="150", help='target duration in seconds')
|
||||
parser.add_argument('--duration', action='store', dest='duration', default="3600", help='target duration of all fragments in seconds')
|
||||
parser.add_argument('--offset', action='store', dest='offset', default="1024", help='inital offset in pi')
|
||||
parser.add_argument('--no-video', action='store_true', dest='no_video', default=False, help='don\'t render video')
|
||||
|
||||
def handle(self, **options):
|
||||
prefix = options['prefix']
|
||||
target = int(options['duration'])
|
||||
base = int(options['offset'])
|
||||
|
||||
with open(os.path.join(prefix, "clips.json")) as fd:
|
||||
clips = json.load(fd)
|
||||
scene = compose(clips, target=target, base=base)
|
||||
timelines = render(prefix, scene, 'scene-%s-' % base)
|
||||
with open(os.path.join(prefix, 'scene-%s.json' % base), 'w') as fd:
|
||||
json.dump(scene, fd, indent=2, ensure_ascii=False)
|
||||
if not options['no_video']:
|
||||
for timeline in timelines:
|
||||
ext = '.mp4'
|
||||
if '-audio.kdenlive' in timeline:
|
||||
ext = '.wav'
|
||||
cmd = [
|
||||
'xvfb-run', '-a',
|
||||
'melt', timeline,
|
||||
'-consumer', 'avformat:%s' % timeline.replace('.kdenlive', ext)
|
||||
]
|
||||
subprocess.call(cmd)
|
||||
if ext == '.wav':
|
||||
cmd = [
|
||||
'ffmpeg', '-i',
|
||||
timeline.replace('.kdenlive', ext),
|
||||
timeline.replace('.kdenlive', '.mp4')
|
||||
]
|
||||
subprocess.call(cmd)
|
||||
os.unlink(timeline.replace('.kdenlive', ext))
|
||||
|
||||
render_all(options)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue